#475 How to replace [BILLING_STATE] with the Zone Code in email templates?

Posted in ‘Technical Support / Bugs’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by Antonio Cornacchia on Friday, 03 October 2025 13:54 UTC

Antonio Cornacchia

Hello

is it possible to replace [BILLING_STATE] with the Zone Code in email templates?

Thanks

Olivier

Hello,

have you tried [CUSTOM_BILLING_FIELD:ZONE_ID]? I believe this will return the id of the zone code, therefore it will be necessary to create an advanced template file where would could have the retrieval of the code from the id through a database call.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Hello

using [CUSTOM_BILLING_FIELD:ZONE_ID]  in the email does not produce any results, neither the zone nor its code.

Olivier

Ok.

In the advanced template, you have access to the $order object.

I believe you can get the id for the zone with $order->billing_zone_id.

A database call can then be made to get the code corresponding to this id.

Let me know if you can see the zone id when adding <?php echo $order->billing_zone_id ?> to the template.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Hi

using JCE, it removes the code from the template. So, using the code view I added it after [BILLING_COUNTRY], in the test email I simply get: billing_zone_id ?>

Anyway, is zone_id the Zone Code, that is what I need?

Olivier

You have to be using the advanced template file, not the simple template editor. The advanced templates uses a code editor so there is no removal of code there.

Once you are able to see the id, then we can go to the next step and do a database query and actually get the code of the zone.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Olivier, what do you mean with advanced template file? Not the J2commerce / Design / Edit email template / Advanced setting I suppose.

Olivier

Hi Antonio, you cannot add PHP in this version of the email template. 

I am talking about the advanced templates, not the advanced settings.

In the 'Basic settings' tab, go to the 'Template editor' option and select 'Advanced template file'. This is higher level, and requires some coding knowledge, though. Most people stay on the simple editor, which is much easier to use.

So the trade off: 

  • keep the simple editor and use the allowed short codes only,
  • use the advanced editor and allow other elements to be added to the email.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Thank you Olivier but I don't see any Template editor in Basic settings tab.

Olivier

I apologize if I was unclear... When you open an email templates, in the basic settings of the email template itself.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Hi Olivier, it is what I did.

into the test email I get the code, please look at the attached screenshot.

Olivier

Thanks Antonio,

you won't get any positive result if you use the simple editor, because the PHP is not interpreted in this 'what you see is what you get' environment. That is why, to modify code through php, you need to use the advanced editor (https://docs.j2commerce.com/design/email-templates#how-to-create-an-email-template-). On that page, we explain you can use the simple editor (recommended for casual users) and the advanced template files, which you can add php to, for advanced users. In the screenshot, the 'Template editor' option is what you need to change. However, if you don't know php, this is going to be more confusing for you.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Hello Oliviaer, I finally figured out where and how to select the advanced editor; I was confusing it with the advanced settings.
Thank you, I'll try to figure out if it's something I can do or not.

Olivier

Super, Antonio!

Yes, let me know if that is too complex.

If you figure it out, let me know and I can then give you the code to call the database and retrieve the zone code from the zone id.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Hi Olivier, I added to the default template for testing (I also added "8888" to make sure the changes are applied). I sent a test email and didn't get anything more than the usual address (apart from 8888, as you can see in the screenshots).

Don't you think a Zone_Code shortcode would be the most logical solution? Thanks

Olivier

I will add this as a request for improvement for a future release, Antonio.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Antonio Cornacchia

Thanks a lot.

Stay Updated

Subscribe for free and be the first to know about the latest features, updates, and new additions.