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)
-   -   Page for products with list price < price (https://forum.x-cart.com/showthread.php?t=75927)

naemsmommy 01-17-2018 12:10 AM

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!

pauldodman 01-17-2018 01:01 AM

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}

naemsmommy 01-17-2018 09:54 AM

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.

naemsmommy 01-17-2018 09:56 AM

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.

naemsmommy 01-17-2018 11:30 AM

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.

pauldodman 01-18-2018 06:46 AM

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.

naemsmommy 01-18-2018 11:25 AM

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.

cflsystems 01-18-2018 11:50 AM

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


All times are GMT -8. The time now is 10:22 PM.

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