cancel
Showing results for 
Search instead for 
Did you mean: 

Customer Account - Exception Notice: Undefined offset: 1 in IfDirective.php on line 43

SOLVED

Customer Account - Exception Notice: Undefined offset: 1 in IfDirective.php on line 43

Magento CE 2.3.4

PHP 7.3.15

 

Hi,

 

after migration from Magento 1.9.3 to 2.3.x I've got huge problems with the customer accounts. When I register a new one there are no problems - the confirmation email is sent, I can confirm and edit the customers account data in the frontend and in the backend.

 

With the imported accounts i got the following error, when I want to edit them:

 

Exception #0 (Exception): Notice: Undefined offset: 1 in /var/www/vhosts/shop.kedo.de/httpdocs/magento2/vendor/magento/framework/Filter/DirectiveProcessor/IfDirective.php on line 43

The same line appears in the system.log from Magento.

 

I got stuck here and any help would be appreciated. What can I do to isolate that problem?

 

Thanks in advance and best wishes,

 

Joska

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Customer Account - Exception Notice: Undefined offset: 1 in IfDirective.php on line 43

Re: Customer Account - Exception Notice: Undefined offset: 1 in IfDirective.php on line 43

Hi Rahul,

 

that was s good hint. I saw it before and hadn't realised the section with the if directive in email templates.

 

That was not the solution for me. Neither the first nor the second solution worked for me.

My database table "directory_country_format" was empty and after deleting some if statements in two email templates the error still occured.

 

But - I made a database dump and found "{{if" statements in:

 

- customer/address_templates/text'

- customer/address_templates/oneline

- customer/address_templates/pdf

 

These can be found in Stores > Configuration > Customers > Customer Configuration > Address Templates.

 

I took these templates from a fresh Magento 2 installation:

 

Text:

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}
{{depend company}}{{var company}}{{/depend}}
{{if street1}}{{var street1}}
{{/if}}
{{depend street2}}{{var street2}}{{/depend}}
{{depend street3}}{{var street3}}{{/depend}}
{{depend street4}}{{var street4}}{{/depend}}
{{if city}}{{var city}},  {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
{{var country}}
{{depend telephone}}T: {{var telephone}}{{/depend}}
{{depend fax}}F: {{var fax}}{{/depend}}
{{depend vat_id}}VAT: {{var vat_id}}{{/depend}}

 

Text Oneline:

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, {{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}}

 

PDF:

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}|
{{depend company}}{{var company}}|{{/depend}}
{{if street1}}{{var street1}}|{{/if}}
{{depend street2}}{{var street2}}|{{/depend}}
{{depend street3}}{{var street3}}|{{/depend}}
{{depend street4}}{{var street4}}|{{/depend}}
{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}|
{{var country}}|
{{depend telephone}}T: {{var telephone}}|{{/depend}}
{{depend fax}}F: {{var fax}}|{{/depend}}|
{{depend vat_id}}VAT: {{var vat_id}}{{/depend}}|

And with these templates the error is gone!

 

Thanks a lot!

View solution in original post

2 REPLIES 2

Re: Customer Account - Exception Notice: Undefined offset: 1 in IfDirective.php on line 43

Re: Customer Account - Exception Notice: Undefined offset: 1 in IfDirective.php on line 43

Hi Rahul,

 

that was s good hint. I saw it before and hadn't realised the section with the if directive in email templates.

 

That was not the solution for me. Neither the first nor the second solution worked for me.

My database table "directory_country_format" was empty and after deleting some if statements in two email templates the error still occured.

 

But - I made a database dump and found "{{if" statements in:

 

- customer/address_templates/text'

- customer/address_templates/oneline

- customer/address_templates/pdf

 

These can be found in Stores > Configuration > Customers > Customer Configuration > Address Templates.

 

I took these templates from a fresh Magento 2 installation:

 

Text:

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}
{{depend company}}{{var company}}{{/depend}}
{{if street1}}{{var street1}}
{{/if}}
{{depend street2}}{{var street2}}{{/depend}}
{{depend street3}}{{var street3}}{{/depend}}
{{depend street4}}{{var street4}}{{/depend}}
{{if city}}{{var city}},  {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}
{{var country}}
{{depend telephone}}T: {{var telephone}}{{/depend}}
{{depend fax}}F: {{var fax}}{{/depend}}
{{depend vat_id}}VAT: {{var vat_id}}{{/depend}}

 

Text Oneline:

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, {{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}}

 

PDF:

{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}|
{{depend company}}{{var company}}|{{/depend}}
{{if street1}}{{var street1}}|{{/if}}
{{depend street2}}{{var street2}}|{{/depend}}
{{depend street3}}{{var street3}}|{{/depend}}
{{depend street4}}{{var street4}}|{{/depend}}
{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}}|
{{var country}}|
{{depend telephone}}T: {{var telephone}}|{{/depend}}
{{depend fax}}F: {{var fax}}|{{/depend}}|
{{depend vat_id}}VAT: {{var vat_id}}{{/depend}}|

And with these templates the error is gone!

 

Thanks a lot!