Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Displaying Discount

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-07-2003, 07:00 PM
 
Jason Brice Jason Brice is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Christchurch, New Zealand
Posts: 42
 

Default 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.
Reply With Quote
  #2  
Old 04-07-2003, 08:05 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

You could apply a {math} equation to your .tpl files showing the 30% discount for every price of {$product.price}.

hth.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #3  
Old 04-07-2003, 08:23 PM
 
Jason Brice Jason Brice is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Christchurch, New Zealand
Posts: 42
 

Default

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} {include file="modules/Subscriptions/subscription_info_inlist.tpl"} {else} {if $products[product].price ne 0} {if $products[product].discount ne 0} <font class=MarketPrice>{$lng.lbl_market_price}: <s> {math equation="price/(1-(discount/100))" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted} </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].discount ne 0}, save {$products[product].discount}%{/if}{if $config.General.use_vat eq "Y"}, {$lng.lbl_including_vat} {$products[product].vat}%{/if} {else} <font class=ProductPrice>{$lng.lbl_enter_your_price}</font> {/if} {/if}


This bit of code:
Code:
<s> {math equation="price/(1-(discount/100))" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted} </s>

seems to be doing something similar to what I want... but I can't figure out how it is being invoked.
Reply With Quote
  #4  
Old 04-07-2003, 09:45 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

$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/
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #5  
Old 04-07-2003, 10:32 PM
 
Jason Brice Jason Brice is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Christchurch, New Zealand
Posts: 42
 

Default

Okay, now I'm lost!

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!
Reply With Quote
  #6  
Old 04-07-2003, 11:21 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

If you like I can make the modifications for you, feel free to PM me with details.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #7  
Old 04-07-2003, 11:37 PM
 
Jason Brice Jason Brice is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Christchurch, New Zealand
Posts: 42
 

Default

I just PMed ya!
Reply With Quote
  #8  
Old 04-08-2003, 02:12 AM
 
Jason Brice Jason Brice is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Christchurch, New Zealand
Posts: 42
 

Default

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
Reply With Quote
  #9  
Old 04-08-2003, 03:05 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

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 ?
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #10  
Old 04-08-2003, 03:08 AM
 
Jason Brice Jason Brice is offline
 

Advanced Member
  
Join Date: Mar 2003
Location: Christchurch, New Zealand
Posts: 42
 

Default

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.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:54 AM.

   

 
X-Cart forums © 2001-2020