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
  #1  
Old 08-08-2015, 08:25 AM
 
fiberglass.supply fiberglass.supply is offline
 

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

Default Show products with variants with price lowest to highest

Show products with variants with price lowest to highest

I would like to show for example

Priced from: $2.00 to $10.00

Right now the price shown is the one defined in the "def" column.
I want to show lowest to highest not just one or the others when the product has variants.

Nothing on the forum anywhere about how to implement it.
Reply With Quote
  #2  
Old 08-10-2015, 06:12 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

I am sorry, do you need it to be implemented for X-Cart 5 or X-Cart 4?
__________________
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
  #3  
Old 08-10-2015, 07:10 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

4.6.6 Gold
Reply With Quote
  #4  
Old 08-10-2015, 07:37 AM
  razortw's Avatar 
razortw razortw is offline
 

X-Cart team
  
Join Date: Feb 2015
Posts: 807
 

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

Quote:
Originally Posted by fiberglass.supply
4.6.6 Gold
Thanks for the clarification.
I think you should turn on the webmaster mode and look into the {$variants} variable. It contains the necessary information about product's variants
The template you can insert the new code into is /customer/main/product_details.tpl
__________________
Best regards,
Igor Pudovkin
X-Cart hosting team
Reply With Quote
  #5  
Old 08-10-2015, 09:34 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

I have the code below

Code:
{if $active_modules.XPayments_Subscriptions and $product.subscription.subscription_product eq 'Y'} {include file="modules/XPayments_Subscriptions/customer/product_details.tpl"} {else} <div class="property-name product-price">{if $products[product].variantid ne ""}From: {else}Your Price: {/if}</div> <div class="property-value"> {if $product.taxed_price ne 0 or $variant_price_no_empty} <span class="product-price-value">{currency value=$product.taxed_price tag_id="product_price"}</span> <span class="product-market-price">{alter_currency value=$product.taxed_price tag_id="product_alt_price"}</span> {if $product.taxes} <br />{include file="customer/main/taxed_price.tpl" taxes=$product.taxes} {/if}

-------------------------------------------------


This part does not work though
Code:
<div class="property-name product-price">{if $products[product].variantid ne ""}From: (Special code to show lowest to highest would go here i am guessing???){else}Your Price: {/if}</div>

it always shows "Your Price:" even if there is a variant.
Reply With Quote
  #6  
Old 08-10-2015, 09:35 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

I am sure a lot of people would like this feature if they have variants with diferent prices.
Reply With Quote
  #7  
Old 08-10-2015, 11:27 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

Below is a sample code that can be used to get max. and min. prices for product variants:

Code:
{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}

As suggested earlier, please use the Webmaster Mode to get information about what Smarty variables are available and can be used in your custom code.
Attached Thumbnails
Click image for larger version

Name:	2015-08-11 11-22-17 Webmaster Mode.png
Views:	143
Size:	220.9 KB
ID:	4262  Click image for larger version

Name:	2015-08-11 11-22-58 Webmaster Mode.png
Views:	136
Size:	223.5 KB
ID:	4263  Click image for larger version

Name:	2015-08-11 11-26-37 Sample Code.png
Views:	130
Size:	59.1 KB
ID:	4264  
__________________
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
  #8  
Old 08-10-2015, 11:32 PM
  razortw's Avatar 
razortw razortw is offline
 

X-Cart team
  
Join Date: Feb 2015
Posts: 807
 

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

Quote:
Originally Posted by fiberglass.supply
I have the code below

Code:
{if $active_modules.XPayments_Subscriptions and $product.subscription.subscription_product eq 'Y'} {include file="modules/XPayments_Subscriptions/customer/product_details.tpl"} {else} <div class="property-name product-price">{if $products[product].variantid ne ""}From: {else}Your Price: {/if}</div> <div class="property-value"> {if $product.taxed_price ne 0 or $variant_price_no_empty} <span class="product-price-value">{currency value=$product.taxed_price tag_id="product_price"}</span> <span class="product-market-price">{alter_currency value=$product.taxed_price tag_id="product_alt_price"}</span> {if $product.taxes} <br />{include file="customer/main/taxed_price.tpl" taxes=$product.taxes} {/if}

-------------------------------------------------


This part does not work though
Code:
<div class="property-name product-price">{if $products[product].variantid ne ""}From: (Special code to show lowest to highest would go here i am guessing???){else}Your Price: {/if}</div>

it always shows "Your Price:" even if there is a variant.
Here's the smarty code to retrieve variants prices
Code:
<span class="product-price-value"> {if $variants ne ""} {foreach from=$variants item=var} {currency value=$var.taxed_price tag_id="product_price"} <br /> {/foreach} {else} {currency value=$product.taxed_price tag_id="product_price"} {/if} </span>
You can use it as an example.
__________________
Best regards,
Igor Pudovkin
X-Cart hosting team
Reply With Quote
  #9  
Old 08-11-2015, 09:02 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

Quote:
Originally Posted by seyfin
Below is a sample code that can be used to get max. and min. prices for product variants:

Code:
{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}

As suggested earlier, please use the Webmaster Mode to get information about what Smarty variables are available and can be used in your custom code.

wow perfect this code worked great,



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.
Reply With Quote
  #10  
Old 08-11-2015, 11:37 AM
  razortw's Avatar 
razortw razortw is offline
 

X-Cart team
  
Join Date: Feb 2015
Posts: 807
 

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

Quote:
Originally Posted by fiberglass.supply
wow perfect this code worked great,

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.
You can use the {if} condition.
Something like
Code:
{if $variants ne ""} ... regular code ... {else} ... code for variants ... {/if}
__________________
Best regards,
Igor Pudovkin
X-Cart hosting team
Reply With Quote

The following user thanks razortw for this useful post:
fiberglass.supply (08-11-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 09:43 AM.

   

 
X-Cart forums © 2001-2020