Skip to content

Commit

Permalink
Merge pull request #1454 from algolia/bugfix/MAGE-808
Browse files Browse the repository at this point in the history
MAGE-808 Add to Cart issue on PLP Page
  • Loading branch information
mohitalgolia authored Dec 12, 2023
2 parents c0f6ed6 + 4570a1f commit 0247b4c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion view/frontend/web/instantsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,21 @@ define(
}
});

var isStarted = false;
// Capture active redirect URL with IS facet params for add to cart from PLP
if (algoliaConfig.instant.isAddToCartEnabled) {
search.on('render', () => {
const cartForms = document.querySelectorAll('[data-role="tocart-form"]');
cartForms.forEach((form, i) => {
const ts = Date.now();
form.addEventListener('submit', e => {
const url = `${algoliaConfig.request.url}${window.location.search}`;
e.target.elements[algoliaConfig.instant.addToCartParams.redirectUrlParam].value = AlgoliaBase64.mageEncode(url);
})
});
});
}

var isStarted = false;

function startInstantSearch() {
if (isStarted === true) {
Expand Down

0 comments on commit 0247b4c

Please sign in to comment.