Announcement

Collapse
No announcement yet.

Unformatted Price

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

    Unformatted Price

    We want to show pricing on the product page as: $68 (without any cents as they are all zeros). This works fine using $&mvt:product:price; for most products. However, we have a product that has to use inventory variants so that we can show a different image for each variant. When a variant is selected. the visible price changes from '$68' to '$68.00'. How could this be altered to keep the format of '68'?

    #2
    I figured this out - I had to simply select "Variant Price is set by the Master Product and its Attributes" when generating the variants.

    Comment


      #3
      So another problem we ran into is we have some products that are $4.20. So using '$&mvt:product:price;' drops the zero showing it as '$4.2'. Is there a way to have no cents show as $68 without any zeors, but $4.20 show with the zero?

      Comment


        #4
        You might try using a conditional to check for the decimal point and, if present, pad two places to the right.
        Matt Zimmermann

        Miva Web Developer
        Alchemy Web Development
        https://www.alchemywebdev.com
        Site Development - Maintenance - Consultation

        Miva Certified Developer
        Miva Professional Developer

        https://www.dev4web.net | Twitter

        Comment


          #5
          I did a quick search for some documenation on doing the decimal points but couldn't find anything off the bat. Do you have any examples or places I can check?

          Comment


            #6
            Since you're dealing with variants, you'll probably have to use JavaScript to make this happen. You would want to use "includes()" [ https://developer.mozilla.org/en-US/...tring/includes ] to check for the decimal and then "padEnd()" [ https://developer.mozilla.org/en-US/.../String/padEnd ] to add the trailing zero, if needed.
            Matt Zimmermann

            Miva Web Developer
            Alchemy Web Development
            https://www.alchemywebdev.com
            Site Development - Maintenance - Consultation

            Miva Certified Developer
            Miva Professional Developer

            https://www.dev4web.net | Twitter

            Comment

            Working...
            X