Custom Text Field On Cart / Add Text Entered Into Order Confirmation

Custom Text Field On Cart / Add Text Entered Into Order Confirmation

jkeef24
Visitor
3 0 0

Hello,

 

I have a message field where customers can provide a “gift message” on the cart page of my Shopify store, which is running the dawn theme. 

The text entered by the customer currently appears on their order within the Admin— this is perfect, but I’d like to also include this in both the order confirmation email as well as the staff notification email. 

Is there possibly someone who can assist me, please?

Reply 1 (1)

Liam
Community Manager
3108 341 880

Hi Jkeef,

 

It should be possible to achieve this using cart attributes, which are accessible in email notifications as an order property:

 

 

On the cart page, where customers are entering in the custom gift message text, you'll need to make sure this is being saved as an attribute of the cart, which then gets transferred to the order attributes. The code of the element could look something like this:

 

 

<textarea
  class="text-area field__input"
  name="attributes[gift-message]"
  form="cart"
  id="Cart-note"
  placeholder="{{ 'sections.cart.note' | t }}"
>{{ cart.note }}</textarea>

 

The important part here is the `name="attributes[gift-message]"` property. Then you'll be able to access this in email notifications by adding `{{ attributes.gift-message }}` 

 

Then when you can enter a message into the text input:

 

This will populate across to the email: 

 

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog