X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Displaying product savings in $ amount instead of % percent (https://forum.x-cart.com/showthread.php?t=4263)

enge919 09-06-2003 08:49 PM

Displaying product savings in $ amount instead of % percent
 
Is there a way that I can show my customers how much they are saving in dollar amount rather that the standard way xcart displays it in percentage.

I found this code that generates the percentage amount in customer/main/products_tpl

Code:

>{if $products[product].list_price gt 0 and $products[product].price lt $products[product].list_price}, save {$discount}%{/if}

How can I change this to display in dollar amount?

funkydunk 09-30-2003 10:52 PM

change:

Code:

{if $products[product].list_price gt 0}
{math equation="100-(price/lprice)*100" price=$products[product].price lprice=$products[product].list_price format="%d" assign=discount}
<font class=MarketPrice>{$lng.lbl_market_price}: <s>
{include file="currency.tpl" value=$products[product].list_price}
</s></font>

{/if}
<font class=ProductPrice>{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].list_price gt 0}, save {$discount}%{/if}{if $config.Taxes.use_vat eq "Y" and $products[product].vat gt "0"}, {$lng.lbl_including_vat} {$products[product].vat}%{/if}
{else}


to:

Code:

{if $products[product].list_price gt 0}
{math equation="lprice-lprice" price=$products[product].price lprice=$products[product].list_price format="%d" assign=discount}
<font class=MarketPrice>{$lng.lbl_market_price}: <s>
{include file="currency.tpl" value=$products[product].list_price}
</s></font>

{/if}
<font class=ProductPrice>{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].list_price gt 0}, save {$config.General.currency_symbol}{$discount}{/if}{if $config.Taxes.use_vat eq "Y" and $products[product].vat gt "0"}, {$lng.lbl_including_vat} {$products[product].vat}%{/if}
{else}


enge919 10-04-2003 08:51 AM

Thanks Funkydunk.....Works like a charm!

dealsondeals 10-04-2003 02:10 PM

:wink: Nice one!

adpboss 11-17-2003 05:24 PM

Here's my code in customer/products.tpl

Code:

{math equation="(lprice-price)" price=$products[product].price lprice=$products[product].list_price assign=discount}
{$lng.lbl_market_price}:
{include file="currency.tpl" value=$products[product].list_price}


{/if}
{$lng.lbl_our_price}: <font class=ProductPrice>{include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].list_price gt 0 and $products[product].price lt $products[product].list_price}, You save <u>{include file="currency.tpl" value=$discount}</u>{/if}{if $config.Taxes.use_vat eq "Y" and $products[product].vat gt "0"}, {$lng.lbl_including_vat} {$products[product].vat}%{/if}
{else}


Code:

="(lprice-price)" price=$products[product].price lprice=$products[product].list_price assign=discount}

Code:

You save <u>{include file="currency.tpl" value=$discount}</u>

Same effect, slightly different code. :)

funkydunk 11-20-2003 04:51 AM

almost :)

yours will do the math equation even if there is no difference in price. Effectively that could slow the site down by, oooh probably in the order of .1 microsecond :LOL

BoomBoomBap 01-13-2004 10:26 PM

I wasnt able to get either one of these fixes working for 3.4.10

Any update here?

the code Im currently using is below. Naturally I would like it to show $ instead of % as the topic of this forum indicates.

Code:

{if $product.price ne 0}{include file="currency.tpl" value=$product.price}{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product.price}{if $config.Taxes.use_vat eq "Y" and $product.vat gt "0"}, {$lng.lbl_including_vat} {$product.vat}%{/if}
{/if}


{if $product.list_price gt 0 and $product.price lt $product.list_price}
{math equation="100-(price/lprice)*100" price=$product.price lprice=$product.list_price format="%d" assign=discount}(Save {$discount}%){/if}


BoomBoomBap 01-13-2004 10:37 PM

oh my. that was far too easy.

Quote:

{$product.list_price}

that's all i need

dealsondeals 01-14-2004 06:30 AM

Is it possible to have this post moved to "Custom Mods & Templates"? This is one I had definitely forgot about and if looking for it I would have started in the "Custom Mods & Templates" area of the forum.

Thanks,

Glen

POSDepot 04-27-2004 06:48 PM

Error in Code?
 
Quote:


{math equation="lprice-lprice" price=$products[product].price


I couldn't get FunkyDunk's mod to work until I changed the line above to this:


Quote:

{math equation="lprice-price" price=$products[product].price


I kept getting $0.00 because it was subtracting lprice from itself.

Please note I know nothing about coding so I may be wrong here, but it seems to work with the change I made.

Randy
X-Cart 3.5.3[/quote]


All times are GMT -8. The time now is 05:43 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.