Hi there!
I have tried to replicate that issue on my end but I’m not able to replicate that issue. To assist you further, I’d like to understand your site properly. Please share with us the necessary information below for us to investigate the issue further:
- System Status Report which you can find via WooCommerce > Status
- Fatal error logs (if any) under WooCommerce > Status > Logs.
- Also share the screenshot of the error message you are seeing. For screenshot you can use https://snipboard.io
Please use https://pastebin.com/ or https://gist.github.com/ and share a link to that paste in reply here. Once we have more information, we’ll be able to assist you further.
Thread Starter
Vania
(@twvania)
https://pastebin.com/DE3gy1t6
And error:
[02-Dec-2025 10:45:13 UTC] PHP Fatal error: Uncaught Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidValue: Invalid coupon ID: 59 in .../wp-content/plugins/google-listings-and-ads/src/Exception/InvalidValue.php:95
Stack trace:
#0 .../wp-content/plugins/google-listings-and-ads/src/Coupon/CouponHelper.php(207): Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidValue::not_valid_coupon_id(59)
#1 .../wp-content/plugins/google-listings-and-ads/src/Admin/MetaBox/CouponChannelVisibilityMetaBox.php(138): Automattic\WooCommerce\GoogleListingsAndAds\Coupon\CouponHelper->get_wc_coupon(59)
#2 .../wp-content/plugins/google-listings-and-ads/src/Admin/MetaBox/AbstractMetaBox.php(105): Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\CouponChannelVisibilityMetaBox->get_view_context(Object(WP_Post), Array)
#3 .../wp-admin/includes/template.php(1456): Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\AbstractMetaBox->handle_callback(Object(WP_Post), Array)
#4 .../wp-admin/edit-form-advanced.php(714): do_meta_boxes(Object(WP_Screen), 'side', Object(WP_Post))
#5 .../wp-admin/post-new.php(75): require('/home/klient.dh...')
#6 {main}
thrown in .../wp-content/plugins/google-listings-and-ads/src/Exception/InvalidValue.php on line 95
Screen: https://prnt.sc/Gokzh_2iB8D_
-
This reply was modified 4 months, 1 week ago by
Vania.
Hi there!
Thank you for sharing the screenshot and system status report. Currently, everything appears fine in the system status report. However, the error code indicates that the Google Listings & Ads extension is trying to load a WooCommerce coupon that no longer exists or is invalid.
Since I’m not able to replicate this issue, it’s possible there could be a plugin conflict. For testing purposes, could you please first clear your site cache and deactivate your caching plugin to see if that resolves the issue?
If the problem persists, please create a staging site, deactivate all plugins except WooCommerce and Google Listings & Ads, and check if the issue still occurs. You can use the following plugin to create a staging site:
WP Staging – Backup/Clone/Stage
Let us know what you find.
Thread Starter
Vania
(@twvania)
After debugging, I discovered that the problem is not related to your plugin. It was caused by the way I was loading block patterns in the block_editor_settings_all filter.
Specifically, this line in my code:
WP_Block_Patterns_Registry::get_instance()->get_all_registered();
When called inside block_editor_settings_all, it causes WordPress/WooCommerce to use the current screen’s fallback post ID.
On the Create New Coupon page (/wp-admin/post-new.php?post_type=shop_coupon), there is no coupon ID yet, so WordPress uses the value of page_for_posts as the “current post ID”.
As a result, Google Listings & Ads receives this incorrect ID and throws:
Invalid coupon ID
Once I restricted my code to run only in the product editor context, the issue disappeared.
So the problem was caused entirely by my filter running in an unintended context, not by your plugin.
Just wanted to update you so you don’t spend time investigating something that wasn’t caused by your code.
Thanks!
Hi @twvania,
I’m glad you were able to trace the issue to the custom block pattern loading logic. That explains why the metabox was receiving an unexpected fallback post ID before the coupon was created.
Great to hear the issue is resolved after restricting the filter to the correct editor context. Thanks again for sharing the explanation. This will definitely help others who run into similar behavior.
If you found our support helpful, please share your review here.
If anything else comes up, feel free to open a new thread. We’re happy to help!