X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Displaying Discount (https://forum.x-cart.com/showthread.php?t=2199)

B00MER 04-08-2003 12:04 PM

{math equation="price-(price*.30)" price=$products[product].price format="%d.00" assign=unformatted}

Would this do the trick?

Jason Brice 04-08-2003 12:35 PM

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.

B00MER 04-10-2003 04:30 AM

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. ;)

shan 04-10-2003 05:30 AM

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 ?

Jason Brice 04-10-2003 12:57 PM

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 10:24 AM.

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