From 8934d18e9c71b3ca6882f7cfc2e4ba038e34a7aa Mon Sep 17 00:00:00 2001 From: Anthoula Wojczak Date: Mon, 11 Nov 2024 14:51:31 -0600 Subject: [PATCH] USF-1510 DEMO: Cart Summary has a Footer Slot (#194) * 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 --- blocks/commerce-cart/commerce-cart.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/blocks/commerce-cart/commerce-cart.js b/blocks/commerce-cart/commerce-cart.js index f49b8dfa8d..6dae2fd289 100644 --- a/blocks/commerce-cart/commerce-cart.js +++ b/blocks/commerce-cart/commerce-cart.js @@ -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;