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

If statement for specific option class?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-23-2009, 04:33 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default If statement for specific option class?

Here's a tricky one - have a client who we are displaying the price on the category page with 'Starting at' in front of it for products with options using this:

{if $products[product].is_product_options}

However, he would only like this to display for products that are variants with a specific option class - in this case 'size'. So products that have an option with the class of 'size' will show 'starting at' while products that have an option class of 'flavor' will not. Version 4.1.10. Any ideas?
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #2  
Old 02-24-2009, 12:16 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default Re: If statement for specific option class?

It's quite simple
find in your skin1/customer/main/product.tpl
Code:
<tr><td class="ProductPriceConverting" valign="top">{$lng.lbl_price}:
and replace with
Code:
<tr><td class="ProductPriceConverting" valign="top">{$lng.lbl_price} {foreach from=$product_options item=v}{if $v.class|lower eq 'size'}starting at{/if}{/foreach}:
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #3  
Old 02-24-2009, 01:20 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default Re: If statement for specific option class?

Sorry I have missed that you need this in category.
add in your products.php before the line
Code:
$smarty->assign("products",$products);


this:
Code:
foreach($products as &$pp){ $pp['product_options'] = func_get_product_classes($pp['productid'], false); }

and every product from your $products array will contain additional array with product options
so you just need to edit skin1/customer/main/products.tpl and skin1/customer/main/products_t.tpl as it was figured in my previous post
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #4  
Old 02-24-2009, 04:12 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for specific option class?

No luck with that Victor. There's an extra & in your php (before $pp) but even removing that doesn't do anything. Any other ideas?
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 02-24-2009, 04:19 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default Re: If statement for specific option class?

This & is necessary to pass the element of array by reference so it should present because $products array won't be modified without it.
But I have found another bug (error message for the categories with no products in it)
so try with
Code:
if (count($products)) foreach($products as &$pp){ $pp['product_options'] = func_get_product_classes($pp['productid'], false); }
in products.php

and
Code:
{foreach from=$products[product].product_options item=v}{if $v.class|lower eq 'size'}starting at{/if}{/foreach}
for skin1/customer/main/products.tpl
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #6  
Old 02-24-2009, 04:20 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for specific option class?

Well that causes a smarty error
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #7  
Old 02-24-2009, 04:23 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for specific option class?

Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /public_html/new/products.php on line 106
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #8  
Old 02-24-2009, 06:00 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: If statement for specific option class?

Try this php:
PHP Code:
foreach($products as $k=>$v){
     
$products[$k]['product_options'] = func_get_product_classes($products[$k]['productid'], false);

__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #9  
Old 02-24-2009, 06:08 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for specific option class?

Thanks Ralph - no smarty error from that, but no 'starting at' showing either. Other ideas?
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #10  
Old 02-24-2009, 06:20 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default Re: If statement for specific option class?

http://www.phpbuilder.com/manual/en/language.references.pass.php
also I should mention that this is working for me
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 06:08 AM.

   

 
X-Cart forums © 2001-2020