WC-Product-Simple documentation code example

Example: WC_Product

// Get the instance of the WC_Product Object
$product = wc_get_product( $product_id);

// Using `WC_Product` methods examples to get specific related data values:

$product_type  = $product->get_type(); // product Type
$product_id    = $product->get_id(); // product ID
$product_name  = $product->get_name(); // product name
$product_sku   = $product->get_sku(); // product SKU
$product_price = $product->get_price(); // product price

// And so on…

// The raw display of the object protected data (Just for testing)
echo '<pre>'; print_r( $product ); echo '</pre>';

Tags:

Php Example