Skip to content

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

@adventuretocode

Description

@adventuretocode

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, " "));
                            }
                        });


                   });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions