Jump to content

Problem when a product has several values from the same feature


AureAure

Recommended Posts

Hello,

I'm on PS 1.7.5 and I'm trying to display text on my product descriptions according to the product's features. 

I managed to do it with this code :

{block name='product_features'}
    {if $product.grouped_features}
{foreach from=$product.grouped_features item=feature}

{if $feature.id_feature == 18 && $feature.value=="Blue"}
 <div>
My text
</div>    
{/if}

{/foreach}
{/if}
  {/block}

 

It works well except if a product has several values from the same feature. Then it doesn't display anything.

For exemple with my code above:

If my product has two values (Blue and Yellow) from the feature with id 18 (Color), then the text doesn't display. If my product has only one value from this feature (Blue for exemple), it works well.

Can someone help me please ? Do someone knows why ?

Thank you very much for your help.

Edited by AureAure (see edit history)
Link to comment
Share on other sites

  • AureAure changed the title to Problem when a product has several values from the same feature

J'ai found a solution, I added "|strstr:" to the code instead of "==" for the value condition.

So the code is :

{block name='product_features'}    

{if $product.grouped_features}

{foreach from=$product.grouped_features item=feature}

{if $feature.id_feature == 18 && $feature.value|strstr:"Blue"}   <div> My text </div>    

{/if} {/foreach} {/if}   {/block}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...