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
[solved] {if} statements and multiple conditions in modules
-
kurashiki_ben
- Forum Members

- Posts: 86
- Joined: Sun Jul 05, 2009 2:37 am
[solved] {if} statements and multiple conditions in modules
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
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

- Posts: 86
- Joined: Sun Jul 05, 2009 2:37 am
Re: {if} statements and multiple conditions in modules
Yep, that works a treat!Peciura wrote: TryCode: Select all
{if count($cartitems)==0} [cart is empty] {elseif count($cartitems)>0 && count($cartitems)<=10 } [CART] {else} [invalid number of items] {/if}
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}Thanks!!
Ben
Re: [solved] {if} statements and multiple conditions in modules
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

- Posts: 86
- Joined: Sun Jul 05, 2009 2:37 am
Re: [solved] {if} statements and multiple conditions in modules
already isjmcgin51 wrote: great - please add [solved] to the subject line of your original post, so that others will know it this issue is solved
