Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Product_Factory::get_product_id( WC_Product|WP_Post|int|bool $product )
Get the product ID depending on what was passed.
Description Description
Parameters Parameters
- $product
-
(Required) Product instance, post instance, numeric or false to use global $post.
Return Return
(int|bool) false on failure
Source Source
File: includes/class-wc-product-factory.php
private function get_product_id( $product ) { global $post; if ( false === $product && isset( $post, $post->ID ) && 'product' === get_post_type( $post->ID ) ) { return absint( $post->ID ); } elseif ( is_numeric( $product ) ) { return $product; } elseif ( $product instanceof WC_Product ) { return $product->get_id(); } elseif ( ! empty( $product->ID ) ) { return $product->ID; } else { return false; } }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |