WooCommerce Product Functions

WooCommerce Product Information

More than 100 product functions to get and check details of WooCommerce Product

This article contains all the necessary product functions that are required to deal with any type of product. It helps to write snippets in PHP, and develop plugins and themes for WooCommerce.

Get Information by product object

Get product by product Id

$product_id = 10;
$product      = wc_get_product( $product_id );

Get Product Type

echo $product_type = $product->get_type();

Get Product Name

echo $product_name = $product->get_name();

Get Product Slug

echo $product_name = $product->get_slug();

Get product Title

// Get Product title by product object.
echo $product_name = $product->get_title();
// Get product title by product id.
echo get_the_title( $product_id );

Get product children

// Get product children of variable and grouped products
$children = $product->get_children();
print_r( $children );

Get Price HTML

// Get porduct price html of variable, variation, composite, subscription and grouped product.
$price_html = $product->get_price_html();
// Get product price of simple product and display on shop.
$price_html = wc_price( wc_get_price_to_display( $product ) );
// Get product price including tax and excluding.
$incl_tax_price  = wc_get_price_including_tax( $product );
$excl_tax_price = wc_get_price_excluding_tax( $product );

$incl_tax_price_html   = wc_price( $incl_tax_price );
$excl_tax_price _html = wc_price( $incl_tax_price );

Get formatted Name

// Get product name with SKU or ID.
echo $product_formatted_name = $product->get_formatted_name();

Get Minimum Purchase Quantity

// Get min quantity which can be purchased at once.
echo $min_quantity= $product->get_min_purchase_quantity();

Get Maximum Purchase Quantity

// Get max quantity which can be purchased at once.
echo $max_quantity= $product->get_max_purchase_quantity();

Get Add to cart URL

// Get the add to url used mainly in loops
echo $product->add_to_cart_url();

Get add to cart button Text for single product page

echo $product->single_add_to_cart_text();

Get add to cart Button Text

echo $product->add_to_cart_text();

Get Add to cart Burton text description

echo $product->add_to_cart_description();

Get Product image

echo $product->get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true );

Get product Shipping class

echo $product->get_shipping_class();

Get the Single Product attribute as a string

echo $product->get_attribute( $attribute );

Get rating count

// Get the total amount (COUNT) of ratings, or just the count for one rating e.g. number of 5 star ratings
echo $product->get_rating_count( $value = null );

Get File by download id

// Get a file by $download_id.
$file = $product->get_file( $download_id = '' );
print_r( $file );

Get file Download path

// Get file download path identified by $download_id.
echo $product->get_file_download_path( $download_id );

Get price suffix

//  Get the suffix to display after prices > 0.
echo $product->get_price_suffix( $price = '', $qty = 1 );

Get Availability of Product

// Returns the availability of the product.
$availability = $product->get_availability();
print_r( $availability );

Get availability text based on stock status


Get availability class name on stock status


Get Product Date of Creation

// Get product created date

Get Product Date of Modification


Get Product Status


Get product Featured if the product is Featured


Get product Catalog Visibility


Get product Description


Get Product Short Description


Get product SKU (Stock-keeping unit) – unique product ID.


Get Active Product Price


Get Regular Product Price


Get Product Sale Price


Get product Date on Sale from


Get product Date on Sale to


Get total sales


Get Tax status


Get Manage Stock (Boolean Return)


Get Stock Quantity


Get Stock Status


Get Back Orders


Get Low Stock Amount


Get sold Individually (return Boolean)


Get product Weight


Get product Length


Get Product height


Get product dimensions (return array or wc_format_dimensions


Get upsell ids


Get cross-sell ids


Get parent id


Get reviews allowed (Return Boolean)


Get Purchase Note


Get product attributes (array)


Get Default Attributes (array)


Get Menu order (integer)


Get Post Password


Get Category Ids


Get Tag ids


Get virtual (return Boolean)


Get Gallery Attachment ids


Get shipping class ids


Get downloads


Get download Expiry


Get downloadable


Get download limit


Get Image Id


Get rating count


Get Average rating


Get review count


Classes of WooCommerce

Leave a Reply

Scroll to Top