WooCommerce get product information by id

Today we talk about how in WooCommerce get product information by id? In our example, we will get product information like name, type, description, short description, SKU, modify date, create date, and status. WooCommerce uses the wc_get_product function to get the product information. So let’s start with our example.

$p_id = 20;
$product_info = wc_get_product( $p_id );
 // Get Product ID
$product_info->get_id(); // get product id
$product_info->get_type(); // get product type
$product_info->get_name(); // get product name
$product_info->get_slug(); // get product slug
$product_info->get_date_created();  // get product created date
$product_info->get_date_modified();  // get product modify date
$product_info->get_status();   // get product status
$product_info->get_catalog_visibility(); // get product visibility
$product_info->get_description(); // get product description
$product_info->get_short_description(); // get product short description
$product_info->get_sku();   // get product sku

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!