Skip to content

Commit

Permalink
USF-1510 DEMO: Cart Summary has a Footer Slot (#194)
Browse files Browse the repository at this point in the history
* USF-1510: Cart Summary has a Footer Slot

- add Footer slot to the Cart Summary

* USF-1510: Cart Summary has a Footer Slot

- add Footer slot to the Cart Summary

* USF-1510: Cart Summary has a Footer Slot

- add Footer slot to the Cart Summary
  • Loading branch information
anthoula authored Nov 11, 2024
1 parent 6e8221f commit 8934d18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions blocks/commerce-cart/commerce-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ export default async function decorate(block) {
quantityType: 'dropdown',
dropdownOptions,
slots: {
Footer: (ctx) => {
// Runs on mount
const wrapper = document.createElement('div');
ctx.appendChild(wrapper);

// Append Product Promotions on every update
ctx.onChange((next) => {
wrapper.innerHTML = '';

next.item?.discount?.label?.forEach((label) => {
const discount = document.createElement('div');
discount.style.color = '#3d3d3d';
discount.innerText = label;
wrapper.appendChild(discount);
});
});
},
ProductAttributes: (ctx) => {
// Prepend Product Attributes
const productAttributes = ctx.item?.productAttributes;
Expand Down

0 comments on commit 8934d18

Please sign in to comment.