Answer the question
In order to leave comments, you need to log in
How to remove all cart items on button click?
There is a component sale.basket.basket. Add a Delete Entire Cart button. I searched on the Internet and found this way:
in init.php add
if ($_POST["BasketDelete"] and CModule::IncludeModule("sale"))
{
CSaleBasket::DeleteAll(CSaleBasket::GetBasketUserID());
}
and add a button in the template
<input type="submit" value="Очистить корзину" name="BasketDelete">
Answer the question
In order to leave comments, you need to log in
after the basket form, I created another form with the post method, pushed the button there. Everything works as it should
Add after CSaleBasket::DeleteAll() the line LocalRedirect('reference to the basket');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question