cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

recalculate cart based on new currency

Former Member
0 Likes
274

Hi All,

I have a requirement , where user would be able to switch between currencies. can you please let me know how to recalculate cart & return response of Getcart in the new currency that's being switched

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

saood
Participant
0 Likes

I did the same as below:

 /**
      * Recalculates cart when currency has changed
      */
     protected void recalculateCart(final String currencyString) throws RecalculationException
     {
         if (getCartService().hasSessionCart())
         {
             final CartModel cart = getCartService().getSessionCart();
             if (cart != null)
             {
                 try
                 {
                     getCalculationService().recalculate(cart);
                 }
                 catch (final CalculationException e)
                 {
                     throw new RecalculationException(e, YSanitizer.sanitize(currencyString));
                 }
             }
         }
     }

After that get the session cart.