Cross-sell products from the Thank You page with a Coupon applied

Custom Product Meta

In this tutorial we are going to talk about how to add custom fields to WooCommerce products. I am not going to talk about plugins here – we will work with code snippets only and all the additional fields will be added to “Product Data” metabox.

Please also keep in mind that WooCommerce allows to hide or display specific product fields depending on a product type. So for example we can show our additional product fields only for “Downloadable” or “Variable” products.

Just like that:

WooCommerce custom product meta
As you can see we added a product field into “Advanced” tab, then we created a conditional “Misha” custom tab and added some additional custom product fields there as well.

WooCommerce REST API: Create Products with Attributes

Before all I also recommend you to check my basic WooCommerce REST API tutorial, where we just created and updated some simple products.

Right now I am going to show you two more specific examples. Two – because there are two types of attributes in WooCommerce – custom attributes and the ones that created in Products > Attributes menu (those are technically taxonomies).

Create and Update Products with WooCommerce API

Recently I was publishing and updating the tutorials about WordPress REST API, how to create a post, how to add a featured image and so on. But did you know that WooCommerce has its own API which is build on the base of a regular WordPress REST API but allows to do much more things and also simplifies the work with the other ones.

In this tutorial we are going to dive into actual examples of working with WooCommerce API, I will show examples of creating and updating products, and also we will try to search them by SKU and delete them.

One more thing – I am a big fan of using WordPress HTTP functions like wp_remote_get() and wp_remote_request(), so we are going to use them below. So no additional steps are needed like installation of a PHP library or anything else.