From 365b456fa5d685a2f8c1ae4f7115ad89a05862e9 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 27 Jan 2017 16:39:53 +0000 Subject: [PATCH] Make sure product is set. --- includes/wc-stock-functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/wc-stock-functions.php b/includes/wc-stock-functions.php index db122cc2cc2..a5a6f7fbea9 100644 --- a/includes/wc-stock-functions.php +++ b/includes/wc-stock-functions.php @@ -24,8 +24,9 @@ if ( ! defined( 'ABSPATH' ) ) { * @param string $operation set, increase and decrease. */ function wc_update_product_stock( $product, $stock_quantity = null, $operation = 'set' ) { - $product = wc_get_product( $product ); - + if ( ! $product = wc_get_product( $product ) ) { + return false; + } if ( ! is_null( $stock_quantity ) && $product->managing_stock() ) { // Some products (variations) can have their stock managed by their parent. Get the correct ID to reduce here. $product_id_with_stock = $product->get_stock_managed_by_id();