Jump to content

Live Update Cart in Shopping Cart


Recommended Posts

Hello!

 

I almost finished my first own module, but I got stuck. With my module the customers can buy extra insurances one by one to products only in shopping cart. If a product has at least 1 insurance, it shows under the row of product. It is working fine, I can add or remove insurances perfectly.

 

My problem is, I can not update the shopping cart via ajax cart. The block cart is refreshing properly, but the normal cart do not.

 

"Add Insurance" button:

<a rel="{$insurance['id_product']}" class="cart_quantity_up btn btn-info addInsurance" data-id="{$insurance['id_product']}" data-product-id="{$product['id_product']}" id="cart_quantity_up_{$insurance['id_product']}_0_0_0" href="/cart?add=1&id_product={$insurance['id_product']}&ipa=0&id_address_delivery=0&token={$static_token}" title="{$insurance['name']}">Add Insurance</a>

My custom javascript:

$(function() {
    $(document).on('click', 'a.addInsurance', function() {
        //Remove "Add Insurance" row
        var productID = $(this).data('id');
        var insuranceID = $(this).data('id-product');
        var row = $('#product_' + productID + '_insurance_' + insuranceID);
        row.remove();
        //Refresh cart
        ajaxCart.refresh(); //not working
    });
});

I could not find any solution in ajax-cart.js, but I hope it is my mistake. :)

 

Is there any built-in solution, or should I implement by myself the cart refreshing method?

 

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...