Archives by year: 2022

2022 Year in Review

Looking back at 2021 year right now, I see that it was one of the greatest years but it ended up in chaos and depression and huge amount of time in 2022 I spent just trying to figure it out.

But anyway 2022 was a year of unexpected travels and hard work mode. I have done a lot of things I was struggling (or postponing) to do for years! Have visited 7 new countries and first time in my life tasted how it is to be a digital nomad.

Multisite Product Sync for WooCommerce

Below, I will show you two ways of configuring WooCommerce multisite product sync between stores within a single WordPress multisite network – with the Simple Multisite Crossposting plugin and without any plugins as well.

But please keep an important thing in mind – if you’re not using your WooCommerce stores as part of a WordPress Multisite network (or maybe you’re just not exactly sure what it means), then check this article instead. Though the idea and the process will be similar in that case, the tools and functions in the code will be completely different.

Using REST API to Sync Users Between Remote Sites

In this post we are going to talk about REST API, particularly about how to sync user registrations, profile updates and removals between two remote WordPress websites.

How to Create Product Variations Programmatically

There is also a tutorial on my blog about creating products programmatically where I slightly cover the product variations.

But there are still a couple moments I would like to discuss more thoroughly, I came to them when I was doing the variable products crossposting for my multisite crossposting plugin.

Get Product (or Variation) by SKU

In this tutorial, I will show you how to get a product or a product variation object in WooCommerce if you only know its SKU. When we just need to get a product object by ID, we use the wc_get_product() function – super-easy, right? But if we only have an SKU, it is going to be a little bit more interesting.

So, I am going to show you four different ways how you can obtain a product object from its SKU, we are going to do it both the WooCommerce way (with WP_Product_Query and wc_get_product_id_by_sku() function) and the WordPress way (with WP_Query). Also, I will show you how to do it when you interact with the WooCommerce REST API.

How to Add Custom Fields to Variations in WooCommerce

Some time ago, I published a tutorial about adding custom fields to products. I covered variable products there; however, I didn’t cover adding custom fields specifically to variations of variable WooCommerce products.

Now, I decided that it is time to dive deep into custom fields for variations as well, at least because recently I’ve been adding one to my Inventory Sync for WooCommerce plugin:

Example of adding a custom field to WooCommerce variations
My plugin adds this product variation field, which allows you to decide whether to exclude this specific variation from the stock sync or not.

In this tutorial, we’ll learn how to work with WooCommerce’s custom fields for variations. Since the new WooCommerce product editor is still in development, I’ll show you examples of how to do it only for the classic product editor, which is widely in use, by the way.

How to Update Post Meta with WordPress REST API

This tutorial is an addition to my another tutorial about creating posts using REST API in WordPress, because in that post I didn’t mention how to work with meta fields. So now we’re going to add (or update) meta fields of a specific post with the help of REST API requests.

By the way, the whole process is similar when you work for example with term meta, not only with post meta.