tch_as_unsynced( array $product_ids ) { foreach ( $product_ids as $product_id ) { try { $product = $this->product_helper->get_wc_product( $product_id ); } catch ( InvalidValue $exception ) { continue; } $this->product_helper->mark_as_unsynced( $product ); } } /** * Marks a WooCommerce product as invalid and stores the errors in a meta data key. * * Note: If a product variation is invalid then the parent product is also marked as invalid. * * @param BatchInvalidProductEntry $product_entry */ public function mark_as_invalid( BatchInvalidProductEntry $product_entry ) { $wc_product = $this->product_helper->get_wc_product( $product_entry->get_wc_product_id() ); $errors = $product_entry->get_errors(); $this->product_helper->mark_as_invalid( $wc_product, $errors ); } /** * Generates an array map containing the Google product IDs as key and the WooCommerce product IDs as values. * * @param WC_Product[] $products * * @return BatchProductIDRequestEntry[] */ public function generate_delete_request_entries( array $products ): array { $request_entries = []; foreach ( $products as $product ) { $this->validate_instanceof( $product, WC_Product::class ); if ( $product instanceof WC_Product_Variable ) { $request_entries = array_merge( $request_entries, $this->generate_delete_request_entries( $product->get_available_variations( 'objects' ) ) ); continue; } $google_ids = $this->product_helper->get_synced_google_product_ids( $product ); if ( empty( $google_ids ) ) { continue; } foreach ( $google_ids as $google_id ) { $request_entries[ $google_id ] = new BatchProductIDRequestEntry( $product->get_id(), $google_id ); } } return $request_entries; } /** * @param WC_Product[] $products * * @return BatchProductRequestEntry[] */ public function validate_and_generate_update_request_entries( array $products ): array { $request_entries = []; $mapping_rules = $this->attribute_mapping_rules_query->get_results(); foreach ( $products as $product ) { $this->validate_instanceof( $product, WC_Product::class ); try { if ( ! $this->product_helper->is_sync_ready( $product ) ) { do_action( 'woocommerce_gla_debug_message', sprintf( 'Skipping product (ID: %s) because it is not ready to be synced.', $product->get_id() ), __METHOD__ ); continue; } if ( $product instanceof WC_Product_Variable ) { $request_entries = array_merge( $request_entries, $this->validate_and_generate_update_request_entries( $product->get_available_variations( 'objects' ) ) ); continue; } $target_countries = $this->target_audience->get_target_countries(); $main_target_country = $this->target_audience->get_main_target_country(); // validate the product $adapted_product = $this->product_factory->create( $product, $main_target_country, $mapping_rules ); $validation_result = $this->validate_product( $adapted_product ); if ( $validation_result instanceof BatchInvalidProductEntry ) { $this->mark_as_invalid( $validation_result ); do_action( 'woocommerce_gla_debug_message', sprintf( 'Skipping product (ID: %s) because it does not pass validation: %s', $product->get_id(), json_encode( $validation_result ) ), __METHOD__ ); continue; } // add shipping for all selected target countries array_walk( $target_countries, [ $adapted_product, 'add_shipping_country' ] ); $request_entries[] = new BatchProductRequestEntry( $product->get_id(), $adapted_product ); } catch ( GoogleListingsAndAdsException $exception ) { do_action( 'woocommerce_gla_error', sprintf( 'Skipping product (ID: %s) due to exception: %s', $product->get_id(), $exception->getMessage() ), __METHOD__ ); continue; } } return $request_entries; } /** * @param WCProductAdapter $product * * @return BatchInvalidProductEntry|true */ protected function validate_product( WCProductAdapter $product ) { $violations = $this->validator->validate( $product ); if ( 0 !== count( $violations ) ) { $invalid_product = new BatchInvalidProductEntry( $product->get_wc_product()->get_id() ); $invalid_product->map_validation_violations( $violations ); return $invalid_product; } return true; } /** * Filters and returns an array of request entries for Google products that should no longer be submitted for the selected target audience. * * @param WC_Product[] $products * * @return BatchProductIDRequestEntry[] */ public function generate_stale_products_request_entries( array $products ): array { $target_audience = $this->target_audience->get_target_countries(); $request_entries = []; foreach ( $products as $product ) { $google_ids = $this->meta_handler->get_google_ids( $product ) ?: []; $stale_ids = array_diff_key( $google_ids, array_flip( $target_audience ) ); foreach ( $stale_ids as $stale_id ) { $request_entries[ $stale_id ] = new BatchProductIDRequestEntry( $product->get_id(), $stale_id ); } } return $request_entries; } /** * Returns an array of request entries for Google products that should no * longer be submitted for every target country. * * @since 1.1.0 * * @param WC_Product[] $products * * @return BatchProductIDRequestEntry[] */ public function generate_stale_countries_request_entries( array $products ): array { $main_target_country = $this->target_audience->get_main_target_country(); $request_entries = []; foreach ( $products as $product ) { $google_ids = $this->meta_handler->get_google_ids( $product ) ?: []; $stale_ids = array_diff_key( $google_ids, array_flip( [ $main_target_country ] ) ); foreach ( $stale_ids as $stale_id ) { $request_entries[ $stale_id ] = new BatchProductIDRequestEntry( $product->get_id(), $stale_id ); } } return $request_entries; } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Product\BatchProductHelper does not exist and could not be loaded in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 73

Warning: foreach() argument must be of type array|object, bool given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 73
hannel_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(), 'is_channel_supported' => $this->merchant_center->is_promotion_supported_country( $target_country ), 'get_started_url' => $this->get_start_url(), ]; } /** * Register a service. */ public function register(): void { add_action( 'woocommerce_new_coupon', [ $this, 'handle_submission' ], 10, 2 ); add_action( 'woocommerce_update_coupon', [ $this, 'handle_submission' ], 10, 2 ); } /** * @param int $coupon_id * @param WC_Coupon $coupon */ public function handle_submission( int $coupon_id, WC_Coupon $coupon ) { /** * Array of `true` values for each coupon IDs already handled by this method. Used to prevent double submission. * * @var bool[] $already_updated */ static $already_updated = []; $field_id = $this->get_visibility_field_id(); // phpcs:disable WordPress.Security.NonceVerification // nonce is verified by self::verify_nonce if ( ! $this->verify_nonce() || ! isset( $_POST[ $field_id ] ) || isset( $already_updated[ $coupon_id ] ) ) { return; } // Only update the value for supported coupon types if ( ! CouponSyncer::is_coupon_supported( $coupon ) ) { return; } try { $visibility = empty( $_POST[ $field_id ] ) ? ChannelVisibility::cast( ChannelVisibility::DONT_SYNC_AND_SHOW ) : ChannelVisibility::cast( sanitize_key( $_POST[ $field_id ] ) ); // phpcs:enable WordPress.Security.NonceVerification $this->meta_handler->update_visibility( $coupon, $visibility ); $already_updated[ $coupon_id ] = true; } catch ( InvalidValue $exception ) { // silently log the exception and do not set the coupon's visibility if an invalid visibility value is sent. do_action( 'woocommerce_gla_exception', $exception, __METHOD__ ); } } /** * @return string * * @since 1.1.0 */ protected function get_visibility_field_id(): string { return $this->prefix_field_id( 'visibility' ); } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Admin\MetaBox\CouponChannelVisibilityMetaBox does not exist and could not be loaded in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 119

Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php:120 Stack trace: #0 /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php(120): array_key_exists('Automattic\\WooC...', false) #1 /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/CoreServiceProvider.php(385): Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement\AbstractServiceProvider->conditionally_share_with_tags('Automattic\\WooC...', 'Automattic\\WooC...', 'Automattic\\WooC...', 'Automattic\\WooC...', 'Automattic\\WooC...', 'Automattic\\WooC...') #2 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/ServiceProvider/ServiceProviderAggregate.php(102): Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement\CoreServiceProvider->register() #3 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(172): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\ServiceProvider\ServiceProviderAggregate->register('Automattic\\WooC...') #4 /htdocs/wp-content/plugins/google-listings-and-ads/src/Container.php(90): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...') #5 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(130): Automattic\WooCommerce\GoogleListingsAndAds\Container->get('Automattic\\WooC...') #6 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(91): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->maybe_register_services() #7 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\{closure}('') #8 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #9 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #10 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #11 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #12 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #13 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #14 /htdocs/index.php(17): require('/htdocs/wp-blog...') #15 {main} thrown in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 120