Skip to content

Commit

Permalink
Merge pull request #1261 from hlxsites/add2cart-fix
Browse files Browse the repository at this point in the history
fix: order options for hero
  • Loading branch information
mhaack authored Oct 27, 2023
2 parents 0955a6d + 7f3f7bd commit 08d8f58
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions blocks/ordering-options/ordering-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,18 @@ async function renderOptions(orderBlock, heroBlock, productRefs, itemDescription

function showHideStoreFeature(showStore, orderBlock, heroBlock) {
renderCartWidget(showStore);
const heroOrder = heroBlock.querySelector('.order-container');
let heroOrder = heroBlock?.querySelector('.order-container');
if (heroOrder && heroBlock.querySelector('img')) heroOrder = undefined;
if (showStore) {
orderBlock.classList.remove(STORE_HIDDEN_CLASS);
if (heroOrder) heroOrder.classList.remove(STORE_HIDDEN_CLASS);
// hide buttons in hero and instead show option form
if (heroBlock) {
heroBlock.querySelectorAll('.button-container').forEach((buttonContainer) => {
buttonContainer.remove();
});
if (heroOrder) {
heroOrder.classList.remove(STORE_HIDDEN_CLASS);
// hide buttons in hero and instead show option form
if (heroBlock) {
heroBlock.querySelectorAll('.button-container').forEach((buttonContainer) => {
buttonContainer.remove();
});
}
}
} else {
orderBlock.classList.add(STORE_HIDDEN_CLASS);
Expand Down Expand Up @@ -462,6 +465,6 @@ export default async function decorate(block) {
showHideStoreFeature(showStore, block, heroBlock);

document.addEventListener('geolocationUpdated', () => {
showHideStoreFeature(block, showStore);
showHideStoreFeature(showStore, block, heroBlock);
});
}

0 comments on commit 08d8f58

Please sign in to comment.