Skip to content

Commit

Permalink
Improve check for product categories (#59)
Browse files Browse the repository at this point in the history
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: #59

Reviewed By: maxkozin

Differential Revision: D66595736

Pulled By: vahidkay-meta

fbshipit-source-id: aa62905081553726cba962bbdfbd494d7496ab1d
  • Loading branch information
iodic authored and facebook-github-bot committed Dec 4, 2024
1 parent d6e7308 commit a4faccf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion integration/FacebookWordpressWooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a4faccf

Please sign in to comment.