Answer the question
In order to leave comments, you need to log in
How to empty OpenCart 2 cart with one click?
Implemented product registration in opencart bypassing the standard one. 3 fields are displayed on the cart page, filled in and the data is sent to email. Then everything returns to the main page, a window pops up that everything is fine. But the basket remained uncleaned. It is necessary that at some stage a request was sent to empty the basket. Opencart Version 2.1.0.1 (rs.2).
Answer the question
In order to leave comments, you need to log in
in catalog/view/javascript/common.js, the cart object has a remove method, you can pass the ID of the product in the cart there, after which it will delete.
If the page does not display the product ID, then it will be necessary to add its output to the template in the page controller.
If it outputs, then at the very end of your script (when everything is OK) add something like this:
$('.cardProduct').each( function () {
var cartID = $(this).attr('prodID');
cart.remove(cartID);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question