Jump to content

Question

Posted

Hello!

 

I have the following in my invoice template:

 

{% if autodebit %}{% if invoice.autodebit_date_formatted %}Auto debit is enabled for your account, so we'll automatically process the card you have on file on {invoice.autodebit_date_formatted} unless payment has been applied sooner.{% else %}If you would like us to automatically charge your card, please log in to your account at http://{client_url} to set up auto debit.{% endif %}{% else %}If you would like us to automatically charge your card, please log in to your account at https://{client_url} to set up auto debit.{% endif %}

 

I'm wondering why the {else} statement is in there twice. When I remove the second one, I get the following error:

 

"Template parse error: endfor tag doesn't exist"

 

I'm just trying to understand the logic.

 

Thanks!

3 answers to this question

Recommended Posts

  • 0
Posted

There is a nested conditional with else statements for each of them.

{% if autodebit %}
    {% if invoice.autodebit_date_formatted %}
        Auto debit is enabled for your account, so we'll automatically process the card you have on file on {invoice.autodebit_date_formatted} unless payment has been applied sooner.
    {% else %}
        If you would like us to automatically charge your card, please log in to your account at http://{client_url} to set up auto debit.
    {% endif %}
{% else %}
    If you would like us to automatically charge your card, please log in to your account at https://{client_url} to set up auto debit.
{% endif %}

I'm wondering why the {else} statement is in there twice. When I remove the second one, I get the following error:
 
"Template parse error: endfor tag doesn't exist"

 

It sounds like you removed more than just that else statement. There is no endfor tag in the template you included, so it may be an error caused somewhere else, or due to broken syntax (e.g. missing endif). Examples in the docs.

  • 0
Posted

Hello!

 

I have the following in my invoice template:

 

 

I'm wondering why the {else} statement is in there twice. When I remove the second one, I get the following error:

 

"Template parse error: endfor tag doesn't exist"

 

I'm just trying to understand the logic.

 

Thanks!

 

You have the extra 

{% endif %}

if you remove that next to the else tag you will be fine.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...