Copied to clipboard

Flag this post as spam?

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


  • Ben Palmer 180 posts 866 karma points c-trib
    Jul 03, 2020 @ 10:54
    Ben Palmer
    0

    Getting Price from Order with Currency

    Hi,

    Currently trying to get the total price of an order with symbol. I've got the OrderReadOnly model using the order service which has the total price but just as a decimal.

    I'm currently hardcoding this:

    target.Cost = "£" + source.TotalPrice.Value.WithTax;
    

    Now, obviously there is a better way than this abomination so what's the easiest way to get the total price but with currency symbol?

    Thanks,

    Ben

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jul 03, 2020 @ 11:06
    Matt Brailsford
    100

    Hey Ben,

    You can use the Formatted() extension on TotalPrice.Value to convert it into it's formatted form.

    target.Cost = source.TotalPrice.Value.Formatted().WithTax;
    

    This will return the price values formatted for its relevant currency.

    You'll need to make sure you have a using Vendr.Core statement to have access to the formatted extension method.

    Hope this helps

    /Matt

  • Ben Palmer 180 posts 866 karma points c-trib
    Jul 03, 2020 @ 11:24
    Ben Palmer
    0

    Ah, using Vendr.Core was indeed what I was missing there, works a charm. I knew you'd have this covered!

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jul 03, 2020 @ 11:28
    Matt Brailsford
    1

    Excellent 😁

    Yea, I'd recommend always having that using statement when using the Vendr API as there are a few things that are available via extension methods that all become available when you have that added.

    Glad we got it working 👍

    /Matt

  • Richard Ockerby 35 posts 210 karma points MVP 4x c-trib
    Apr 28, 2022 @ 21:45
    Richard Ockerby
    1

    In more recent versions of Vendr, this extension is found using Vendr.Extensions

Please Sign in or register to post replies

Write your reply to:

Draft