remove all items from cart in prestashop 1.7
<a class="btn btn-primary" style="float:right" id="removeAll" href="javascript:void(0)"> Empty Cart</a>
in js file
$(document).ready(function() {
if(prestashop.page.page_name == ‘cart’)
{
$(‘#removeAll’).click(function(e) {
e.preventDefault()
$.ajax({
type: ‘POST’,
headers: { “cache-control”: “no-cache” },
url: prestashop.urls.base_url + “cart”,
async: true,
cache: false,
data: ‘deleteAll=1&token=’ + prestashop.token + ‘&ajax=true’,
success: function(data){
window.location.reload();
}
})
});
}
{
$(‘#removeAll’).click(function(e) {
e.preventDefault()
$.ajax({
type: ‘POST’,
headers: { “cache-control”: “no-cache” },
url: prestashop.urls.base_url + “cart”,
async: true,
cache: false,
data: ‘deleteAll=1&token=’ + prestashop.token + ‘&ajax=true’,
success: function(data){
window.location.reload();
}
})
});
}
});
In cart controller.php
find and add after this >>
elseif (Tools::getIsset('delete')) { elseif (Tools::getIsset('deleteAll')) { $this->context->cart->delete(); $this->context->cookie->id_cart = 0; die(1);}
Comments
Post a Comment