Website Building » WooCommerce » How Do I Extract an Order in WooCommerce?

How Do I Extract an Order in WooCommerce?

Last updated on January 17, 2023 @ 2:00 pm

Do you have a WooCommerce store? Do you want to know how to extract an order?

When you run a WooCommerce store, there are times when you may need to extract an order. For example, if you need to cancel an order or if you need to refund an order. In this article, we will show you how to extract an order in WooCommerce.

What is an Order in WooCommerce?

Before we show you how to extract an order, let’s first understand what an order is in WooCommerce.

An order is a record of a customer’s purchase from your WooCommerce store. An order contains all the details of the customer’s purchase, such as the products they purchased, the shipping address, the billing address, etc.

How to Extract an Order in WooCommerce?

There are two ways to extract an order in WooCommerce. You can either do it from the WordPress admin panel or from the command line.

Extracting an Order from the WordPress Admin Panel

To extract an order from the WordPress admin panel, first, you need to login to your WordPress site and go to WooCommerce > Orders. This will take you to the Orders page where you will see all the orders placed on your WooCommerce store.

From here, you can either view the details of an order or extract it. To extract an order, simply hover over the order that you want to extract and click on the Extract link. This will open a popup where you can select the products that you want to extract from the order.

Extracting an Order from the Command Line

If you are comfortable with using the command line, then extracting orders from there can be a faster way for you. First, login to your server via SSH and go to your WooCommerce store’s directory. Once there, type in the following command:

wc_get_orders [–status=] [–order=].. [–limit=] [–offset=] [–fields=] [–return=]

  • [–status=<status>] – Status of orders that should be returned (default: ‘any’).
  • [–order=<order_id>]. – comma separated list of specific orders that should be returned.
  • [–limit=<limit>] – Limit number of orders returned (default: 10). Use -1 for no limit.
  • [–offset=<offset>] – Offset number of orders returned (default: 0).
  • [–fields=<fields>] – Limit fields returned by each order (default: all fields).

    Use ‘ids’ for only ‘order_id’ field.

  • [–return=<return>] – Type of data that should be returned (default: ‘data’). Valid values are ‘ids’, ‘objects’, or ‘raw’.

After running this command, you will see a list of all orders placed on your WooCommerce store. To view the details of an order, type in the following command:

wc_get_order <order_id> [–fields=<fields>] [–return=<return>]

This will return the details of the specified order. You can also use this command to extract an order by specifying the products that you want to extract. For example:

wc_get_order <order_id> –extract-products=”product1,product2″

This will extract products “product1” and “product2” from the specified order.

Conclusion

In this article, we showed you how to extract an order in WooCommerce. We hope this article helped you learn how to manage orders in your WooCommerce store.

Madison Geldart

Madison Geldart

Cloud infrastructure engineer and tech mess solver.