Skip Navigation

[Resolved] Add Custom Field to WooCommerce Order Details

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 3 voices.

Last updated by Waqar 5 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1167290

Tell us what you are trying to do? I have added a custom field to each WooCommerce each using the Custom Fields in Types. This field has an image reference number. I would like that field to show with the product information on the order details. It could be in the email notification I get as store owner, or the order details in the dashboard. Whichever is easier.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

#1167624

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

For this you need to customise WC itself using its own API.

There is a good description of adding the field to the checkout page (so that a value can be provided with the order), displaying the custom field on the WC Order admin page, and including the custom field in WC order notification emails starting here: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-7

Check that. I might be able to give you some pointers if you get stuck with a particular part.

Let me know how you get on.

#1167758

Where I get lost is that documentation seems to be related to adding a custom field to the order/checkout process. Which is not what I want or need. I have added a custom field to the product, which I use for administration and the customer does not see while placing their order. I want that field, however, to show up on the order email in the information about that particular product. It is my personal reference number (in this case it tells me where in my archives to find the specific image they are purchasing), different than a SKU (which is why I can't just use the SKU).

#1167927

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, I didn't quite understand.

Your products have a custom field, and you want to display this custom field in the emails sent by WooCommerce about the order or in the admin dashboard on the order edit screen.

That really sounds like a question for WooCommerce, the only information that is really pertinent to Toolset is that you should know that Types stores custom fields in wp_postmeta with a 'wpcf-' prefix, otherwise they are like a native custom field.

If you aim to manipulate either the order edit screen or the order emails, the relevant sections of that link I provided before still seem appropriate.

What's missing is that you need to duplicate the custom field you store on the product in the order, so that it is available to the order edit screen or order emails.

You need to start at the section in that link with the text "Finally, let’s save the new field to order custom fields using the following code:".

The value of the custom field you save you need to retrieve from the product contained in the order. Here is an example of how to get the product id from the order id, which you can then use to retrieve your custom post meta for that product: https://stackoverflow.com/a/45124188/1180189

So there are a few pieces to put together, but that's what is involved.

#1172266

I tried a couple things from that page and links but at this time implementing them seems above my skillset. I may need to pay someone to do it for me. Should we mark this ticket as closed?

#1172901

Hi Keith,

Nigel is away for holidays, but I'll be happy to follow up on this ticket.

If you'd like to hire a professional to assist you with custom programming tasks, you can check out our list of recommended contractors at:
https://toolset.com/contractors/

You're welcome to mark this ticket as resolved and open a new one for different question/concern.

regards,
Waqar

#1172903

[Status changed to "Waiting for user confirmation"]