Describe the bug:
Critical (Fatal error, breaks coupon creation/editing page).
PHP Fatal error: Uncaught Automattic\WooCommerce\GoogleListingsAndAds\View\ViewException:
The property "is_setup_complete" could not be found within the context of the currently rendered view.
in src/View/ViewException.php:70
The view template views/meta-box/coupon_channel_visibility.php accesses $this->is_setup_complete at line 40, but the method CouponChannelVisibilityMetaBox::get_view_context() in src/Admin/MetaBox/CouponChannelVisibilityMetaBox.php does not include is_setup_complete in the context array passed to the view.
Steps to reproduce:
- Install and activate Google Listings & Ads with Merchant Center connected
- Navigate to WooCommerce > Marketing > Coupons > Add coupon (/wp-admin/post-new.php?post_type=shop_coupon)
- The page throws a PHP Fatal error
Expected behavior:
The view expects these context properties: coupon_id, coupon, channel_visibility, field_id, is_setup_complete, is_channel_supported, get_started_url, sync_status, issues.
Actual behavior:
get_view_context() only provides 8 of these 9 properties, omitting is_setup_complete.
This produce a PHP Fatal error by opening /wp-admin/post-new.php?post_type=shop_coupon
Additional details:
Suggested fix:
Add the missing property to the context array in CouponChannelVisibilityMetaBox::get_view_context():
return [
'field_id' => $this->get_visibility_field_id(),
'coupon_id' => $coupon_id,
'coupon' => $coupon,
'channel_visibility' => $this->coupon_helper->get_channel_visibility( $coupon ),
'sync_status' => $this->meta_handler->get_sync_status( $coupon ),
'issues' => $this->coupon_helper->get_validation_errors( $coupon ),
'is_setup_complete' => $this->merchant_center->is_setup_complete(), // <-- missing line
'is_channel_supported' => $this->merchant_center->is_promotion_supported_country( $target_country ),
'get_started_url' => $this->get_start_url(),
];
MerchantCenterService::is_setup_complete() already exists and is used elsewhere in the plugin. No additional dependencies are needed.
Tested: Fix confirmed working. After the change, the coupon creation page loads without errors.
Describe the bug:
Critical (Fatal error, breaks coupon creation/editing page).
The view template
views/meta-box/coupon_channel_visibility.phpaccesses$this->is_setup_completeat line 40, but the methodCouponChannelVisibilityMetaBox::get_view_context()insrc/Admin/MetaBox/CouponChannelVisibilityMetaBox.phpdoes not includeis_setup_completein the context array passed to the view.Steps to reproduce:
Expected behavior:
The view expects these context properties: coupon_id, coupon, channel_visibility, field_id, is_setup_complete, is_channel_supported, get_started_url, sync_status, issues.
Actual behavior:
get_view_context() only provides 8 of these 9 properties, omitting is_setup_complete.
This produce a PHP Fatal error by opening
/wp-admin/post-new.php?post_type=shop_couponAdditional details:
Suggested fix:
Add the missing property to the context array in
CouponChannelVisibilityMetaBox::get_view_context():MerchantCenterService::is_setup_complete()already exists and is used elsewhere in the plugin. No additional dependencies are needed.Tested: Fix confirmed working. After the change, the coupon creation page loads without errors.