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 to the Cart Summary
  • Loading branch information
anthoula committed Nov 11, 2024
1 parent 6e8221f commit 8180cb5
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions blocks/commerce-cart/commerce-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { render as provider } from '@dropins/storefront-cart/render.js';
import * as Cart from '@dropins/storefront-cart/api.js';

// Dropin Containers
import CartSummaryList from '@dropins/storefront-cart/containers/CartSummaryList.js';
import OrderSummary from '@dropins/storefront-cart/containers/OrderSummary.js';
import EstimateShipping from '@dropins/storefront-cart/containers/EstimateShipping.js';
import EmptyCart from '@dropins/storefront-cart/containers/EmptyCart.js';
import CartSummaryList from "@dropins/storefront-cart/containers/CartSummaryList.js";

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

View workflow job for this annotation

GitHub Actions / build

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

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

View workflow job for this annotation

GitHub Actions / build

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

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

View workflow job for this annotation

GitHub Actions / build

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

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

View workflow job for this annotation

GitHub Actions / build

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

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

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

// Initializers
import '../../scripts/initializers/cart.js';
import "../../scripts/initializers/cart.js";

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

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

import { readBlockConfig } from '../../scripts/aem.js';

Expand Down Expand Up @@ -96,6 +97,23 @@ export default async function decorate(block) {
quantityType: 'dropdown',
dropdownOptions,
slots: {
Footer: (ctx) => {
// Runs on mount
const wrapper = document.createElement("div");

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

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
ctx.appendChild(wrapper);

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

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

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

next.item?.discount?.label?.forEach((label) => {
const discount = document.createElement("div");

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

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
discount.style.color = "#3d3d3d";

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

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
discount.innerText = label;
wrapper.appendChild(discount);
});
});
},
ProductAttributes: (ctx) => {
// Prepend Product Attributes
const productAttributes = ctx.item?.productAttributes;
Expand Down Expand Up @@ -137,6 +155,14 @@ export default async function decorate(block) {
ctx.replaceWith(wrapper);
}
},
Coupons: (ctx) => {
// Prepend Coupons
const coupons = document.createElement("div");

provider.render(Coupons)(coupons);

ctx.appendChild(coupons);
},
},
})($summary),

Expand Down

0 comments on commit 8180cb5

Please sign in to comment.