Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The `CartSummaryList` container provides the following configuration options:
| `dropdownOptions` | `string[]` | No | An array of items to display in a dropdown menu. |
| `undo` | `boolean` | No | Enables the undo banner to restore recently removed items to the cart. |
| `includeOutOfStockItems` | `boolean` | No | Display out-of-stock and insufficient-quantity items in the main cart item list alongside in-stock items. Default: `false`. |
| `confirmBeforeDelete` | `boolean` | No | Enables the confirmation banner when an item is removed from the cart. When set to true, clicking the remove button shows an inline confirmation banner instead of immediately deleting the item. |

</TableWrapper>

Expand All @@ -70,6 +71,7 @@ The `CartSummaryList` container supports the following slots:
* CartSummaryFooter
* CartItem
* UndoBanner
* ConfirmDeleteBanner
* ItemTitle
* ItemPrice
* ItemQuantity
Expand All @@ -86,6 +88,7 @@ provider.render(CartSummaryList, {
enableRemoveItem: true,
enableUpdateItemQuantity: true,
showDiscount: true,
// confirmBeforeDelete: true,
// accordion: true,
// includeOutOfStockItems: true,
// showMaxItems: false,
Expand Down
3 changes: 3 additions & 0 deletions src/content/docs/dropins/cart/containers/mini-cart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The `MiniCart` container provides the following configuration options:
| `enableQuantityUpdate` | `boolean` | No | Flag to enable updating item quantities in the mini cart. When set to true, users can adjust product quantities directly in the mini cart interface. |
| `hideHeading` | `boolean` | No | Flag to hide the heading in the mini cart. When set to true, the mini cart header will not be displayed. |
| `undo` | `boolean` | No | Enables the undo banner to restore recently removed items to the cart. |
| `confirmBeforeDelete` | `boolean` | No | Enables the confirmation banner when an item is removed from the cart. When set to true, clicking the remove button shows an inline confirmation banner instead of immediately deleting the item. |

</TableWrapper>

Expand All @@ -61,6 +62,7 @@ The `MiniCart` container supports the following slots:
* CartSummaryFooter
* CartItem
* UndoBanner
* ConfirmDeleteBanner
* ItemTitle
* ItemPrice
* ItemQuantity
Expand All @@ -85,5 +87,6 @@ provider.render(MiniCart, {
// enableItemRemoval: true,
// enableQuantityUpdate: true,
// hideHeading: true,
// confirmBeforeDelete: true,
})($miniCart);
```
90 changes: 88 additions & 2 deletions src/content/docs/dropins/cart/slots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Do not use context methods inside other context methods (for example, `appendChi
| Container | Slots |
|-----------|-------|
| [`CartSummaryGrid`](#cartsummarygrid-slots) | `Thumbnail` |
| [`CartSummaryList`](#cartsummarylist-slots) | `Heading`, `EmptyCart`, `Footer`, `RowTotalFooter`, `Thumbnail`, `ProductAttributes`, `CartSummaryFooter`, `CartItem`, `UndoBanner`, `ItemTitle`, `ItemPrice`, `ItemQuantity`, `ItemTotal`, `ItemSku`, `ItemRemoveAction` |
| [`CartSummaryList`](#cartsummarylist-slots) | `Heading`, `EmptyCart`, `Footer`, `RowTotalFooter`, `Thumbnail`, `ProductAttributes`, `CartSummaryFooter`, `CartItem`, `UndoBanner`, `ConfirmDeleteBanner`, `ItemTitle`, `ItemPrice`, `ItemQuantity`, `ItemTotal`, `ItemSku`, `ItemRemoveAction` |
| [`CartSummaryTable`](#cartsummarytable-slots) | `Item`, `Price`, `Quantity`, `Subtotal`, `Thumbnail`, `ProductTitle`, `Sku`, `Configurations`, `ItemAlert`, `ItemWarning`, `Actions`, `UndoBanner`, `EmptyCart` |
| [`GiftOptions`](#giftoptions-slots) | `SwatchImage` |
| [`MiniCart`](#minicart-slots) | `ProductList`, `ProductListFooter`, `PreCheckoutSection`, `Thumbnail`, `Heading`, `EmptyCart`, `Footer`, `RowTotalFooter`, `ProductAttributes`, `CartSummaryFooter`, `CartItem`, `UndoBanner`, `ItemTitle`, `ItemPrice`, `ItemQuantity`, `ItemTotal`, `ItemSku`, `ItemRemoveAction` |
| [`MiniCart`](#minicart-slots) | `ProductList`, `ProductListFooter`, `PreCheckoutSection`, `Thumbnail`, `Heading`, `EmptyCart`, `Footer`, `RowTotalFooter`, `ProductAttributes`, `CartSummaryFooter`, `CartItem`, `UndoBanner`, `ConfirmDeleteBanner`, `ItemTitle`, `ItemPrice`, `ItemQuantity`, `ItemTotal`, `ItemSku`, `ItemRemoveAction` |
| [`OrderSummary`](#ordersummary-slots) | `EstimateShipping`, `Coupons`, `GiftCards` |

</TableWrapper>
Expand Down Expand Up @@ -98,6 +98,11 @@ interface CartSummaryListProps {
onUndo: () => void;
onDismiss: () => void;
}>;
ConfirmDeleteBanner?: SlotProps<{
item: CartModel['items'][number];
onConfirm: () => void;
onCancel: () => void;
}>;
ItemTitle?: SlotProps<{ item: CartModel['items'][number] }>;
ItemPrice?: SlotProps<{ item: CartModel['items'][number] }>;
ItemQuantity?: SlotProps<{
Expand Down Expand Up @@ -337,6 +342,44 @@ await provider.render(CartSummaryList, {
})(block);
```

### ConfirmDeleteBanner slot

The `ConfirmDeleteBanner` slot lets you replace the default confirmation banner that appears when `confirmBeforeDelete={true}` and a shopper reduces an item's quantity to 0 or clicks the remove button. Use it to customize the banner's appearance, message text, and action buttons.

#### Context

The slot receives the following context:

| Property | Type | Description |
|----------|------|-------------|
| `item` | `CartModel['items'][number]` | The cart item pending deletion. |
| `onConfirm` | `() => void` | Call to confirm deletion and trigger the remove API. |
| `onCancel` | `() => void` | Call to dismiss the banner and restore the item row with its original quantity. |

#### Example

```js
import { render as provider } from '@dropins/storefront-cart/render.js';
import { CartSummaryList } from '@dropins/storefront-cart/containers/CartSummaryList.js';

await provider.render(CartSummaryList, {
confirmBeforeDelete: true,
slots: {
ConfirmDeleteBanner: (ctx) => {
const banner = document.createElement('div');
banner.innerHTML = `
<p>Remove "${ctx.item.name}" from your cart?</p>
<button id="confirm">Remove</button>
<button id="cancel">Keep it</button>
`;
banner.querySelector('#confirm').addEventListener('click', ctx.onConfirm);
banner.querySelector('#cancel').addEventListener('click', ctx.onCancel);
ctx.appendChild(banner);
}
}
})(block);
```

### ItemTitle slot

The `ItemTitle` slot allows you to customize the item title section of the `CartSummaryList` container.
Expand Down Expand Up @@ -536,6 +579,11 @@ interface MiniCartProps {
onUndo: () => void;
onDismiss: () => void;
}>;
ConfirmDeleteBanner?: SlotProps<{
item: CartModel['items'][number];
onConfirm: () => void;
onCancel: () => void;
}>;
ItemTitle?: SlotProps<{ item: CartModel['items'][number] }>;
ItemPrice?: SlotProps<{ item: CartModel['items'][number] }>;
ItemQuantity?: SlotProps<{
Expand Down Expand Up @@ -820,6 +868,44 @@ await provider.render(MiniCart, {
})(block);
```

### ConfirmDeleteBanner slot

The `ConfirmDeleteBanner` slot lets you replace the default confirmation banner that appears when `confirmBeforeDelete={true}` and a shopper clicks the remove button. Use it to customize the banner's appearance, message text, and action buttons.

#### Context

The slot receives the following context:

| Property | Type | Description |
|----------|------|-------------|
| `item` | `CartModel['items'][number]` | The cart item pending deletion. |
| `onConfirm` | `() => void` | Call to confirm deletion and trigger the remove API. |
| `onCancel` | `() => void` | Call to dismiss the banner and restore the item row with its original quantity. |

#### Example

```js
import { render as provider } from '@dropins/storefront-cart/render.js';
import { MiniCart } from '@dropins/storefront-cart/containers/MiniCart.js';

await provider.render(MiniCart, {
confirmBeforeDelete: true,
slots: {
ConfirmDeleteBanner: (ctx) => {
const banner = document.createElement('div');
banner.innerHTML = `
<p>Remove "${ctx.item.name}" from your cart?</p>
<button id="confirm">Remove</button>
<button id="cancel">Keep it</button>
`;
banner.querySelector('#confirm').addEventListener('click', ctx.onConfirm);
banner.querySelector('#cancel').addEventListener('click', ctx.onCancel);
ctx.appendChild(banner);
}
}
})(block);
```

### ItemTitle slot

The `ItemTitle` slot allows you to customize the item title section of the `MiniCart` container.
Expand Down
Loading