Good morning,
I developed a feature for my Shopping bag to give a gift if a customer buys a certain amount. If the customer removes a product from the card after receiving the gift, a new validation is made to check if the value of the card is below or above the spefified value to receive the gift or not. The functionality is ok, but the product given as a gift remains in the Shopping bag and Cart, disappearing only if I upload the page. The functionality itself works perfectly, only the case of updating the displayed products is not ok.
If the customer wishes to checkout, the product is removed (or kept if applicable) as the screen ends up being reloaded to the checkout page, but I would like to have it removed from the cart(visually) at the time of the product being added or removed from the cart (according to the validation of the rule I defined to receive the gift or not).
In the example of the attached image, the gift is given if the purchase reaches a minimum of 3000, as shown. However if I remove one of the products, getting 1500 only in the cart, the gift is removed in the background but it remains in the dropdown menu displayed. If I go to the checkout page or update the page it disappears and only the 1500 product remains.
I know there is a ‘location.reload()’ function that would reload when the product is removed, but I would like to know if there is any other way. I tried using ‘addToCartHandler.updateGeneralInfo(cart);’ but I believe this function is not called when the removal of one of the items on the cart is done.
If you know of any other solution I will be very grateful.
Thanks
