Skip to content

Deleted by the user Autoadded Product #85

Discussion options

You must be logged in to vote

Hi @elektro-hub
Yes, you can subscribe to the liquid-ajax-cart:request-end event, check if the autoadded item has been just removed removed using the cart property of the event and add cookie or a localStorage value to the user that will indicate that they don't wanna have the autoadded item:

// Subscribe to 
document.addEventListener("liquid-ajax-cart:request-end", function(event) {
  const {cart, requestState} = event.detail;

  // Variant Id of the autoadded product
  const variantId = 40934235668668 

  // Has autoadded product been just removed
  const isAutoAddedItemRemoved = cart.items_removed?.find(item => item.variant_id === variantId);
  if (!isAutoAddedItemRemoved) {
    return f…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@elektro-hub
Comment options

Answer selected by elektro-hub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants