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

Show products with variants with price lowest to highest

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #11  
Old 08-11-2015, 06:25 PM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: Show products with variants with price lowest to highest

Quote:
Originally Posted by fiberglass.supply
final issue is how to not show on products with no variants or options. on those products it shows price lowest to highest but it not needed.

Just change the code as follows:

Code:
{if $variants} {assign var="variant_max_price" value=$product.taxed_price} {assign var="variant_min_price" value=$product.taxed_price} {foreach from=$variants item="variant_item"} {math assign="variant_max_price" equation="max(x, y)" x=$variant_max_price y=$variant_item.taxed_price} {math assign="variant_min_price" equation="min(x, y)" x=$variant_min_price y=$variant_item.taxed_price} {/foreach} Max. Price: {$variant_max_price} Min. Price: {$variant_min_price} {/if}
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote

The following user thanks seyfin for this useful post:
fiberglass.supply (08-12-2015)
  #12  
Old 08-12-2015, 04:40 AM
 
fiberglass.supply fiberglass.supply is offline
 

Senior Member
  
Join Date: Dec 2012
Location: Florida
Posts: 171
 

Default Re: Show products with variants with price lowest to highest

Thank you very much, it worked perfectly on product details page.


I tried it on category page/products list page but it did not work. Is the code different for that page?
Reply With Quote
  #13  
Old 08-13-2015, 06:42 AM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: Show products with variants with price lowest to highest

The same code will not work on category page/products list page, unfortunately, as $variants variable is not available at this page.

Basically, it requires more complex custom code modifications both in X-Cart's scripts and templates: your custom code should retrieve the variants info for each product to be displayed on category page, then pass the info to Smarty templates, to display the min. and max. variant prices for each product.

You can take advantage of our custom development services, and our developers will implement such customization for you.
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote
  #14  
Old 10-23-2015, 12:06 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Show products with variants with price lowest to highest

This worked for me... (v4.7.x)

In products.php

BEFORE...
Code:
$smarty->assign('cat_products', isset($products) ? $products : array());
INSERT...
Code:
if($products) { foreach($products as $key=> $product) $products[$key]["minprice"] = func_query_first_cell("SELECT min(price) FROM $sql_tbl[pricing] WHERE productid=".$product["productid"]); foreach($products as $key=> $product) $products[$key]["maxprice"] = func_query_first_cell("SELECT max(price) FROM $sql_tbl[pricing] WHERE productid=".$product["productid"]); }

In skin/<SKIN>/customer/main/products_list.tpl AND/OR skin/<SKIN>/customer/main/products_t.tpl

INSERT....

Code:
{if $product.variantid && ($product.minprice != $product.maxprice)} {math assign="min_price" equation="x*y" x=$product.minprice y=1.2}{* tax rate if applicable *} {math assign="max_price" equation="x*y" x=$product.maxprice y=1.2}{* tax rate if applicable *} <p><b>{$lng.lbl_from} {currency value=$min_price} {$lng.lbl_to} {currency value=$max_price}</b></p> {/if}

*Updated*
__________________
xcartmods.co.uk
Reply With Quote

The following user thanks PhilJ for this useful post:
seyfin (10-23-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may 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 05:43 PM.

   

 
X-Cart forums © 2001-2020