From a4faccfe3bfb5750c0d3fc2787f6795dccddad9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ran=C4=91elovi=C4=87?= Date: Wed, 4 Dec 2024 04:05:57 -0800 Subject: [PATCH] Improve check for product categories (#59) Summary: This update checks whether the product is within a category. There are sites where it is possible that the product is not even in the `Uncategorized` "fallback" category. Pull Request resolved: https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/pull/59 Reviewed By: maxkozin Differential Revision: D66595736 Pulled By: vahidkay-meta fbshipit-source-id: aa62905081553726cba962bbdfbd494d7496ab1d --- integration/FacebookWordpressWooCommerce.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/FacebookWordpressWooCommerce.php b/integration/FacebookWordpressWooCommerce.php index 3b0760e7..f1066e21 100644 --- a/integration/FacebookWordpressWooCommerce.php +++ b/integration/FacebookWordpressWooCommerce.php @@ -123,7 +123,8 @@ private static function getProductCategory($product_id){ $product_id, 'product_cat' ); - return count($categories) > 0 ? $categories[0]->name : null; + + return (is_array($categories) && count($categories) > 0) ? $categories[0]->name : null; } public static function trackPurchaseEvent($order_id) {