Use instance of checks for detecting WCProduct
[MAILPOET-2586]
This commit is contained in:
committed by
Jack Kitterhing
parent
73e9cc3517
commit
d3ce76f88d
@@ -110,7 +110,7 @@ class PurchasedInCategory {
|
||||
$ordered_product_categories = [];
|
||||
foreach ($order_details->get_items() as $order_item_product) {
|
||||
$product = $order_item_product->get_product();
|
||||
if (!$product || !is_callable([$product, 'get_category_ids'])) {
|
||||
if (!$product instanceof \WC_Product) {
|
||||
continue;
|
||||
}
|
||||
$ordered_product_categories = array_merge($ordered_product_categories, $product->get_category_ids());
|
||||
|
@@ -118,7 +118,7 @@ class PurchasedProduct {
|
||||
}
|
||||
|
||||
$ordered_products = array_map(function($product) {
|
||||
return is_callable([$product, 'get_product_id']) ? $product->get_product_id() : null;
|
||||
return ($product instanceof \WC_Order_Item_Product) ? $product->get_product_id() : null;
|
||||
}, $order_details->get_items());
|
||||
$ordered_products = array_values(array_filter($ordered_products));
|
||||
|
||||
|
Reference in New Issue
Block a user