N
N
Nikita Peterson2017-03-14 16:54:52
PHP
Nikita Peterson, 2017-03-14 16:54:52

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

2 answer(s)
V
Vitaly, 2017-03-14
@Designik_by

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);
});

* i.e. At me here in attribute the product ID is deduced. Then I look for it on the page and pass it to the remove method in a loop

O
opencart-russia, 2017-03-15
@opencart-russia

forum.opencart-russia.ru/threads/ochistit-korzinu-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question