The $product
object in WooCommerce provides developers access to all relevant product data. If you’re customizing WooCommerce templates or building advanced features, here’s a reference of what you can retrieve:
- ID:
$product->get_id()
– Get the product ID. - Name:
$product->get_name()
– Title of the product. - Type:
$product->get_type()
– Type (simple, variable, etc.). - SKU:
$product->get_sku()
- Description:
$product->get_description()
- Short Desc:
$product->get_short_description()
- Regular Price:
$product->get_regular_price()
- Sale Price:
$product->get_sale_price()
- Stock Qty:
$product->get_stock_quantity()
- Weight:
$product->get_weight()
- Dimensions:
$product->get_dimensions()
- Categories:
$product->get_category_ids()
- Tags:
$product->get_tag_ids()
- Gallery:
$product->get_gallery_image_ids()
- Featured Image:
$product->get_image_id()
- Attributes:
$product->get_attributes()
- Variations:
$product->get_available_variations()
- Rating:
$product->get_average_rating()
- Reviews:
$product->get_review_count()
- Permalink:
$product->get_permalink()
- Add to Cart URL:
$product->add_to_cart_url()
- Cart Button Text:
$product->add_to_cart_text()
These methods provide everything from basic details to advanced product metadata. If needed, inspect the full $product
object using print_r()
or var_dump()
. This makes custom WooCommerce development more efficient and powerful.