Show the metafield value of a product in the admin order page

Show the metafield value of a product in the admin order page

TheChosen
Visitor
1 0 0

Hi,

i am new to shopify and i need to use a product metafield to be shown in the order admin page.

Our sku does not relate to our warehouse storage bin location. 
So I want to store my bin location in a metafield per product. 

If a customer orders a product I need to show the value of the metafield in the admin order page.

How can I solve this problem?

Replies 10 (10)

gr_trading
Shopify Partner
1891 145 199

Hi @TheChosen ,

 

Please follow below steps

From Shopify dashboard, go to Online store > Themes > Edit code

In the search box, search for the file named main-product.liquid

Scroll to line no 431 of this file, and paste below code just after the {%- form 'product', product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}

<input type="hidden" name="properties[warehouse location]" value="{{ product.metafields.custom.material }}" />

 

Change product.metafields.custom.material with your field name.

 

Then this field will available to order list.

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
Joey1919
Tourist
3 0 2

Does this method still work in the latest Online Store 2.0? If not, I need help!

davidducrest
Visitor
1 0 0

Hey @Joey1919 the response from Hari1_prasad has nothing to do with the post's question. 

Modifying the theme will only change the store's front end experience, not the Admin pages. (e.g. https://admin.shopify.com/store/{your-store}/orders

I'm hunting for the same solution to modify the columns on the Admin/Orders page

gr_trading
Shopify Partner
1891 145 199

Hi @Joey1919 ,

 

Yes, @davidducrest is right my code would not help if you want to add new column in Shopify admin order listing page.

 

But my code will add a field of warehouse at order details page.

 

As your my understanding you prime concern is understand from which warehouse you have to ship the product.

 

If you want to add column in order listing you have to code for adding warehouse location tag in every order. Which will be available in order listing as separate column.

 

Let me know if you need more detail.

 

And about working in online 2.0, yes my code will work in it.

 

Hope it helps...

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
as01
Tourist
4 0 2

Hi Hari1_prasad,

 

in the main-product.liquid page I could not find the line 

 {%- form 'product', product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}

 

instead there is a form at line 114 that says

{%- form 'product', product, id: product_form_installment_id, class: 'installment caption-large' -%}

 

I added this as you have suggested

 

<input type="hidden" name="properties[warehouse location]" value="{{ product.metafields.custom.warehouse_location }}" />

 

The value is also coming when I check the "view source" but there is no value in the admin order page detail page. What am I doing wrong? Please help

gr_trading
Shopify Partner
1891 145 199

Hi @as01 

 

Assuming you have already created product level metafield.

 

Just want to be confirmed have to assigned metafield value in product??

 

About the code location can't say anything without checking your store URL.

 

Make sure you assign metafield value in product in Shopify admin.

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
as01
Tourist
4 0 2

Hi @gr_trading 

 

Thanks a lot for your quick reply. To confirm your points

 

Yes, the product level meta field is created

And I have assigned a value for that meta field. I have attached a screenshot for your reference.

metafield-product-demo.PNG

When I view source the page I can see this value appearing as well

 

<form method="post" action="/cart/add" id="product-form-installment-template--19101421207873__main" accept-charset="UTF-8" class="installment caption-large" enctype="multipart/form-data">

<input type="hidden" name="properties[warehouse location]" value="NY" />

<input type="hidden" name="form_type" value="product" />
<input type="hidden" name="id" value="45143583916353">
...
...

As you can see <input type="hidden" name="properties[warehouse location]" value="NY" /> is showing 

 

Now for showing it to the admin order page do I need to make any changes? If yes, then could you please tell me where?

 

Thanks again 

truemoroz1
Shopify Partner
3 0 0

Did you find the solution?

 

truemoroz1
Shopify Partner
3 0 0

This code only shows metafield on product page, not on order page in admin area

 

gr_trading
Shopify Partner
1891 145 199

Seems you are putting the code at wrong place.

 

We can do this setting for you request you to connect over the WhatsApp.

 

Details are in post footer 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee