Announcement

Collapse
No announcement yet.

Displaying discounted price to 2 decimal place

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

    Displaying discounted price to 2 decimal place

    Hi guys,

    I struggled the the title for this sorry, the code below (asuming I've cut the right part) displays the following:

    RRP: £215 Our Price: £172 Inc. VAT
    You Save 20% while offer lasts!

    £172.00 (Including VAT at 20%)


    but will only ever display 1 figure after the decimal point, could someone tell me why?

    Thanks guys


    <actinic:block php="true" >

    $rrp = <actinic:variable name="RRP" selectable="false" />;

    $rawprice = (((<actinic:variable name="ProductPriceRaw" selectable="false" />) /100)* 120);

    {

    $saving = ((($rrp - $rawprice) / $rrp) * 100);

    echo "Our Price: £";

    echo round(((("<actinic:variable name="ProductPriceRaw" selectable="false" />")/100) * 120) ,2);

    echo " Inc. VAT";

    echo "<br />You Save ".number_format($saving,0)."% while offer lasts!";

    }

    </actinic:block>

    #2
    Sorry, I don't understand.

    Which bit of the display do you want to change? The only decimal point I can see in the displayed example is in the £172.00 and that has two figures after the dp.

    Mike
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    Comment


      #3
      Sorry, poor example

      See here

      Comment


        #4
        Instead of
        echo round(((("<actinic:variable name="ProductPriceRaw" selectable="false" />")/100) * 120) ,2);
        why not just use this:
        echo round($rawprice ,2);

        Comment


          #5
          If it's still the same with the above change then maybe it's because round(127.2,2) is 127.2 and not 127.20 as expected whereas round(127.21,2) would be 127.21. You can check this quite easily in the code.

          Comment


            #6
            You need to use number_format rather than round.

            Round will just round up to the required number of places but you haven't told it to display (rather than just round) the second dp figure of 0.

            Just replace 'round' with 'number_format' and you should be OK.

            i.e.

            echo number_format($rawprice ,2);


            Mike
            -----------------------------------------

            First Tackle - Fly Fishing and Game Angling

            -----------------------------------------

            Comment


              #7
              Stupendous, that's done the trick, cheers Mike!

              Comment


                #8
                In addtion to this $rrp value

                Hi everyone,

                I implemented this RRP saving for a client and they mentioned that when they type the rrp value in, if there is a zero then is gets removed eg. £65.50 is displayed as £65.5 or £55.00 becomes £55. Does anyone know how the $rrp value can display the additonal zeros?

                Cheers.
                Lee.
                Regards.

                Lee Jackson
                Creative Director

                Centurius Design & Marketing
                Centurius Website
                Portfolio of Work

                Comment


                  #9
                  Umm. read the post 2 places above your own?

                  Mike

                  OK. For clarity, that displays the 'our price' to 2 DP but you just have to do the same for $rrp.
                  -----------------------------------------

                  First Tackle - Fly Fishing and Game Angling

                  -----------------------------------------

                  Comment


                    #10
                    Mike,
                    Its been one of those days I'm afraid.... =( Thanks for pointing the obvious.
                    Regards.

                    Lee Jackson
                    Creative Director

                    Centurius Design & Marketing
                    Centurius Website
                    Portfolio of Work

                    Comment

                    Working...
                    X