SOLVED::Get custom field to display in email messages

Hi,

I’m trying to get the custom field I have added to my cart.twig display in the merchant email.
In the cart.twig I have a text input for the customer to add notes about their product and this works as expected…

<label for="field-customer_notes">Please leave any instructions for your order here:</label>
<input type="text" id="field-customer_notes" name="customer_notes">

In the docs it says that the following should work to display the custom field in my order-to-merchant.twig:
{{ order_fields.customer_notes }}
I have disabled the commerce.save_sent_message_content in System Settings for quicker checking of the emails.
I’m assuming I’ve misunderstood a part of this?

Thanks

Janice

Do you see the field in the backend, on the order detail page?

No I don’t see it there Mark.

Hi Janice,

Are you using the “Custom Fields (Basic)” module to add the custom field?
https://docs.modmore.com/en/Commerce/v1/Modules/Custom_Fields_(Basic).html

If you’re not seeing the customer_notes field/value on the order detail page, it’s possible there’s a typo on the name of the field on the module configuration window.

It’s probably also worth checking the <input> tag you’re adding is inside the <form> tag in the cart.twig template. (I’ve accidentally overlooked that a few times)

It could also be the custom field is set on the wrong step on the module configuration page.

Hi Murray,
Yes I’m using the Custom Fields module.
Which twig file should I add {{ order_fields.customer_notes }} to in order to see it on the order detail page in the Manager?
I have only added it to the custom/emails/order-to-merchant.twig file so maybe I need to add it elsewhere.
The custom_field does display on the frontend by the way via the cart.twig file

Thanks for your help

All order fields are automatically added to the dashboard, so that suggests it’s not getting saved to the order - that’s why I asked. @digitalpenguin’s list of things to check is excellent.

I’ve just tried it on my installation. Module configuration:

frontend/checkout/cart.twig template:

and where it’s visible in the order detail page:

{{ order_fields.customer_notes }} is working as expected in both the front-end templates and the email templates. So it does seem likely to be a typo somewhere or the input not being in a <form> so not getting saved.

If you can’t find the problem, happy to take a look. If this is the site with the import I should still have the credentials, otherwise please email a login to support@modmore.com.

Thanks for all the help.
It appears I was doing everything correctly but the issue was possibly with a server issue and my changes weren’t saving. Once I restarted everything the following day it all worked as expected.