From 7561f772d9ea40e3b2c30d1f3e92a41cf826825f Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Thu, 31 Mar 2016 17:51:01 -0700 Subject: [PATCH] Make wc_get_product() return false if the specified post is not a product --- includes/class-wc-product-factory.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-wc-product-factory.php b/includes/class-wc-product-factory.php index d4f067ab772..79b316af799 100644 --- a/includes/class-wc-product-factory.php +++ b/includes/class-wc-product-factory.php @@ -33,6 +33,10 @@ class WC_Product_Factory { $classname = $this->get_product_class( $the_product, $args ); + if ( ! $classname ) { + return false; + } + if ( ! class_exists( $classname ) ) { $classname = 'WC_Product_Simple'; }