We have a little bit of php which calculation the cost per 100g for each sweet that we sell, mostly with a little help from Norman I might add.
here id the originasl code
(<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.175 ;
$unitcost = ($cost / $units) * 100; // do the arithmetic
printf(' %.1fp', $unitcost);
}
</actinic:block> per <actinic:variable name="Per_unit" /> )
This works perfectly but now we want to offer discounts when you buy over a certain number of each item, but I want to now show the cost per 100g for each price point.
I put the code into standard tax exclusive price and the code works but always brings up the price for the non discounted price band.
I tried replaceing
<actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" />
with
<actinic:variable name="PreFormattedPrice" value="Product Price Excluding Tax" />
but all I get is coding errors
here id the originasl code
(<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.175 ;
$unitcost = ($cost / $units) * 100; // do the arithmetic
printf(' %.1fp', $unitcost);
}
</actinic:block> per <actinic:variable name="Per_unit" /> )
I put the code into standard tax exclusive price and the code works but always brings up the price for the non discounted price band.
I tried replaceing
<actinic:variable encoding="perl" name="ProductPriceRaw" selectable="false" />
with
<actinic:variable name="PreFormattedPrice" value="Product Price Excluding Tax" />
but all I get is coding errors
Comment