You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have disabled the quantity for line item and added custom button to remove. How can I bind event to this custom button to remove line item from cart? Check my code below:
lineItem: {templates: {// Custom button templatecustomButton: '<div class="{{data.classes.lineItem.customButton}}" data-line-item-id="{{data.id}}" >Remove</div>',},contents: {quantity: false,customButton: true,},order: ['image',// Optional: include image'title','variantTitle','price','priceWithDiscounts','quantity','customButton',// Ensure custom button is in order],classes: {customButton: 'shopify-buy__cart-item-remove',},styles :{customButton: {'color': 'red','position': 'absolute','left': '80px','background': 'transparent','border': 'none','cursor': 'pointer',':hover': {'color': 'orange'}}},DOMEvents: {'click .shopify-buy__cart-item-remove': function(event,target){constlineItemId=target.getAttribute('data-line-item-id');// Fetch current checkout and remove the itemclient.checkout.fetch(checkoutId).then((checkout)=>{constlineItemsToRemove=[{id: lineItemId}];// Remove the line itemreturnclient.checkout.removeLineItems(checkout.id,lineItemsToRemove);}).then((checkout)=>{// Update the cart UI after removalui.updateComponent('cart',{checkoutId: checkout.id});}).catch((error)=>{console.error('Error removing line item:',error);});}},
The text was updated successfully, but these errors were encountered:
I have disabled the quantity for line item and added custom button to remove. How can I bind event to this custom button to remove line item from cart? Check my code below:
The text was updated successfully, but these errors were encountered: