Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cart not working it was getting the data cart response #63

Open
adventuretocode opened this issue Jan 11, 2023 · 0 comments
Open

Comments

@adventuretocode
Copy link

adventuretocode commented Jan 11, 2023

Remove cart not working it was getting the data cart response

this code block was push data wrong

$(__DL__.removeCartTrigger).click(function(e){
                      var link = $(this).attr("href");
                      console.log(" link  ", link)
                      let targetUrl = e.target.parentElement.href;
                      console.log("target URL", targetUrl)  
                        jQuery.getJSON(link, function (response) {
                            // get Json response
                            
                            console.log("response this is return the current list of items ", response) 
                            __DL__.removeCart = response;
                            var removeFromCart = {
                                'pageType' : 'Cart',
                                'event'    : 'Remove from Cart11',
                                'ecommerce': __DL__.removeCart.items.map(function (line_item) {
                                    return {  
                                        'id'       : line_item.id,
                                        'sku'      : line_item.sku,
                                        'variant'  : line_item.variant_id,
                                        'name'     : line_item.title,
                                        'price'    : (line_item.price/100),
                                        'quantity' : line_item.quantity
                                 
                                    }
                                })

                            };
                            dataLayer.push(removeFromCart);
                            if (__DL__.debug) {
                                console.log("Cart removes "+" :"+JSON.stringify(removeFromCart, null, " "));
                            }
                        });


                   });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant