Copied to clipboard

Flag this post as spam?

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


  • Anders Grahn 14 posts 94 karma points
    Apr 17, 2013 @ 10:05
    Anders Grahn
    0

    How do you set currency of an order in C#

    Hello

    I have a situation in version 1.4.4.2 where the customer can choose a specific paymenthod means the backend will have to react by setting the CurrentCurrency of the active order to a specific currency (and change back to default if another paymentmethod is selected). I have though so far been unable to find any setter for the currency of an order in C# (the one in javascript seems inapropriate due to this being a backend response).

    Is there any way to change the currency of an order from c# in version 1.4.4.2?

    Thanks in advance,

    Anders

  • Anders Burla 2560 posts 8256 karma points
    Apr 17, 2013 @ 17:15
    Anders Burla
    0

    You don't have the order.CurrencyId? Im looking at it in the source right now and its public :)

    Kind regards
    Anders

  • Anders Grahn 14 posts 94 karma points
    Apr 18, 2013 @ 09:15
    Anders Grahn
    0

    I do, but setting it like "order.CurrencyId = newId" seems to just change that number without any change to any of its other properties. Do I have to set each individual property in order.CurrentCurrency to the desired values or would TeaCommerce set the rest of the properties for me? (for some reason I expected the latter to be the case when setting the Id, and since it didn't happen I assumed I was doing it wrong) :)

    Thanks in advance

    Anders

  • Anders Burla 2560 posts 8256 karma points
    Apr 18, 2013 @ 15:56
    Anders Burla
    0

    What would you expect it to change. When you change the currency id - that is changed for the order. no other things change automatic.

    Kind regards
    Anders

  • Anders Grahn 14 posts 94 karma points
    Apr 18, 2013 @ 16:08
    Anders Grahn
    0

    Since no setter is available I expected changing the Id manually would fire an event within teacommerce, (since something similar happens when setting the sessioncontroller's currentorderid to 0) finding the currency with the Id in question and setting that object as the current currency after which it would fire the WebshopEvents.CurrencyChanged event where I handle my custom properties.

    The question remains though, while setting every property of the current currency manually is doable, how do I get TeaCommerce to do this with a its own logic?

    Best Regards

    Anders

  • Anders Burla 2560 posts 8256 karma points
    Apr 19, 2013 @ 09:36
    Anders Burla
    100

    Hi Anders

    Yeah in Tea Commerce 1.x the events are only called when you use the JavaScript or XSLT/Razor API - NOT the .NET API so that is why the event isnt invoked. In Tea Commerce 2.0 this is done the right way and the events are in the .NET layer.

    If you want to change the currency - use the SessionController to change it. It will change it for the current order and fire the events.

    Kind regards
    Anders

  • Anders Grahn 14 posts 94 karma points
    Apr 19, 2013 @ 09:41
    Anders Grahn
    0

    Cool, thank you very much :D

Please Sign in or register to post replies

Write your reply to:

Draft