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

In this tutorial I am going to show you two ways how you can sync your WooCommerce products between stores within a single WordPress multisite network.

Under two ways I mean this:

  1. In code with the help of the woocommerce_update_product action hook, the switch_to_blog() function and CRUD layers (in case we’re working not with a multisite network but with standalone WooCommerce stores, then we need to use REST API, there is a separate tutorial about that).
  2. With the plugin (just install and here we go).

Below is an example of how it can be implemented on your store with my plugin:

WooCommerce multisite product sync
Just select some of the connected WooCommerce stores you would like to sync this specific product with.

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. It is easy-peasy when we get a product object by ID, we just have to use wc_get_product() function, but we can not pass SKU to that function.

So I am going to show you three different ways how you can obtain a product object from SKU, we are going to do it both WooCommerce-way (with WP_Product_Query and with wc_get_product_id_by_sku() function) and WordPress-way (with WP_Query).

How to Display Variations with Color (or Size) Buttons

In this tutorial I will show how you can change the way the variation selection is working on the product page in WooCommerce.

We all know that by default the variations are displayed like a select dropdown.

default variation switcher on WooCommerce product page
Wouldn’t it be better to use color swatches here?

But today we will learn how to display them as color swatches. If you would like to display them as size buttons or custom images, you can do it with my plugin.

This is our goal for this tutorial:

WooCommerce display color variations with buttons

How to Add Custom Fields to Product Variations

Long time ago I published a tutorial where I described how to add custom fields to WooCommerce products. Now it is time to dive deep into product variations and add a couple settings fields there as well.