Solved

Record additional Product detail in Order upon checkout (Metafield, Cart Attributes or Line Item)

booter9898
Tourist
10 1 1

I'm trying to work out how I can transfer additional, non Customer defined, Product detail to an Order when a customer makes a purchase.

 

Background
I run a single product business which sells eggs locally. Customers sign up to receive a deliery of eggs either once, or on subscription every 1, 2 or 3 weeks.

 

Customers cannot choose when to receive their delivery. Instead a customer's postcode will determine the day of the week that they receive their delivery.

 

In the first step of the checkout flow, a customer enters their postcode. They are then redirected to the Product page relating to their deliery day (eg Eggs for Thursday delivery).

 

I have created a product for each day of the week (eg Eggs for Monday delivery, Eggs for Tuesday delivery etc).

 

Customers can only buy one product, and they only see the product which delivers to their area. When a new order is created, I need to somehow record the Delivery Day (eg Monday, Tuesday etc) as a discrete value in the order. 

 

What I'm seeking to understand is whether I can achieve this with Metafields, or whether I need to look at alternatives such as Cart Attributes or Line Items.

 

Thank you.

Accepted Solution (1)
booter9898
Tourist
10 1 1

This is an accepted solution.

Ok, this is now resolved. @Made4uo-Ribe your very helpful contribution above got me most of the way there. I also used this very helpful video.

 

The fix (including incorporating the metafield) was to insert the following into the relevant Product Page using a piece of Custom Liquid code:

 

<input type="hidden" name="properties[Delivery day]" value="{{ product.metafields.custom.delivery_day.value }}">

View solution in original post

Replies 5 (5)

Made4uo-Ribe
Shopify Partner
6394 1535 1905

Hi @booter9898 

 

I assume that every product page is different for each delivery day? If so, you can pass a product line item in the order. You can read more information here. You can then assign the value base on the product delivery day. You can have this hidden in the customer view, but available at the admin order page. 

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free.
booter9898
Tourist
10 1 1

Yes, that is correct. Each day of the week has its own product page.

 

Thank you for that suggestion. It sounds as if it might do what I need it to. Are you able to offer any suggestions as to:

 

1) how to prefill/assign the value for that field; and

2) hide that field from customer view?

 

Thanks again.

Made4uo-Ribe
Shopify Partner
6394 1535 1905

Hi @booter9898 

 

You can paste the following code to the corresponding products inside the product form. Placement depends on what theme you are using. 

NOTE: You can see the value differs

 

For Monday product:

 

<input type="text" name="properties[_Delivery day]" value="Monday">

 

 

For Tuesday product:

 

<input type="text" name="properties[_Delivery day]" value="Tuesday">

 

 

 

Please don't forget to Like and Mark Solution to the post that helped you. Thanks!

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free.
booter9898
Tourist
10 1 1

Amazing. Thank you so much. 

 

I have created a Product metafield (product.metafield.custom.delivery_day) and added the Delivery Day for each Product. 

 

If I were to insert the code you provided into the Product page template, rather than 'hard coding' the delivery day for each product, is it possible to populate the line item field with the value of the product.metafield.custom.delivery_day metafield?

booter9898
Tourist
10 1 1

This is an accepted solution.

Ok, this is now resolved. @Made4uo-Ribe your very helpful contribution above got me most of the way there. I also used this very helpful video.

 

The fix (including incorporating the metafield) was to insert the following into the relevant Product Page using a piece of Custom Liquid code:

 

<input type="hidden" name="properties[Delivery day]" value="{{ product.metafields.custom.delivery_day.value }}">