Announcement

Collapse
No announcement yet.

Math with variables

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

    #16
    Thanks so much for that norman, that will carve hours of work out. It works fantastically. Well Done, also, ill be in touch in the next few days re your lightbox addon. Many thanks again,

    Matt
    http://www.itwiz.co.uk

    http://www.AntiV.net - The Discount Antivirus Store

    Comment


      #17
      Originally posted by NormanRouxel
      Something like (NB untested)
      Code:
      <actinic:block php="true">
      $rrp = <actinic:variable name="RRP" selectable="false" />;
      $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
      $rawprice = $rawprice * 1.175;  // add in vat if showing VAT inc prices
      // only display is we have an RRP and there's a saving to show
      if ( ($rrp != 0) && ($rrp > $rawprice) )
        {
        $savepercent = round((($rrp - $rawprice) / $rrp) * 100);
        echo "RRP £$rrp - you save $savepercent%";
        }
      </actinic:block>
      You won't need the YouSave variable any more. It's calulated for you.
      I just gave this a try and ity works like a charm, EG: We sell an item for £4.75 and the RRP of the item is £4.99 once i add the variable and php code i get:

      RRP £4.99 - you save 5%

      Is it possible to tweak this code and show the amount of money saved as well something like:

      RRP £4.99 | You Save £0.24 (5%)

      Comment


        #18
        I think you would just change
        {
        $savepercent = round((($rrp - $rawprice) / $rrp) * 100);
        echo "RRP £$rrp - you save $savepercent%";
        }
        TO

        {
        $amountsaved = round($rrp - $rawprice);
        $savepercent = round((($rrp - $rawprice) / $rrp) * 100);
        echo "RRP £$rrp - you save £$amountsaved ($savepercent%)";
        }
        gotta love php!
        Last edited by mattc; 02-Apr-2008, 05:16 PM. Reason: needed ;
        http://www.itwiz.co.uk

        http://www.AntiV.net - The Discount Antivirus Store

        Comment


          #19
          Also nice to add
          <strike> £$rrp</strike>
          http://www.itwiz.co.uk

          http://www.AntiV.net - The Discount Antivirus Store

          Comment


            #20
            That also works a treat almost but it rounds everything up so on an item with an RRP of £15 and we are selling it for £9.99 it shows the saving as £5 not £5.01.

            Any ideas of any required tweaks to show the pence?

            Comment


              #21
              Try

              $amountsaved = number_format ($rrp - $rawprice, 2);

              If that's not what you want, the PHP documentation is at http://uk2.php.net/manual/en/ - look at number_format and you'll see the "See also: money_format(), sprintf(), printf() and sscanf()".
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #22
                works a charm Norman thank you very much. If i was chatting on MSN with you i would send you one of the big red lip kiss wink things but were not so a xxx will have to surfice

                Comment


                  #23
                  Just posted a hint about selectable="false" in another topic. You can specify it at block level rather for each variable enclosed by the block. Although it is not documented and anot available on the UI you can add it to the block tag in advanced view.

                  Just thinking a bit more on this actually it would make sense to set it as the default behaviour of the PHP blocks. Hmmm...
                  Zoltan
                  Actinic Software
                  www.actinic.co.uk

                  Comment


                    #24
                    Surely this must warrant an entry in the AUG....

                    Comment


                      #25
                      Originally posted by Ginnys Attic
                      If i was chatting on MSN with you i would send you one of the big red lip kiss wink things but were not so a xxx will have to surfice
                      LOL
                      That made me chuckle on a dull morning
                      Tracey

                      Comment


                        #26
                        This is indeed top stuff. I'll get it added to the Advanced User Guide.

                        Comment


                          #27
                          Ease up Tiger, I've found a slight issue with this today. If you have a product for example which is set to sell for £1.15 when Actinic adds the VAT it shows the price as £1.36 and if the retail price of this product was £1.45 the php calculates the sell price as being £1.35 and displays the saving as being 10p not 9p so Actinic and PHP are not in sync when it comes to the VAT amount.

                          The only thing i can think is to use the Actinic sell price (£1.36) instead of the rawprice and PHP calculating the VAT. I've had a look at different variables but so far i've not been able to get anything to work so hopefully Norman might be able to assist a little further before anything gets added to the AUG.

                          Comment


                            #28
                            It will be rounding issue i expect as you have to use productpriceraw, but actinic v8 and below do not always calculate correctly.

                            Before being added to the AUG, it will also need to start taking the vat rate on the product, not a global amount as some products have differing amounts.

                            It's a great start to something very good, but it certainly is not AUG ready yet. If actinic can get their heads banged together and provide the RRP field as standard or let you choose or use the cost price field, that will be even better in V9.

                            Question: Where did actinic get the idea that Cost Price was wanted but RRP never got in? That has to have been one of the most blindfolded decisions ever surely?

                            Comment


                              #29
                              This sounds like you might have your VAT settings in actinic wrong.

                              They should be 'round item scientific'. i.e. rounded per item to the nearest value.

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

                              First Tackle - Fly Fishing and Game Angling

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

                              Comment


                                #30
                                Originally posted by olderscot
                                This sounds like you might have your VAT settings in actinic wrong.

                                They should be 'round item scientific'. i.e. rounded per item to the nearest value.

                                Mike
                                I'm using Version 9 but VAT was set to round up so i have changed that to standard now and that as far as i can see seems to calculate the You Save amount correctly.

                                In another thread from the v9 beta Chris did mention that we might possibly get an additional field actually in Actinic V9 for the product RRP instead of having a custom variable which would make life 2500 product entires easier as we could import the data and maintain the pricing with ease from simple spread sheets which could calculate the sale price on a margin or discount from RRP or whatever formula we require but so far it's not appeared.

                                I would think it would be far easier to calculate the difference and % between the RRP and actual site price if this was added to Actinic. Is there any hope or sign of this appearing in the next maintenance release Chris?

                                Comment

                                Working...
                                X