Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arun 141 posts 394 karma points
    Feb 23, 2021 @ 14:24
    Arun
    0

    How can i switch between countries in Tea commerce?

    Hi
    I was working on a project with multiple cultures and countries, When I tried to switch culture from da-DK to en-US all the Prices, Currencies, and VAT of the cart items must be changed from DKK to USD which is set in the backend.
    But I can see that all of the properties didn't switch properly. I can see the VAT rate changed from 25,00% (of da-DK) to 20.00% (en-US) but is displaying in a danish culture 20,00
    Could you please help?

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Feb 23, 2021 @ 14:27
    Matt Brailsford
    0

    Hey Arun,

    Can you share what code you are currently using to "switch the culture"? I should be able to suggest something once I know what you are currently doing.

    Matt

  • Arun 141 posts 394 karma points
    Feb 25, 2021 @ 14:27
    Arun
    0

    I'm not sure. Can you please share which are codes used in Tea Commerce to switch currency and culture?

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Feb 25, 2021 @ 14:35
    Matt Brailsford
    0

    To set the current sessions currency you would use

    TC.SetCurrentCurrency(storeId, currencyId);
    

    See https://docs.teacommerce.net/3.4.0/api/currency/#getcurrentcurrency for more details.

    We don't control the session culture change, hence why I asked what code you were using so I could suggest how to integrate the code above.

    Matt

  • Arun 141 posts 394 karma points
    Feb 25, 2021 @ 14:37
    Arun
    0

    Do this code affect culture for items in the order?

    order.ChangePaymentRegion(country.Id, null); order.ChangeShippingRegion(country.Id, null);
    order.Save();

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Feb 25, 2021 @ 14:51
    Matt Brailsford
    0

    Hi Arun,

    No, those are essentially setting the billing / shipping address regions of your order. They have no effect on the order culture.

    You can change an individual orders currency by calling

    order.ChangeCurrency(currencyId);
    

    I believe this should then force the prices to recalculate when the order is saved.

    PS TC.SetCurrentCurrency(storeId, currencyId); will call order.ChangeCurrency(currencyId) under the hood. The difference is, TC.SetCurrentCurrency will set the current session currency, so any new orders created will automatically be in that currency from that moment on, where as order.ChangeCurrency only changes the currency of that one order with the currency sessions default currency being unchanged.

Please Sign in or register to post replies

Write your reply to:

Draft