Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-commerce into develop
  • Loading branch information
fnhipster committed Dec 11, 2024
2 parents c07da35 + 501aa54 commit ade7c87
Show file tree
Hide file tree
Showing 348 changed files with 2,911 additions and 2,535 deletions.
13 changes: 11 additions & 2 deletions blocks/commerce-cart/commerce-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import EstimateShipping from '@dropins/storefront-cart/containers/EstimateShippi
import EmptyCart from '@dropins/storefront-cart/containers/EmptyCart.js';
import Coupons from '@dropins/storefront-cart/containers/Coupons.js';

// API
import { publishShoppingCartViewEvent } from '@dropins/storefront-cart/api.js';

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

Expand Down Expand Up @@ -71,7 +74,7 @@ export default async function decorate(block) {
// Cart List
provider.render(CartSummaryList, {
hideHeading: hideHeading === 'true',
routeProduct: (product) => `/products/${product.url.urlKey}/${product.sku}`,
routeProduct: (product) => `/products/${product.url.urlKey}/${product.topLevelSku}`,
routeEmptyCartCTA: startShoppingURL ? () => startShoppingURL : undefined,
maxItems: parseInt(maxItems, 10) || undefined,
attributesToHide: hideAttributes.split(',').map((attr) => attr.trim().toLowerCase()),
Expand All @@ -81,7 +84,7 @@ export default async function decorate(block) {

// Order Summary
provider.render(OrderSummary, {
routeProduct: (product) => `/products/${product.url.urlKey}/${product.sku}`,
routeProduct: (product) => `/products/${product.url.urlKey}/${product.topLevelSku}`,
routeCheckout: checkoutURL ? () => checkoutURL : undefined,
slots: {
EstimateShipping: async (ctx) => {
Expand All @@ -107,9 +110,15 @@ export default async function decorate(block) {
})($emptyCart),
]);

let cartViewEventPublished = false;
// Events
events.on('cart/data', (payload) => {
toggleEmptyCart(isCartEmpty(payload));

if (!cartViewEventPublished) {
cartViewEventPublished = true;
publishShoppingCartViewEvent();
}
}, { eager: true });

return Promise.resolve();
Expand Down
Loading

0 comments on commit ade7c87

Please sign in to comment.