Working with WooCommerce often means interacting with the $product object — the core data object that gives you access to product details like ID, SKU, price, stock, attributes, images and more.
If you want to build custom features, tweak templates or display product information anywhere on your site, knowing how to extract basic product data such as product ID, SKU and price is essential.
This guide serves up bite-sized code snippets that will give you an instant retrieval of these crucial pieces of information using either product IDs or SKUs.
Now imagine processing orders faster than lightning, filtering your product catalog like a pro and updating prices or doing stock management. This is precisely what we are going to help you achieve in just a few lines of code, even a coding novice can implement.
So, let’s get started!
Why do you need a product ID
Most WooCommerce store owners don’t think about product IDs while creating or displaying products — and usually, you don’t need to. But there are many situations where knowing the exact product ID becomes essential.
For example:
- Displaying a specific product elsewhere on your site: If you want to show a product inside a sidebar, a custom section or via a shortcode, you’ll need to pass the product ID so WooCommerce knows exactly which item to load.
- Creating custom product lists or grouped displays: When building curated collections (“Best Sellers”, “Staff Picks”, “Red T-Shirts”), certain tools and templates require product IDs to determine which items belong in the list.
- Using advanced filtering or automation: If you’re showing only products of a certain size, color, tag or category — or running custom queries — you often have to filter by product IDs behind the scenes.
In short, the product ID acts as a precise identifier, helping WooCommerce (and you) target the exact product needed for shortcodes, lists, filters, automations and custom workflows.
So, having outlined why knowing a particular product ID is useful for these situations, let us now look into the means of finding the WooCommerce product ID inside your online shop.
Getting product info from $product object via code
Sometimes, you might not have the product details ($product object) right away. You might need to get them in a different way, depending on what you’re doing.
In WooCommerce, product information lives in the WC_Product object — commonly available as $product.
As said earlier, you won’t always have direct access to it. Depending on your hook, action or screen, you may only have: the product ID or the order object or the cart object or the $post object.
- If you only have the product’s ID (
$product_id): You’ll need to use that ID to go and get all the product details. - On order pages or shopping cart pages: You often don’t have the product details directly. In these cases, you need to go through each item in the order or the cart to find the product details.
Once you finally have the product details ($product object), it’s easy to find things like:
- The price
- The product code (SKU)
- How many are in stock
You have access to $product variable
When you have access to the $product variable, you can easily retrieve product details.
Hooks like do_action and apply_filters often pass additional arguments to your function. But:
- If these include the $product object, you’re in luck – you can use it directly.
- If not, you can still access the product information by declaring “global $product” inside your function to make the $product variable available.
In both scenarios, you’ll be able to retrieve all the product details you need, such as SKU, price, stock and more. Here’s how you can do it:
// Get Product ID $product->get_id(); // Get Product General Info $product->get_type(); $product->get_name(); $product->get_slug(); $product->get_date_created(); $product->get_date_modified(); $product->get_status(); $product->get_featured(); $product->get_catalog_visibility(); $product->get_description(); $product->get_short_description(); $product->get_sku(); $product->get_menu_order(); $product->get_virtual(); get_permalink( $product->get_id() ); // Get Product Prices $product->get_price(); $product->get_regular_price(); $product->get_sale_price(); $product->get_date_on_sale_from(); $product->get_date_on_sale_to(); $product->get_total_sales(); // Get Product Tax, Shipping & Stock $product->get_tax_status(); $product->get_tax_class(); $product->get_manage_stock(); $product->get_stock_quantity(); $product->get_stock_status(); $product->get_backorders(); $product->get_sold_individually(); $product->get_purchase_note(); $product->get_shipping_class_id(); // Get Product Dimensions $product->get_weight(); $product->get_length(); $product->get_width(); $product->get_height(); $product->get_dimensions(); // Get Linked Products $product->get_upsell_ids(); $product->get_cross_sell_ids(); $product->get_parent_id(); // Get Product Variations and Attributes $product->get_children(); // get variations $product->get_attributes(); $product->get_default_attributes(); $product->get_attribute( 'attributeid' ); //get specific attribute value // Get Product Taxonomies $product->get_categories(); $product->get_category_ids(); $product->get_tag_ids(); // Get Product Downloads $product->get_downloads(); $product->get_download_expiry(); $product->get_downloadable(); $product->get_download_limit(); // Get Product Images $product->get_image_id(); $product->get_image(); $product->get_gallery_image_ids(); // Get Product Reviews $product->get_reviews_allowed(); $product->get_rating_counts(); $product->get_average_rating(); $product->get_review_count();
You have access to $product_id
If you have access to the product ID (once again, usually the do_action or apply_filters will make this possible for you), you have to get the product object first. Then, do the exact same things as above.
// Get $product object from product ID $product = wc_get_product( $product_id ); // Now you have access to (see above)... $product->get_type(); $product->get_name(); // etc. // etc.
You have access to the Order object or Order ID
In this case, you will need to loop through all the items present in the order and then apply the rules above.
// Get $product object from $order / $order_id
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
$product = $item->get_product();
// Now you have access to (see above)...
$product->get_type();
$product->get_name();
// etc.
// etc.
}
Accessing product information within orders is incredibly beneficial. By looping through order items and retrieving product details, you can:
- Create detailed invoices with complete product specifications
- Add important factors such as SKU, weights and dimensions to shipping
- Add special handling instructions for fragile or heavy items.
- Calculate lead times for the custom manufacturing of products
- Measuring precise locations inside a warehouse for an item
- Automated shipping recommendations based on order content, etc.
You have access to the Cart object
How to get the product information inside the cart? In this case, once again, you will need to loop through all the items present in the cart and then apply the rules above.
// Get $product object from Cart object
$cart = WC()->cart->get_cart();
foreach( $cart as $cart_item_key => $cart_item ){
$product = $cart_item['data'];
// Now you have access to (see above)...
$product->get_type();
$product->get_name();
// etc.
// etc.
}
Imagine you’re building a special message that appears in the shopping cart, like “Free shipping on orders with 3 or more t-shirts!”
To show a message like “Free shipping on 3+ t-shirts,” your code needs to check every item in the cart to count the t-shirts. Without this, it wouldn’t know what’s in the cart.
You have access to $post object
In certain cases (e.g. the WordPress admin side or backend), you can only get access to $post. So, how do we “calculate” $product from $post?
Here’s how:
// Get $product object from $post object $product = wc_get_product( $post ); // Now you have access to (see above)... $product->get_type(); $product->get_name(); // etc. // etc.
Imagine you’re in the WordPress admin, looking at a list of all your website pages and products. WordPress shows everything as a general “post.”
If you want to do something specific to a product on that list – like change its price or see its stock – you first need to tell WordPress, “Hey, this ‘post’ is actually a ‘product’!” The $post object is the general info, and using wc_get_product($post) is like saying, “Calculate the specific ‘product’ details from this general ‘post’ info.
How do I find WooCommerce product ID without coding?
You can also get the WooCommerce product ID using three simple ways:
WordPress backend
- Log in to your WordPress Admin panel dashboard.
- Click on
Products > All Products. - Hover on each product row and you’ll get the product ID.

Edit product URL
Open any product to edit. You’ll find the product ID in the URL as “post=X”.

Finding product ID with the Smart Manager plugin
Finding product IDs manually is slow when you have hundreds or thousands of products. Thousands of store owners use Smart Manager for efficient product management.
Smart Manager gives you:
- A spreadsheet-like interface
- Product ID, SKU, price, stock, categories… all in one table
- Instant search
- Bulk actions
- Sorting, filtering, exporting
It removes endless clicking and enables powerful store management from a single screen.
Think of it as an all-mighty spreadsheet to manage your store. You have instant access to truckloads of information in a manner that makes sense.
Say goodbye to wasting precious hours and hello to an altogether different, smoother, faster way of running your shop – from one simple screen!

How to make WooCommerce inventory management efficient with Smart Manager
Here’s how Smart Manager, with its Excel-like sheet editor, simplifies product and inventory management:
Bulk editing is made powerful
- Eliminate tedious one-by-one product editing with fast, spreadsheet-like bulk actions.
- Update prices, stock levels, categories, visibility and other fields in seconds.
- Add, edit or delete hundreds of products at once — including variations.
- Apply strategic sale prices in bulk based on regular prices.
- Add or modify product attributes for hundreds of products with a single action.
Advanced SKU management
- Search products or variations instantly using simple or advanced SKU lookup.
- Bulk edit SKUs or duplicate products while automatically adjusting SKUs.
- Let vendors search SKUs and manage stock easily.
- Sort or export products by SKU for audits and planning.
- Find related orders or subscriptions directly using the SKU search.
Smart filtering and data views
- Hide or show columns to focus only on the data you need.
- Sort products by SKU, name, price, stock level or any field before performing actions.
- Create clean, customized views for focused workflows.
Category and shipping class control
- Bulk add, update or remove product categories.
- Quickly assign or modify shipping classes across large catalogs.
- Use filters to target only specific products for updates.
Fast, flexible exporting
- Export complete WooCommerce product data to CSV — including variations, images, categories, stock, custom fields and more.
- Apply filters before exporting to get exactly the dataset you want.
Accurate inventory and stock management
- Supports WooCommerce inventory control for all product types — simple, variable, downloadable, affiliate and more.
- Real-time stock updates ensure quantities remain accurate as orders come in.
- Easily manage backorders and stock statuses from one screen.
Like products, you can also manage and bulk edit orders, coupons, posts, pages, users and any WordPress post type.
Conclusion
If you’re comfortable with hooks and PHP, WooCommerce provides flexible ways to retrieve product IDs, SKUs, prices and other product data via $product, $product_id, carts, orders and posts.
But if you want a much faster, code-free way to manage products, filter data, bulk update pricing, duplicate, edit SKUs or export product info — Smart Manager is the easiest and most efficient solution.
You’ll save hours of time and avoid countless mistakes.
FAQ
How do I get the product by SKU in WooCommerce?
Go to WordPress admin > Products. Click on any product to edit it. Scroll down and click on the Inventory tab to find or add the product SKU.
Can I find a product ID with an SKU number?
Yes.
How do I get the product image from a product ID in WooCommerce?
All you need to do is use the WordPress wp_get_attachment_url() function. The wp_get_attachment_url() function accepts an attachment ID as its only parameter. So, all you need to do is pass in the product ID and you’ll be able to get the URL of the product image.
