I am currently trying to empty the whole cart in mangento 1.9 while clicking an item. The code is in the list.phtml from my template.
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="POST" name="emptyTheCart">
<?php echo $this->getBlockHtml('formkey'); ?>
<button type="submit" name="update_cart_action" value="empty_cart" style="display:none" title="<?php echo $this->__('Empty Cart'); ?>" id="empty_cart_button"></button>
</form>
$('.item').click(function() {
var dataExecURL = "<?php echo $this->getUrl('checkout/cart/updatePost') ?>";
var datafiles=$("#emptyTheCart").serialize();
$.ajax({
type : 'POST',
data : datafiles,
url : dataExecURL
});
});
when i click on an item, it should empty my cart. Can someone please help? I do not have any clues why this is not working at all.