0

I'm trying to modify the address template in Magento through admin>stores>configuration>customer>customer configuration>Address Templates> HTML

Can someone tell me the use of {{depend}} and {{if}} in the template or help me modify this one.

In the checkout page, I want to interchange the position of the postcode and city. Also, put the country on top of it and put the street below. This is the order:

  • Country
  • Postcode
  • Region
  • City
  • Street

This is the default:

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

This is my my modified version:

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

But it is not working.

enter image description here

0
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}{{depend firstname}}<br/>{{/depend}}
{{depend company}}{{var company}}<br />{{/depend}}
{{var country}}<br/>
{{if postcode}}{{var postcode}}<br/>{{/if}}
{{if region}}{{var region}}<br/>{{/if}}
{{if city}}{{var city}}<br/>{{/if}}
{{depend telephone}}T: {{var telephone}}{{/depend}}
{{depend fax}}<br/>F: {{var fax}}{{/depend}}
{{depend vat_id}}<br/>VAT: {{var vat_id}}{{/depend}}

I'm not an expert so not sure if this is going to work (and i don't have anything to test it with). But as far as i can see these rules apply : (source : depend and if/else in transaction emails)

  • If statement is used when you want it to output an else (not sure why magento uses it here)
  • Depend statements do the same thing but without the else

  • tags go before or after the var but always between the depend/if
  • A good line of code exists out of depend/if and a var (not sure why country does not have this)

Can you try this and give me feedback? Like i said i don't know anything about it but i would like to work it out together.

| improve this answer | |
  • I actually realized that I made a mistake. What I need to change is not the template but the checkout form address. – Dean Mar 21 '17 at 8:41

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.