Skip to content

Commit 78b71e0

Browse files
authored
WooCommerce Analytics: check if product exists before we use it (#35566)
Fixes #35562
1 parent 973d31d commit 78b71e0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: bugfix
3+
4+
WooCommerce Analytics: avoid error when trying to pay for a deleted product.

projects/plugins/jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-trait.php

+6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ protected function format_items_to_json( $items ) {
6868
} else {
6969
$product = $item['data'];
7070
}
71+
72+
if ( ! $product || ! $product instanceof WC_Product ) {
73+
continue;
74+
}
75+
7176
$data = $this->get_product_details( $product );
77+
7278
if ( $item instanceof WC_Order_Item_Product ) {
7379
$data['pq'] = $item->get_quantity();
7480
} else {

0 commit comments

Comments
 (0)