[solved] {if} statements and multiple conditions in modules

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
kurashiki_ben
Forum Members
Forum Members
Posts: 86
Joined: Sun Jul 05, 2009 2:37 am

[solved] {if} statements and multiple conditions in modules

Post by kurashiki_ben »

Hi,

I am stuck with a general issue regarding {if} statements in one module.

In the cart module, I want to display different messages depending on how many products are in the cart.

{if no products}
you have no products
{else}{if number of products >10}
sorry, maximum of 10 products for an online order, please call
{else}
display cart
{/if}
{/if}

I have used:
{if !isset($cartitems) || count($cartitems) >10 }
[CONTENT]
{else}
{if !isset($cartitems) || count($cartitems) == 0 }
[CONTENT]
{else}
[CART]
{/if}
{/if}

However, the {if !isset($cartitems) || count($cartitems) >10 } isn't taken into account at all.
The cart works as if that condition wasn't present.
If it is empty, it displays the empty message, but I can add as many items as I want without it displaying the >10 please call message.

Can you help me with the syntax please?

Regards

Ben
Last edited by kurashiki_ben on Mon Dec 28, 2009 10:51 am, edited 1 time in total.
Peciura

Re: {if} statements and multiple conditions in modules

Post by Peciura »

Try

Code: Select all

{if count($cartitems)==0}
   [cart is empty]
{elseif count($cartitems)>0 && count($cartitems)<=10 }
   [CART]
{else}
   [invalid number of items]
{/if}
kurashiki_ben
Forum Members
Forum Members
Posts: 86
Joined: Sun Jul 05, 2009 2:37 am

Re: {if} statements and multiple conditions in modules

Post by kurashiki_ben »

Peciura wrote: Try

Code: Select all

{if count($cartitems)==0}
   [cart is empty]
{elseif count($cartitems)>0 && count($cartitems)<=10 }
   [CART]
{else}
   [invalid number of items]
{/if}
Yep, that works a treat!
Actually, I needed $cart_itemcount not count($cartitems).

Final solution

Code: Select all

{if count($cartitems)==0}
   [cart is empty]
{elseif ($cart_itemcount)>0 && ($cart_itemcount)<=10}
   [CART]
{else}
   [invalid number of items]
{/if}
==> [solved]
Thanks!!

Ben
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: [solved] {if} statements and multiple conditions in modules

Post by jmcgin51 »

great - please add [solved] to the subject line of your original post, so that others will know it this issue is solved
kurashiki_ben
Forum Members
Forum Members
Posts: 86
Joined: Sun Jul 05, 2009 2:37 am

Re: [solved] {if} statements and multiple conditions in modules

Post by kurashiki_ben »

jmcgin51 wrote: great - please add [solved] to the subject line of your original post, so that others will know it this issue is solved
already is  ;D see your re: [solved]  ;)
Post Reply

Return to “Modules/Add-Ons”