How to add custom data to Order?

How to add custom data to Order?

giopetris
Shopify Partner
2 0 0

This is the most popular answer on this forum, but, I believe it only works on Shopify Plus stores. I'm trying to do the same in a non-plus store and can't get it working.

 

Is it possible to add custom order attribute for non-plus stores? If so, how can I do it? 

Replies 3 (3)

oliversinz
Shopify Partner
96 7 18

Hi @giopetris 

Hope you're having a great day!

 

If you need to add any additional data to order/cart - there are two ways whether it a Shopify Plus store or not.

- Add it in the order note

- Add it via cart attributes

Both of these can be done with JS/jQuery and Liquid objects.

 

Cart attributes

Cart attributes are custom form fields that let you collect additional information (custom data) from your customers on the cart page. The information that you collect will display in a note on the customer's order in the admin. For example, if you want to ask customers how they heard about your store, then you can add an How did you hear about us? drop-down selection question to the cart.

 

Order notes

You can use order notes to collect special instructions from customers about how to prepare and deliver an order. Order notes are submitted with a customer's order, and will appear on their order page in the Shopify admin. Order notes are referred to as cart notes in some themes.

Order notes can be enabled in the Cart theme settings. Refer to your theme's documentation for more information about how to find this setting in your theme.

 

Custom checkout attributes

Checkout attributes allow to customize Shopify checkout page. This feature is only available for Shopify Plus store.

 

So?

Order notes, cart attributes, and line item properties are three separate tools with similar functionality. Order notes let you capture special instructions on how to prepare and deliver an order. Cart attributes are custom form fields that you can use to collect additional information from your customers on the cart page. Line item properties are used to record customization information about specific products in an order. Line item properties are specified directly on the product page.

 

You should be more specific about what you are trying to achieve. Are you trying to edit checkout.liquid (checkout page)? add Order notes? etc.

 

Have a great day!

- Was my reply helpful then Click Like and Mark it as an Accepted Solution

- Feel free to contact me regarding any help on: Twitter | LinkedIn | My website



- Want to modify or custom changes on store Hire me.
Shopify Partner | Full Stack Software Developer
giopetris
Shopify Partner
2 0 0

Thanks so much for the reply @oliversinz ! I'll try to give you more context around what I'm trying to do:

 

Context: I'm currently plugging a custom payment provider into Shopify, the main flow is working great, user can select as a payment option, gets redirected to our app, and finishes the payment successfully by connecting into their bank account. 

User is then redirected to the Thank You/Order Status page, where I have a JS code that changes the subtotal to take into account the discount when the payment is done through our provider. Here's an example:
"original" subtotal (without the discount yet): $ 10

provider discount: $ 1

subtotal (after discount): $ 10 - $ 1 = $ 9

 

We could successfully edit the HTML in the Thank You/Order Status page to show the subtotal with discount ($ 9), the problem is that the email sent to the customer is not applying the discount yet, so, this is what I'm trying to do

 

I think the way to do it, is by persisting the provider_discount (100, which represents $1 in cents) and subtotal_after_discount (900, which represents $9 in cents) in the order, then render it in the email sent to the customer after completing an order. So, how can I do that?

There's a important thing to keep in mind is that this can only be persisted after payment has been done through our provider, since we don't want show it in the email sent to the client after completing a purchase when using different payment providers. 

 

Here's a breakdown of the most relevant attempts, and why they haven't worked so far:

 

- Cart attributes: I couldn't edit the cart attributes after completing the payment (in the Thank You/Order Status page), I tried by making a POST to /cart/update.js but it updates a new cart that is created after the order has been paid, not for the order the user is seeing in the Thank You/Order Status page;

 

- I tried adding <input type="hidden"  /> fields in the checkout page, but that didn't work. I think that is the Custom checkout attributes you mentioned that only work on Plus Shopify stores;

 

Am I missing something or doing something wrong? Is there a solution for Non-Shopify Plus stores do that? 

 

Thank you!

Sanluisero
Visitor
1 0 0

Hi

 

Your post above is very helpful. I am trying to add the ability to engrave one of my products when added to the car. I need to collect the customer's names. I want to be able to do it for this single product but per item. If the customer selects a quantity of 5 I want to be able to collect 5 different names. I want to do it on the product page as they increase the quantity rather than at check out as they may have other products there and I only need this feature for this specific product. 

 

Your help would be much appreciated.