Otaksone Posted January 13, 2018 Share Posted January 13, 2018 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 More sharing options...
Krystian Podemski Posted January 13, 2018 Share Posted January 13, 2018 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} Link to comment Share on other sites More sharing options...
Otaksone Posted January 14, 2018 Author Share Posted January 14, 2018 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 More sharing options...
Krystian Podemski Posted January 15, 2018 Share Posted January 15, 2018 Probably the position of {$highestValue = 0} is wrong, you should have it before the {foreach} displaying products in your shopping cart Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now