![]() |
Displaying Discount
Hi,
I want to be able to show the normal retail price for each product, and then a price after the global store discount (30%) has been applied. What's the easiest way to do this? Of course I'd like the after discount price to be the most prominent one. |
You could apply a {math} equation to your .tpl files showing the 30% discount for every price of {$product.price}.
hth. ;) |
I'm guessing I should change /customer/main/products.tpl? A couple of further questions since I'm such a newbie:
What syntax do I use in constructing the {math} equation? And what variable do I use to grab the flat 30% discount from the discount I set up as applying on all purchases greater than $0.00? Code:
{if $active_modules.Subscriptions ne "" and $products[product].catalogprice} This bit of code: Code:
<s> seems to be doing something similar to what I want... but I can't figure out how it is being invoked. |
$products[product].price would be the product price.
Come to think of it using {math} may not be very good since it would put a load on the server, you'd better better of doing the calculations within the php and passing the variable onto smarty for display. http://smarty.php.net/ |
Okay, now I'm lost! :D
So, what do I do to create the new smarty object, and where should I create it? This is my first time using smarty, so be gentle! |
If you like I can make the modifications for you, feel free to PM me with details. :wink:
|
I just PMed ya!
|
Okay, against my better judgement I hard coded the discount into the display to see what would happen:
Code:
<font class=ProductPrice>{$lng.lbl_our_price}: <s>{include file="currency.tpl" value=$products[product].price}</s> {math equation="price*0.7" price=$products[product].price discount=$products[product].discount format="%d.2f" assign=unformatted}{include file="currency.tpl" value=$unformatted}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}% And it resulted in the wrong price being displayed: Generic Comic Book This is a test item. -------------------------------------------------------------------------------- Our price: <s>$ 25.00</s> $ 17.20 |
would you not just use the adv discount option in the modify products page for this one. Just enter your selling price and drop 30 in the Adv. discount (%) field ?
|
I'd prefer not because the adv discount function rounds to the nearest dollar, and that is misleading and problematic when you are dealing with large volumes of low priced items like my business is.
|
{math equation="price-(price*.30)" price=$products[product].price format="%d.00" assign=unformatted}
Would this do the trick? |
format="%d.00" seems to round to the nearest dollar...
format="%.2f" is better but it truncates the string in stead of rounding it, so for 30% off 2.95 we are displayed $2.06 in the product window, but it is $2.07 when it's added to the cart because the actual price of $2.0666* is round up. format acts on the numeric as if it is a string. |
Where you able to make the adjustments to the smarty modifier plugin for formatprice, if so I'd like to see a snippet if possible. ;)
|
http://smarty.php.net/manual/en/language.modifier.string.format.php
so would using the global discount thing as mentioned before and then altering the smarty string_format command to round up to the nearest penny or cent be ok ? |
It would be best to round to the closest penny, actually, since that's what the calculation for the shopping cart does.
Go to http://www.morecomics.net and add the item that is normally $2.95 to your cart and you'll see what I mean. It is displyed on the page as $2.06, but the price displayed in the cart area is $2.07. Here is the code that I am currently using: Code:
<font class=ProductPrice>{$lng.lbl_our_price}: <s>{include file="currency.tpl" value=$products[product].price}</s> {math equation="price*0.7" price=$products[product].price discount=$products[product].discount assign=unformatted}{include file="currency.tpl" value=$unformatted}</font> When I tried using the code that is mention at http://smarty.php.net/manual/en/language.modifier.string.format.php - {$number|string_format:"%.2f"} all I got were values like this: $2.26 $7.20 That is, everything had "2" in the first place after the decimal point. I'm getting puzzled here! |
All times are GMT -8. The time now is 12:52 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.