Jump to content

Get array on feature of all products in cart


Otaksone

Recommended Posts

HI, how i can get array of one feature (ex HEIGHT ) of all product in cart in one array.

I can get biggest value

My cart

oneproducts --> height 10

secondproducts --> height 30

i get value 30

in shooping-cart-prodoct-line.tpl, i have add this code:

{assign var='features' value=Product::getFrontFeaturesStatic($cookie->id_lang, $product.id_product)}
          {if isset($features) && $features}
                 {foreach from=$features item=feature}
                        {if isset($feature.value)}
                            
                                  {if $feature.name == "HEIGHT"}
                                                {$HEIGHT = $feature.value}
                                             {/if}
     {/if}
                  {/foreach}
            {/if} 

 

But print all HEIGHT value..i want only biggest HEIGHT.

Link to comment
Share on other sites

17 hours ago, Krystian Podemski said:

At first, assign the default value to variable

{$highestValue = 0}

In your loop and if statement checking if the current feature is Height you can add code like this

{if $feature.value > $highestValue}{$highestValue = $feature.value}

 

HI, thank you but not work:

this is my final code

{$highestValue = 0}                     

                                 {if isset($features) && $features}
                                    {foreach from=$features item=feature}
                                        {if isset($feature.value)} 
                                             {if $feature.name == "HEIGHT"}
                                {if $feature.value > $highestValue}
                                {$highestValue = $feature.value}
                                            {/if}                    
                                             {/if}
                                        {/if}
                                    {/foreach}
                                {/if}

{$highestValue}
    

 print:
10
30

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...