Skip to content

Commit

Permalink
Fix PRex on cart page (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
herzog31 authored Nov 8, 2024
1 parent 59834f8 commit f8e50e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
4 changes: 3 additions & 1 deletion blocks/product-recommendations/product-recommendations.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ export default async function decorate(block) {
}

function handleCartChanges({ shoppingCartContext }) {
context.cartSkus = shoppingCartContext?.items?.map(({ product }) => product.sku);
context.cartSkus = shoppingCartContext?.totalQuantity === 0
? []
: shoppingCartContext?.items?.map(({ product }) => product.sku);
loadRecommendation(block, context, visibility, filters);
}

Expand Down
28 changes: 16 additions & 12 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,24 @@ async function loadEager(doc) {
pageType = 'Checkout';
}

window.adobeDataLayer.push({
pageContext: {
pageType,
pageName: document.title,
eventType: 'visibilityHidden',
maxXOffset: 0,
maxYOffset: 0,
minXOffset: 0,
minYOffset: 0,
window.adobeDataLayer.push(
{
pageContext: {
pageType,
pageName: document.title,
eventType: 'visibilityHidden',
maxXOffset: 0,
maxYOffset: 0,
minXOffset: 0,
minYOffset: 0,
},
},
shoppingCartContext: {
totalQuantity: 0,
{
shoppingCartContext: {
totalQuantity: 0,
},
},
});
);
window.adobeDataLayer.push((dl) => {
dl.push({ event: 'page-view', eventInfo: { ...dl.getState() } });
});
Expand Down

0 comments on commit f8e50e1

Please sign in to comment.