Skip to content

Commit

Permalink
USF-1510: Cart Summary has a Footer Slot
Browse files Browse the repository at this point in the history
- add footer slot example to the boilerplate
  • Loading branch information
anthoula committed Sep 23, 2024
1 parent e66e6ee commit c0520ff
Show file tree
Hide file tree
Showing 21 changed files with 146 additions and 54 deletions.
44 changes: 30 additions & 14 deletions blocks/commerce-cart-summary/commerce-cart-summary.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
import { render as provider } from '@dropins/storefront-cart/render.js';
import CartSummaryList from '@dropins/storefront-cart/containers/CartSummaryList.js';
import { readBlockConfig } from '../../scripts/aem.js';
import { render as provider } from "@dropins/storefront-cart/render.js";

Check failure on line 1 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import CartSummaryList from "@dropins/storefront-cart/containers/CartSummaryList.js";

Check failure on line 2 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
import { readBlockConfig } from "../../scripts/aem.js";

Check failure on line 3 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

export default async function decorate(block) {
const {
'hide-heading': hideHeading = 'false',
'start-shopping-url': startShoppingURL = '',
'max-items': maxItems,
'hide-attributes': hideAttributes = '',
'enable-item-quantity-update': enableUpdateItemQuantity = 'false',
'enable-item-remove': enableRemoveItem = 'true',
"hide-heading": hideHeading = "false",

Check failure on line 7 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

Check failure on line 7 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
"start-shopping-url": startShoppingURL = "",

Check failure on line 8 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

Check failure on line 8 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
"max-items": maxItems,

Check failure on line 9 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
"hide-attributes": hideAttributes = "",

Check failure on line 10 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

Check failure on line 10 in blocks/commerce-cart-summary/commerce-cart-summary.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
"enable-item-quantity-update": enableUpdateItemQuantity = "false",
"enable-item-remove": enableRemoveItem = "true",
} = readBlockConfig(block);

block.innerHTML = '';
block.innerHTML = "";

return provider.render(CartSummaryList, {
hideHeading: hideHeading === 'true',
hideHeading: hideHeading === "true",
routeProduct: (product) => `/products/${product.url.urlKey}/${product.sku}`,
routeEmptyCartCTA: startShoppingURL ? () => startShoppingURL : undefined,
maxItems: parseInt(maxItems, 10) || undefined,
attributesToHide: hideAttributes.split(',').map((attr) => attr.trim().toLowerCase()),
enableUpdateItemQuantity: enableUpdateItemQuantity === 'true',
enableRemoveItem: enableRemoveItem === 'true',
attributesToHide: hideAttributes
.split(",")
.map((attr) => attr.trim().toLowerCase()),
enableUpdateItemQuantity: enableUpdateItemQuantity === "true",
enableRemoveItem: enableRemoveItem === "true",
slots: {
Footer: (ctx) => {
// Prepend Product Promotions
const discountLabel = ctx.item?.discount?.label;
if (discountLabel) {
discountLabel.map((label) => {
const discount = document.createElement("div");
discount.style.color = "#3d3d3d";
discount.innerText = label;
ctx.appendChild(discount);
});
}
},
},
})(block);
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"dependencies": {
"@adobe/magento-storefront-event-collector": "^1.8.0",
"@adobe/magento-storefront-events-sdk": "^1.8.0",
"@dropins/storefront-cart": "0.6.0",
"@dropins/storefront-cart": "0.7.0-alpha010",
"@dropins/storefront-checkout": "0.1.0-alpha49",
"@dropins/storefront-auth": "0.0.1-alpha20",
"@dropins/storefront-order-confirmation": "0.1.0-alpha33",
"@dropins/storefront-pdp": "0.4.0-alpha3",
"@dropins/tools": "0.30.0"
"@dropins/tools": "0.31.0-alpha005"
}
}
Loading

0 comments on commit c0520ff

Please sign in to comment.