Automattic\WooCommerce\StoreApi\Utilities

CartController::get_product_id()protectedWC 1.0

For a given product, get the product ID.

Method of the class: CartController{}

No Hooks.

Return

Int.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_product_id( $product );
$product(\WC_Product) (required)
Product object associated with the cart item.

CartController::get_product_id() code WC 8.7.0

protected function get_product_id( \WC_Product $product ) {
	return $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
}