Skip to Content
author's profile photo Former Member
Former Member

Update Promotion and recalculate the cart.

Hello All, I create a new promotion restriction. It depends on payment type. When user change the payment type the promotion is updated and the cart is recalculated. Everything works ok. I add a peace of code in the changemethod of payment.

         final PromotionGroupModel group = ebebekPromotionService.getDefaultPromotionGroup();
         promotionservive.updatePromotions(Collections.singletonList(group), sessionCart, true, AutoApplyMode.APPLY_ALL,
                 AutoApplyMode.KEEP_APPLIED, Helper.getDateNowRoundedToMinute());
         getCustomCheckoutFacade().recalculateCart();

It works ok, but sometimes an error appears like;; [de.hybris.platform.promotions.jalo.PromotionsManager] Failed to updatePromotions item 8978427548565 no longer valid (was removed): object no longer valid at de.hybris.platform.jalo.Item$CachedGetter.get(Item.java:680)

I checked with pkanalyzer what is the type of item that couldnt be found; it is type of AbstractPromotionAction.

I thought that there is something that i missed in updatepromotions and recalculate process. What is the best way to update promotions and recalculate cart totals.

Also, getCustomCheckoutFacade().recalculateCart(); this line of code doesnt effect the cart totals, i need to reflesh the page to make the cart is updated in the fronent. Is there anyway to update the cart in the storefront without refleshing the page.

I hope that my question is clear.

Regards, Adem

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on May 02, 2016 at 03:53 PM

    I dont know what your custom getCustomCheckoutFacade().recalculateCart() is doing, however the important point is to ensure that your custom code uses de.hybris.platform.commerceservices.order.CommerceCartCalculationStrategy which does:

    • cart calculation

    • updates promotions.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.