cancel
Showing results for 
Search instead for 
Did you mean: 

Update Promotion and recalculate the cart.

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member537989
Contributor
0 Kudos

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.