forked from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
USF-1510: Cart Summary has a Footer Slot
- add footer slot example to the boilerplate
- Loading branch information
Showing
21 changed files
with
146 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
import CartSummaryList from "@dropins/storefront-cart/containers/CartSummaryList.js"; | ||
import { readBlockConfig } from "../../scripts/aem.js"; | ||
|
||
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 GitHub Actions / build
|
||
"start-shopping-url": startShoppingURL = "", | ||
Check failure on line 8 in blocks/commerce-cart-summary/commerce-cart-summary.js GitHub Actions / build
|
||
"max-items": maxItems, | ||
"hide-attributes": hideAttributes = "", | ||
Check failure on line 10 in blocks/commerce-cart-summary/commerce-cart-summary.js GitHub Actions / build
|
||
"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); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.