0

I have an Expresso:Store site and I am using the following conditionals in the header:

{exp:store:cart}
{if no_items}
    <a href="{path='store/checkout'}">Your bag is empty</a>

        <div class="details">
            {if logged_in}
                <br /><a href="{path='store/my_orders'}">My Orders</a>
                <!-- template parsing fails -->
            {if:else}
                <br /><a href="{path='account/login'}">Login</a>
            {/if}
         </div>
    {/if}

<a href="{path='store/checkout'}">My Shopping Bag ({order_qty})</a>
    <div class="details">
         <span class="price">{order_subtotal}</span><a href="{path='store/checkout'}">Checkout</a>
     {if logged_in}
         <br /><a href="{path='store/my_orders'}">My Orders</a>
     {if:else}
         <br /><a href="{path='account/login'}">Login</a>
     {/if}
     </div>
{/exp:store:cart}

When I am logged in, the template parses fine and everything works.

If I am NOT logged in, the template parses up to the commented line and the header template fails to output anything after that line, breaking the remaining page layout.

It's as if it just stops after that line, but I can't work out what I have done wrong, there are no template errors I can see in the EE template editor.

  • Please confirm, you've stated "When I am logged in" and "If I am logged in" I'm assuming you meant logged OUT for the second one? – Peter Lewis Sep 2 '13 at 10:05
  • Thanks, updated the question, you're right I meant logged out for the second instance – mattbee Sep 2 '13 at 10:23
0

Perhaps it's to do with parse order? From my understanding, the {if:else} conditional (particularly of the logged_in variety) is counted as an advanced conditional, so gets parsed later than modules, such as the Expresso:store.

This is just guessing, but perhaps when parsing exp:store:cart, it's interpreting the {if:else} on line 9 as being part of the {if no_items} conditional, rather than the {if logged_in}.

Hope that helps

| improve this answer | |
  • You may be correct, I just added my own (similar) answer, having found that it's the {if} statement nested in the no_items if statement that was failing, moving the code around has got rid of the issue. – mattbee Sep 2 '13 at 10:27
  • Good to hear you resolved it. I did a bit of checking and I'd be pretty confident that having any sort of logged_in statement or if/else statement would send it down the parse order, according to here and here – David Leitch Sep 2 '13 at 10:34
2

Try this instead:

 {if logged_in}
     <br /><a href="{path='store/my_orders'}">My Orders</a>
 {/if}
 {if logged_out}
     <br /><a href="{path='account/login'}">Login</a>
 {/if}

Not sure if it's an EE version thing, but {if:else} never used to work for me on older EE versions, but does with the latest. Either that or it's where it's used (EE introduced new conditional parsing rules with a more recent update), so the {if:else} may work in channel:entries, but not outside. Just theoretical.

| improve this answer | |
  • Thanks, I tried that but it didn't help - but moving the code around helped my find the answer! – mattbee Sep 2 '13 at 10:22
0

I have worked out that the issue is something to do with nesting {if logged_in} within the {if no_items} loop.

The code is all working fine without the {if} statement in the expresso:store {no_items} - a bit of reworking the code to not need any nested loops worked much better.

I can't explain the issue, but it's resolved my problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.