File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -660,7 +660,21 @@ define(
660
660
}
661
661
} ) ;
662
662
663
- var isStarted = false ;
663
+ // Capture active redirect URL with IS facet params for add to cart from PLP
664
+ if ( algoliaConfig . instant . isAddToCartEnabled ) {
665
+ search . on ( 'render' , ( ) => {
666
+ const cartForms = document . querySelectorAll ( '[data-role="tocart-form"]' ) ;
667
+ cartForms . forEach ( ( form , i ) => {
668
+ const ts = Date . now ( ) ;
669
+ form . addEventListener ( 'submit' , e => {
670
+ const url = `${ algoliaConfig . request . url } ${ window . location . search } ` ;
671
+ e . target . elements [ algoliaConfig . instant . addToCartParams . redirectUrlParam ] . value = AlgoliaBase64 . mageEncode ( url ) ;
672
+ } )
673
+ } ) ;
674
+ } ) ;
675
+ }
676
+
677
+ var isStarted = false ;
664
678
665
679
function startInstantSearch ( ) {
666
680
if ( isStarted === true ) {
You can’t perform that action at this time.
0 commit comments