Jump to content

Ajax-cart remove function


Recommended Posts



I have a customization field on my product page, and I've managed to edit the add function of the ajax-cart.js file, and the Cart class, for it to be added on the database in the cart_product table, in a custom field.


I've also managed that when we personnalise the product again, and add it to the cart again, the code also checks my custom field, to have 2 lines of the same product on the cart, but with different custom codes.


What I'm not able to do, is to delete a product when there is the same product with a different custom code in the cart, both the products gets deleted.


I've tried to do like for the add function, I've added my custom field in the products's "data-id" in the cart page, which allows me to get that custom field in the ajax-cart.js file, like follows :

if (!customizationId)
//retrieve idProduct and idCombination from the displayed product in the block cart
var firstCut = $(this).parent().parent().data('id').replace('cart_block_product_', '');
firstCut = firstCut.replace('deleteCustomizableProduct_', '');
ids = firstCut.split('_');
productId = parseInt(ids[0]);

if (typeof(ids[1]) != 'undefined')
productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined')
idAddressDelivery = parseInt(ids[2]);

ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery, MYCUSTOMCODE);

Then, in the remove function in that same file, I do :

remove : function(idProduct, idCombination, customizationId, idAddressDelivery, MYCUSTOMCODE){
data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&MYCUSTOMCODE=' + MYCUSTOMCODE + '&token=' + static_token + '&ajax=true',

But I don't know what to do next. I've tried the forums, and everything that passed through my mind with the Cart class, and the cart controller, but with no success :(


That's why I'm coming to you, hoping you'll be able to help me.

Hoping that I made everyhting clear.


Thanks in advance !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...