Announcement

Collapse
No announcement yet.

Format an expression as currency

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Format an expression as currency

    Hello, I am using miva templating language in a Miva page and I was wondering if some one can help me.

    I have the following code:
    Code:
    <mvt:eval expr="30 - g.basketsubtotal" /><
    This code works fine and it subtracts 30 from what the basket total is. The problem is, I want to take the result and format it as currency. I can't figure out how to make this work. Unfortunately Miva's documenation on their template stuff is broken and they haven't fixed it (http://www.miva.com/template-language/index.html).

    Does anyone know how I can format this correctly?

    Thanks

    #2
    Re: Format an expression as currency

    Not a true currency format but


    <mvt:assign name="g.your_variable" value="rnd(your_variable, 2)" />
    <mvt:assign name="g.your_variable" value="'$' $ padr(your_variable, 2, 0)" />


    should work
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      Re: Format an expression as currency

      That'll work. Thanks

      Comment


        #4
        Re: Format an expression as currency

        You can also use a module like toolkit/toolblet. They have built in currency format functions.

        http://apps.miva.com/product/WCW-TOOLKIT5.html

        However, very soon we will be releasing the next update to the Miva Engine (5.21) which allows you to call Native Merchant functions from the template language.

        This would look something like this:

        Code:
        <mvt:do name="l.formatted_output" file="g.module_store_module_currency" value="CurrencyModule_AddFormatting( g.module_store_module_currency, l.order:total )" />
        <mvt:eval expr="l.formatted_output" />
        Where l.order:total is the un-formatted number and l.formatted_output is formatted version.
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #5
          Re: Format an expression as currency

          Thanks Brennan. Can you tell me, is this the correct documentation for miva template language - http://www.miva.com/template-language/index.html

          If so, half of the pages don't load. They just sit there with the green bar loading. Take this one for example - http://www.miva.com/template-languag...variables.html

          Comment


            #6
            Re: Format an expression as currency

            In the meantime using Toolbelt will provide the correct formatting even if the currency is not U.S. currency format.
            Code:
            <mvt:item name="ry_toolbelt" param="currencyformat|g.basketsubtotal_F|30 - g.basketsubtotal" />
            &mvt:global:basketsubtotal_F;


            Ray Yates
            "If I have seen further, it is by standing on the shoulders of giants."
            --- Sir Isaac Newton

            Comment

            Working...
            X