If you’re running a WooCommerce store, there are a few different places you can find your product ID. The product ID is a unique number that is assigned to each product in your store, and is used to identify the product in your database. Here are a few places you can find the product ID in WooCommerce:
1. On the product edit page in your WordPress admin panel, the product ID will be displayed in the URL of the page.
For example, if you’re editing the product with an ID of 1234, the URL of the page will be something like this: http://yourstore.com/wp-admin/post.php?post=1234&action=edit. As you can see, the number at the end of the URL is the product ID.
2. If you’re using the WooCommerce REST API to work with products in your store, each product will have a “id” property that contains its product ID. For example, here’s a sample JSON representation of a product from the WooCommerce REST API:
{
"id": 1234,
"name": "Sample Product",
"sku": "123456",
..
}
3. If you’re using the WooCommerce Product CSV Import Suite to import products into your store, each product in the CSV file will have a “ID” column that contains its product ID.
4. If you’re using the WooCommerce CLI, you can use the wc post list command to list all products in your store, along with their post IDs. For example:
[user@host ~]$ wc post list --type=product --format=ids
1234
1235
1236
5. Finally, if you need to find the product IDs of products that have been ordered by customers, you can use the wc_get_order_items() function.
This function accepts an order ID as its only parameter and returns an array of order items (which includes products). Each order item has a “product_id” property that contains its product ID.
How Do I Find The Product ID In WooCommerce?
There are a few different places you can find your product ID in WooCommerce. The Product ID is a unique number assigned to each product and is used to identify it within your database.
- On The Product Edit Page
In your WordPress admin panel, go to Products > All Products and select Edit under any given product. The Product ID will be displayed as part of that products URL. - REST API
If you’re using REST API to work with products in your store each one will have an “id” property that contains it’s Product IDs. - Product CSV Import Suite
If you’re using this tool to import products into your store then each one within your CSV file will have an “ID” column containing it’s Product IDs. - WooCommerce CLI
If working with products via WooCommerce’s command line interface then from within terminal (mac) or command prompt (PC) enter “wc post list –type=product –format=ids” which will list all Products along with their Post IDs.
To find the product ID in WooCommerce:
1. Go to Products > All Products in your WordPress dashboard.
2. Hover over the product you want to find the ID for and click Edit.
3. In the Product Data section, look for the SKU field. The number in this field is the product ID.
Finding A Customer’s Ordered Products
To find which products have been ordered by customers use WooCommerce’s wc_get_order_items(). This function requires an Order ID as it’s only parameter and will return an array of Order Items (which includes Products). Each Order Item has a “product_id” property containing it’s Product ID.
Conclusion
In short, there are five different ways that you as a store owner or administrator can find a given Products ID number within WooCommerce.