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

Page for products with list price < price

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-17-2018, 12:10 AM
 
naemsmommy naemsmommy is offline
 

Senior Member
  
Join Date: Jul 2007
Posts: 144
 

Default Page for products with list price < price

I am using 4.7.8 Gold. I've created a new php page that currently displays all products (based on products.php). I just want it to only display products that have a list price (i.e. products on sale).

I've tried many different things but I'm not having any luck. Does anyone have any ideas on how this could be accomplished?

Thanks!
__________________
Danielle
Reply With Quote
  #2  
Old 01-17-2018, 01:01 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,060
 

Default Re: Page for products with list price < price

You would need to include an if statement in the loop in the template:

{if $product.list_price gt 0}
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #3  
Old 01-17-2018, 09:54 AM
 
naemsmommy naemsmommy is offline
 

Senior Member
  
Join Date: Jul 2007
Posts: 144
 

Default Re: Page for products with list price < price

Quote:
Originally Posted by pauldodman
You would need to include an if statement in the loop in the template:

{if $product.list_price gt 0}

Well, what is odd, is that the template page is blank and the page still returns all products. This is the first time I've set up a new php page and clearly I've done something wrong. Nothing I add to the tpl file shows up. It's all being generated in the php file.
__________________
Danielle
Reply With Quote
  #4  
Old 01-17-2018, 09:56 AM
 
naemsmommy naemsmommy is offline
 

Senior Member
  
Join Date: Jul 2007
Posts: 144
 

Default Re: Page for products with list price < price

I should clarify that if I remove the code from the php file that is generating the search results, then anything I type into the tpl file does show up. I'm not sure what code I need in the php file and what in the tpl file.
__________________
Danielle
Reply With Quote
  #5  
Old 01-17-2018, 11:30 AM
 
naemsmommy naemsmommy is offline
 

Senior Member
  
Join Date: Jul 2007
Posts: 144
 

Default Re: Page for products with list price < price

Quote:
Originally Posted by pauldodman
You would need to include an if statement in the loop in the template:

{if $product.list_price gt 0}

OK I've got the page itself working, but I can't get the if statement to work correctly. It only returns one product, even though there are multiple products with a list price greater then 0. As far as I can tell, it will only return a product with a list price of greater then 0 that also has no variants. If a product has variants, it won't show even if there is a list price entered.
__________________
Danielle
Reply With Quote
  #6  
Old 01-18-2018, 06:46 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,060
 

Default Re: Page for products with list price < price

You could try:
{if $product.appearance.market_price_discount gt 0}

Worked fine for me on the products listing page.
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #7  
Old 01-18-2018, 11:25 AM
 
naemsmommy naemsmommy is offline
 

Senior Member
  
Join Date: Jul 2007
Posts: 144
 

Default Re: Page for products with list price < price

Quote:
Originally Posted by pauldodman
You could try:
{if $product.appearance.market_price_discount gt 0}

Worked fine for me on the products listing page.

Yes, I had tried that yesterday, it doesn't work either. It actually returns no products, whereas the other query does return a product.

From reading through the forums, it seems like the list_price is removed from some pages when there are variants with prices. I'm not sure how to get it back.
__________________
Danielle
Reply With Quote
  #8  
Old 01-18-2018, 11:50 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default Re: Page for products with list price < price

List price is attached to the product and not to variant. As far as I know it is there at all times - as long as there is product array available on the page.

You can do the foreach to list products in smarty with condition however if you do not need these products on the page it is way better and faster to strip them out in php.

Either use func_search_products (you can see an example of it in bestsellers module) so you can have the query restrictions set there OR do foreach and unset product after you run the search.php in your scrip (since you said it is based on products.php).

I would redo the script and use func_search_products - it is faster and collects just the necessary info which you can add to if you need more after that.

Then in the smarty template just do foreach loop and list the products
__________________
Steve Stoyanov
CFLSystems.com
Web Development
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 04:27 AM.

   

 
X-Cart forums © 2001-2020