Apury Posted February 7, 2019 Share Posted February 7, 2019 Hello there. I'm trying to check a shopping cart's products for their category and want my bigger if statement to be triggered if every product in the cart is part of a certain default category. {assign var="worldwide" value=false} {assign var="idCategory" value=15} {foreach from=$cart.products item=product} {if $product.id_category_default == $idCategory} {assign var="worldwide" value=true} {/if} {/foreach} {if $worldwide == true} {/if} In its current state it however is true if just one product of category value 15 is in cart. I want it so that it only outputs as true if all products in cart are part of same category. Link to comment Share on other sites More sharing options...
JBW Posted February 8, 2019 Share Posted February 8, 2019 You missed to set "worldwide" to false again if a product does not meet your condition. 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