Allow product ids in get_product_data

This commit is contained in:
Claudiu Lodromanean 2017-03-07 09:40:28 -08:00
parent d5262a1711
commit dd97b7bc50
3 changed files with 15 additions and 3 deletions

View File

@ -260,10 +260,14 @@ class WC_API_Products extends WC_API_Resource {
* Get standard product data that applies to every product type
*
* @since 2.1
* @param WC_Product $product
* @param WC_Product|int $product
* @return array
*/
private function get_product_data( $product ) {
if ( is_numeric( $product ) ) {
$product = wc_get_product( $product );
}
return array(
'title' => $product->get_name(),
'id' => $product->get_id(),

View File

@ -676,10 +676,14 @@ class WC_API_Products extends WC_API_Resource {
* Get standard product data that applies to every product type
*
* @since 2.1
* @param WC_Product $product
* @param WC_Product|int $product
* @return WC_Product
*/
private function get_product_data( $product ) {
if ( is_numeric( $product ) ) {
$product = wc_get_product( $product );
}
$prices_precision = wc_get_price_decimals();
return array(
'title' => $product->get_name(),

View File

@ -1122,10 +1122,14 @@ class WC_API_Products extends WC_API_Resource {
* Get standard product data that applies to every product type
*
* @since 2.1
* @param WC_Product $product
* @param WC_Product|int $product
* @return WC_Product
*/
private function get_product_data( $product ) {
if ( is_numeric( $product ) ) {
$product = wc_get_product( $product );
}
return array(
'title' => $product->get_name(),
'id' => $product->get_id(),