Skip to content

CartAddLinesButton

Add several lines to the active cart in one write, creating a cart where there is none, and say why when the cart refuses. Disabled with nothing to add.

import { CartAddLinesButton } from "@evolve-storefront/feature-cart/cart-add-lines-button";

Renders inside CartProvider.

Preview

DefaultOpen in Storybook ↗

Usage

// Reorder: the order's lines in one write, then on to the cart.
<CartAddLinesButton
lineItems={orderLinesToAdd(order)}
onAdded={() => router.push("/cart")}
/>;

Props

PropTypeDescription
lineItemsCartLineItemInput[]

What to add, in one write: an order's lines to reorder, a list's to buy.

onAdded?((result: LineItemsAddedResult) => void)

After the write, overriding CartProvider's onLineItemsAdded: typically route to the cart. A partial OUT_OF_STOCK add arrives here as warnings.

children?ReactNode

The label. Defaults to "Add all to cart".

Any other props go to the root element, like on a plain HTML element.