Hi All
I'm trying to display a trade discount to logged in customers. I've added the following code to the product layout to show, for example:
RRP (Ex) £17.5 - RRP (Inc) £21.00 - TRADE (ex) £11.38 - % off RRP = 35%
under each product. The page is set out as a product list with single add to cart button.
It seems to be working apart from calculating the "% off RRP".
As it's the logged in customer price I am using in the calculation, I have used javascript to work out the discount. The only way I know to get to the customer price is to use <td id="trade"> in the cell containing <actinic:variable name="PriceListRetail" /> in the product layout. But this only picks up the value from the first product in the list and displays the same discount for all the products listed.
Any help would be much appreciated.
Thank
Lee
I'm trying to display a trade discount to logged in customers. I've added the following code to the product layout to show, for example:
RRP (Ex) £17.5 - RRP (Inc) £21.00 - TRADE (ex) £11.38 - % off RRP = 35%
under each product. The page is set out as a product list with single add to cart button.
It seems to be working apart from calculating the "% off RRP".
As it's the logged in customer price I am using in the calculation, I have used javascript to work out the discount. The only way I know to get to the customer price is to use <td id="trade"> in the cell containing <actinic:variable name="PriceListRetail" /> in the product layout. But this only picks up the value from the first product in the list and displays the same discount for all the products listed.
Any help would be much appreciated.
Thank
Lee
Code:
<table width="100%" cellspacing="0" cellpadding="1" style="border-top:dotted 1px #003399;"> <tr> <td width="13%" align="left" valign="middle" style="height:26px;"><actinic:variable name="RealTimeStockDisplay" /></td> <td id="retailex" width="21%" align="left" valign="middle"> RRP (Ex) <Actinic:PRICES> £<actinic:variable name="ProductPriceRaw" /></Actinic:PRICES></td> <td width="22%" align="left" valign="middle"> <Actinic:PRICES> <actinic:block php="true"> $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />; { $rrpincvat = number_format(($rawprice*1.2), 2, ".", " "); echo "RRP (Inc) £$rrpincvat"; } </actinic:block> </Actinic:PRICES> </td> <td width="22%" align="left" valign="middle">TRADE (ex) <Actinic:PRICES PROD_REF="<actinic:variable Name="ProductID" />" RETAIL_PRICE_PROMPT="<Actinic:Variable Name="ProductPriceDescription"/>"> <actinic:variable name="PriceListRetail" /> </Actinic:PRICES> </td> <td width="22%" align="left" valign="middle"> % off RRP = <script> var tradeprice = document.getElementById('trade').innerHTML.replace(/[^\d\.]/g, ''); var retailpriceex = document.getElementById('retailex').innerHTML.replace(/[^\d\.]/g, ''); var tradedisc = ((retailpriceex-tradeprice)/retailpriceex)*100; var tradedisc = tradedisc * 10; var tradedisc = Math.round(tradedisc); var tradedisc = tradedisc / 10; document.write(tradedisc + '%'); </script> </td> </tr> </table>
Comment