+ Start a Discussion

How to refresh shopping cart on page reload?

Shopping cart is not getting refresh on page reload.

i have written one custom fucntionality on shopping cart on storefront where i have added the one clear cart button on shopping cart.

Vf component:
<button class="btn btn-default btn-sm" id="DeleteAll" name="" type="button" onclick="deleteall(event);">{{pageLabelMap 'CartInc_DeleteAll'}}</button>

function deleteall(e){
        var cart_id =  CCRZ.cartDetailModel.attributes.sfid;
        // var cart_id = CCRZ.pagevars.currentCartID;
        var Eff_account_ID = CCRZ.pagevars.queryParams.effectiveAccount;
       if(cart_id != undefined){
        console.log("i am in if loop");
        var remoteCall = _.extend(CCRZ.RemoteInvocation, { className: 'FIL_FGP_ProductListCtrl' });
            'clearCart',cart_id , Eff_account_ID,
                    console.log("clearCart remote action called successfully");
                    //do something with the response
                    CCRZ.pubSub.trigger('pageMessage', { messages: [{ type: 'CUSTOM', severity: 'ERROR', message:'You have no items in the Cart', classToAppend: 'messagingSection-Error'}] });
                    console.log("clearCart remote action called, but something went wrong");
                buffer:false, //this call will be executed by itself
                nmsp : false //defines that this is a call to a subscriber class
        console.log("do nothing");

Controller :
    global static ccrz.cc_RemoteActionResult clearCart( final ccrz.cc_RemoteActionContext ctx, String cart_id , string Ef_Account_ID){
        ccrz.cc_RemoteActionResult res = ccrz.cc_CallContext.init(ctx);

        List<ccrz__E_CartItem__c> item=[Select Id, Name, ccrz__Cart__c, ccrz__CartItemId__c, ccrz__ItemLabel__c, ccrz__Product__c FROM ccrz__E_CartItem__c WHERE ccrz__Cart__c = :cart_id];
        if(item.size()> 0){
            delete item;
            res.success = true;
            system.debug('Empty Cart');
           res.success = false; 
        return res;

The remote is going sucessfully and the cart items are getting deleted from the object at backend side .but on page reload the cart is not getting refreshed .It shows the previous quantity.

Thanks & Regards,
Suraj Bahale
richardscarry scarryrichardscarry scarry
QuickBooks is an excellent technical suite of features essential for accounting. Dial QuickBooks Helpline Number @ + 1-888-744-6OO5 if the user seeks elaborated knowledge of the software. The functioning advantages of this software are endless. Since the primary aim behind this invention was to simplify complex calculations and other tasks involved in the management of various businesses. Read more: QuickBooks Helpline Number 
QuickBooks Helpline Number 
QuickBooks Helpline Number 
QuickBooks Helpline Number