Cart Refresh

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi All

I am after a little help please. I have added line in the ShoppingCartController to add or remove a discount coupon when someone clicks on a checkout attribute. This works exactly as i hoped, however the cart needs to be refreshed before the prices will reflect the discount coupon rules. Is there a way i can trigger the "Update Cart" button from this controller, or alternatively just refresh the page.

My code looks as follows:

if (conditionMet.HasValue)
                {
                    if (conditionMet.Value)
                    {
                        enabledAttributeIds.Add(attribute.Id);
                        _customerService.ApplyDiscountCouponCode(_workContext.CurrentCustomer, "MEMBER");
                    }

                    else
                    {
                        disabledAttributeIds.Add(attribute.Id);
                        _customerService.RemoveDiscountCouponCode(_workContext.CurrentCustomer, "MEMBER");
                    }
                    
                }

Any help would be greatly appreciated.
4 years ago
If the action method is not triggered via AJAX request then you can simply redirect this action to the "ShoppingCart" route which will reload the cart page.
You can use this
return RedirectToRoute("ShoppingCart");

or use this if your method is in ShoppingCartController
return RedirectToAction("ShoppingCart");
4 years ago
Thanks for your help
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.