we use a php code to calculate the cost per item on our site
<actinic:block php="true" >
$units = '<actinic:variable encoding="perl" name="CUST_UNITS_PER_OUTER" selectable="false" />'; // load as string in case variable empty
if ( $units != '' )
{
$cost = '<actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" />'; // load as string in case variable empty
$cost = preg_replace('/£|,/', '', $cost); // remove any £ and ,
$costinc = $cost * 1.15 ;
$unitcost = ($cost / $units) * 100; // do the arithmetic
printf(' %.1fp', $unitcost);
}
</actinic:block>
the problem is we need to make the script a bit more complex
we need 2 results to be displayed
if final price is 99p or less we need the script to work as is showing for example 69.2p
(We currently put the p in after the calculation has been done)
if the price is 100p or more we need the price to be displayed in £ i.e £1.59
My php skills is not that good and I would appreciate a point in the right direction.
<actinic:block php="true" >
$units = '<actinic:variable encoding="perl" name="CUST_UNITS_PER_OUTER" selectable="false" />'; // load as string in case variable empty
if ( $units != '' )
{
$cost = '<actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" />'; // load as string in case variable empty
$cost = preg_replace('/£|,/', '', $cost); // remove any £ and ,
$costinc = $cost * 1.15 ;
$unitcost = ($cost / $units) * 100; // do the arithmetic
printf(' %.1fp', $unitcost);
}
</actinic:block>
the problem is we need to make the script a bit more complex
we need 2 results to be displayed
if final price is 99p or less we need the script to work as is showing for example 69.2p
(We currently put the p in after the calculation has been done)
if the price is 100p or more we need the price to be displayed in £ i.e £1.59
My php skills is not that good and I would appreciate a point in the right direction.
Comment