Bug in code
-
Hi.
I believe I found a bug in your code. On line 236 of classes/pixels/lass-google-pixel-manager.php, you have a $product->get_id() call.
The problem is that the $product can be non-existent (False), since the product ids you gather include upsells and related products. These products can get deleted by the user and WooCommerce does not update the associated references in related products and upsells (until the associated product is saved).
The result is a fatal error. I wrote three lines of code as a work-around:
234 foreach ( $product_ids as $key => $product_id ) { 235 $product = wc_get_product( $product_id ); 236 if (!$product) { 237 continue; 238 } 239 $data[$product->get_id()] = [
Hope this helps.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Bug in code’ is closed to new replies.