WooCommerce: Order Meta with HPOS and API

code, data, programming code, computer programming, information technology, technology, security, development, php, it, website development, connection, blue data, blue website, blue security, blue code, blue coding, blue programming, php, php, php, php, php

In a recent Business Bloomer Club Slack thread, a member raised an important question about WooCommerce HPOS (High-Performance Order Storage) and API compatibility.

Their developer had built a custom integration using the legacy WooCommerce API, and one of the key operations was saving metadata to orders. This metadata was used to associate internal order numbers from a third-party system.

With WooCommerce shifting toward HPOS for order management, the member wanted to confirm if their integration would require changes — especially when saving order meta. If the current implementation uses functions like $order->update_meta_data(), would that still work seamlessly with HPOS?

This is a common concern for developers who rely on programmatic access to orders, especially when orders are linked to external systems. The good news is that HPOS is designed with backward compatibility in mind, but certain practices need a closer look. Let’s go through what changes, what stays the same, and how to future-proof your API integrations.

Continue reading WooCommerce: Order Meta with HPOS and API

WooCommerce: Search Orders By 2-Letter Country Code [HPOS]

WooCommerce’s order search function is essential for store admins, but with the introduction of High-Performance Order Storage (HPOS), searching by billing or shipping country code may no longer work as expected.

If you’re used to quickly filtering orders by country, this limitation can be frustrating. Fortunately, there’s a simple way to bring back this functionality using a custom code snippet.

In this post, we’ll walk through how to modify the WooCommerce order search to support two-letter country codes, making it easier to find the orders you need. Let’s dive into the solution!

Continue reading WooCommerce: Search Orders By 2-Letter Country Code [HPOS]

WooCommerce: Get List of Users Who Purchased a Product ID

This time around we’ll take a look at some SQL. As you know, WooCommerce orders (same as WooCommerce products) are stored in the WordPress database.

Instead of using complex PHP loops and conditionals, sometimes knowing a bit of database “reading” can help. I took some inspiration (because I don’t know everything by heart) from the wc_customer_bought_product() WooCommerce function, which contains some SQL to check if a user has purchased a given product.

I’ve played a little with the same SQL SELECT call, and managed to return the list of user email addresses who have purchased a specific product ID. If you’re ever going to need this, enjoy!

Continue reading WooCommerce: Get List of Users Who Purchased a Product ID