Skip to Content

New J2Commerce 6.6.5 is out. Here is everything in the release.

See What’s New
Account
Enter the email address on your account.
Forgot your username?
Enter your password.
Forgot your password?

Or continue with

Pending Public Category: Technical Support / Bugs Ticket #1087

Use field queries in the form designer

This is a public ticket

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

J2Commerce

Version
J2Store/J2Commerce v4

Conversation

Jörg Müller

Hi,

is it possible to use field queries in the form designer, e. g. If field Country = Germany then do not show?

Regards Jörg

Olivier Buisard Staff

Jörg,

I am not sure if you are asking for email templates or invoice templates.

In any case, J2Store 4 does not offer if/if not conditioning in it's editor.

What is your use case? Maybe just an override would be enough.

Olivier.

Jörg Müller

Hi Olivier,

It's all about billing templates. Every now and then is sold in EU countries. In these cases it would be very nice (but not necessary) if the country also appears in the bill.
For the many German customers, however, "Germany" should not be the recipient country.
At present, the country is written by hand on the invoice for the few EU customers.
An override might solve this, but that's not so mine.

Regards Jörg

Olivier Buisard Staff

Ok, there are quite a few places where changes would need to be made, but if you want to restrict the change to email, you would have to use the advanced template file for the email you want to modify in 'email templates'.

Then in the file, you would add, at the beginning:

$orderinfo = $order->getOrderInformation();

Then you would replace the line with [BILLING_STATE] with:

<p>[BILLING_STATE] <?php if ((int) $orderinfo->billing_country_id !== 81) : ?>[BILLING_COUNTRY]<?php endif; ?></p>

 

Olivier.

Jörg Müller

This is the source code of the extended billing template

<table style="width: 97%; float: right;" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr valign="top">
<td><img style="float: right;" src="https://www.frauenprojekt-kenia.de/images/logo_frauenprojekt-text_208x50.jpg" width="208" height="50">
<p style="text-align: left;"><span style="font-size: 10pt;">Engel für Afrika - Christine Rottland - Geisselstrasse 95 - 50823 Köln<br>USt-Id DE276682923</span></p>
<p style="text-align: left;"> </p>
<hr></td>
</tr>
<tr valign="top">
<td><span style="font-size: 8pt;">Engel für Afrika - C. Rottland - Geisselstrasse 95 - 50823 Köln<br><br></span>
<p><span style="font-size: 10pt;">[BILLING_COMPANY]<br>[BILLING_FIRSTNAME] [BILLING_LASTNAME]<br>[BILLING_ADDRESS_1] </span><span style="font-size: 10pt;">[BILLING_ADDRESS_2]<br>[CUSTOM_BILLING_FIELD:adressenzusatz]<br>[BILLING_ZIP] [BILLING_CITY]<br>[BILLING_STATE] <br></span></p>
</td>
</tr>
.....

<tr valign="top">
<td>
<p><span style="font-size: 8pt;"><img style="float: right;" src="https://www.frauenprojekt-kenia.de/images/asante-logo-150x34.jpg" width="150" height="34"><strong>Mit Ihrer Bestellung unterstützen Sie den Verein <a href="https://asante-ev.de/" target="_blank" rel="noopener noreferrer">Asante e.V.</a><br>Der Erlös aus dem Verkauf der Engel fließt nach Abzug aller Kosten komplett an den Verein!</strong></span></p>
</td>
</tr>
</tbody>
</table>

When I add to the beginning:

$orderinfo = $order->getOrderInformation();

and this at the line with [BILLING_STATE]

<p>[BILLING_STATE] <?php if ((int) $orderinfo->billing_country_id !== 81) : ?>[BILLING_COUNTRY]<?php endif; ?></p>

these program lines appear in the output.

Am I in the right place?

Attachments

Invoice-Template.png
Olivier Buisard Staff

Hello Jörg,

no, you can only do that in the advanced tempate. Right now you are in the simple editor (Basic settings tab, 'Template editor' parameter). You cannot add code in the view you tried it on.
If you have many changes, makes ure you keep a copy of the original view so you can copy and paste your changes to the advanced template.
You have to make sure the advanced template suits you, it is a more 'raw' view of the email, less user friendly but much more flexible.

Olivier.