Jump to content

Assigning variable only if if statement applies to all items.


Apury

Recommended Posts

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

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