I'm using the below code to display RRP and show the saving % if there is one:
My RRP variable is empty unless i add something into it. On products where i have not added a value, the above code fails. I understand why because of this condition:
My RRP has no value in it and is not equal to 0. I cannot retrospectively change the variable to have 0 as the default value as it's a long standing variable with over 900 entries across products. So i need to get the code to also evaluate when the variable is empty. This is where i have been going round in circles, nothing seems to work.
My logic has so far been:
if ($rrp == '') then $rrp = 0 - to assign 0 value if it is empty. This did not work.
i also tried adding in a third option into this, like so:
That didn't work either, i then tried what was seemingly every other version of those ideas, to no avail.
I SUCK AT PHP!
Code:
<actinic:block php="true" > $rrp = number_format(<actinic:variable name="RRP" selectable="false" />,2); $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />; // display if there's a saving to show if ( ($rrp != 0) && ($rrp > $rawprice) ) { $savepercent = round((($rrp - $rawprice) / $rrp) * 100); echo "<h3 class=\"rrp_price\">"; echo "RRP: £$rrp <span class=\"percent\">(SAVING YOU $savepercent%)</span>"; echo "</h3>"; } </actinic:block>
Code:
if ( ($rrp != 0) && ($rrp > $rawprice) )
My logic has so far been:
if ($rrp == '') then $rrp = 0 - to assign 0 value if it is empty. This did not work.
i also tried adding in a third option into this, like so:
Code:
if ( ($rrp != 0) && ($rrp == '') && ($rrp > $rawprice) )
I SUCK AT PHP!
Comment