Announcement

Collapse
No announcement yet.

format Productpriceraw variable

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

    format Productpriceraw variable

    SOLVED - see below

    Hi folks,

    I'm using ProductPriceRaw to return the price of a product for various things. However, the price returned misses off any training 0's e.g. 3.50 become 3.5, 100.00 is 100 etc

    Whats the best way to return the following:

    £3.50

    rather than just 3.5??

    i'm assuming PHP, but i'm unable to do what I need to.

    on a product, with price £3.50

    <actinic:block php="true" >
    $var = "<actinic:variable name="ProductPriceRaw" />";
    echo $var;
    </actinic:block>

    this returns 3.5

    fine.

    now, with PHP I thought that variables were of a type depending on what you do with them...

    so,

    <actinic:block php="true" >
    $var = "<actinic:variable name="ProductPriceRaw" />";
    $num = number_format($var, 2, '.', '');
    echo $num;
    </actinic:block>

    I assumed would return 3.50 as well, but it returns 0.00

    I can't seem to get ProductPriceRaw out as a number - can someone shed any light on my inability as a PHP programmer please!!

    also note, this is a return string for pinterest.com and it seems that pinterest is reading 3.5 as 3 because if you dont have 2 decimals, it truncates the value....

    Thanks

    -------------------------------
    SOLVED: used this:


    <actinic:block php="true" >
    echo "£" . number_format((<actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" />), 2);
    </actinic:block>

    and it worked.
    the important bit is setting the Selectable=false bit

    from here:
    http://community.actinic.com/archive...p/t-46620.html
    Last edited by Andy Warner; 14-Feb-2012, 05:17 PM. Reason: added the answer
    Andy Warner

    www.legendgames.co.uk - rpgs, boardgames, dice and other geeky stuff
    www.RPGMiniatures.com D&D and Star Wars Miniatures

    Both running the Cart from Search Page hack

    Also www.mainlymurder.co.uk www.thegamesplace.co.uk and www.thediceplace.co.uk

    All running V8.5.2 Multisite on a windows 7 quad PC, augmented by Mole End automation, from a single shared database, using actinic specific hosting from Host-IT.

    #2
    ProductPriceRaw is a number but you're making it a string. Try:
    Code:
    <actinic:block php="true" >
      $var = <actinic:variable name="ProductPriceRaw" selectable="false" />;
      $num = number_format($var, 2, '.', '');
      echo $num;
    </actinic:block>
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      I just found that a nano second before you posted - thanks though.

      in fact, looking at this, the 'standard' settings, under edit appearance, are

      Encoding = NONE
      Condition = TRUE
      Selectable = TRUE

      It looks like the Selectable = FALSE is the only one that needs to be set here.
      Andy Warner

      www.legendgames.co.uk - rpgs, boardgames, dice and other geeky stuff
      www.RPGMiniatures.com D&D and Star Wars Miniatures

      Both running the Cart from Search Page hack

      Also www.mainlymurder.co.uk www.thegamesplace.co.uk and www.thediceplace.co.uk

      All running V8.5.2 Multisite on a windows 7 quad PC, augmented by Mole End automation, from a single shared database, using actinic specific hosting from Host-IT.

      Comment

      Working...
      X