ed_conversions' => $this->get_boolean_value( OptionsInterface::ADS_ENHANCED_CONVERSIONS_ENABLED ), 'target_audience' => $target_audience->get_target_countries(), 'shipping_rate' => $mc_settings['shipping_rate'] ?? '', 'shipping_time' => $mc_settings['shipping_time'] ?? '', 'has_account_issue' => $mc_service->is_connected() && $mc_service->has_account_issues() ? 'yes' : 'no', 'has_at_least_one_synced_product' => $mc_service->is_connected() && $mc_service->has_at_least_one_synced_product() ? 'yes' : 'no', 'small_image_product_count' => $mc_service->is_connected() ? $image_size_audit->get_small_image_product_count() : 0, 'ads_setup_started' => $ads_service->is_setup_started() ? 'yes' : 'no', 'ads_customer_id' => $this->options->get_ads_id(), 'ads_campaign_count' => $merchant_metrics->get_campaign_count(), 'youtube_connected' => $this->get_boolean_value( OptionsInterface::YOUTUBE_THIRD_PARTY_LINK ), 'reviews_collection' => ! empty( $gcr_settings['gcr_collect_reviews_after_purchase'] ) ? 'yes' : 'no', 'reviews_badge_widget' => ! empty( $gcr_settings['gcr_badge_widget_enabled'] ) ? 'yes' : 'no', 'multilingual_markets' => $market_counts['multilingual'], 'multicurrency_markets' => $market_counts['multicurrency'], ]; return array_merge( $settings, $this->get_feed_issue_counts( $mc_service->is_connected() ) ); } /** * Get the feed-blocking issue counts saved by the last completed Merchant Center status check. * * @since 3.11.0 * * @param bool $is_connected Whether Merchant Center is connected. * * @return array Counts keyed by snapshot field name, each an int or null. */ protected function get_feed_issue_counts( bool $is_connected ): array { $fields = MerchantStatuses::FEED_ISSUE_SUMMARY_FIELDS; $unknown = array_fill_keys( $fields, null ); if ( ! $is_connected ) { return $unknown; } $summary = $this->options->get( OptionsInterface::FEED_ISSUE_SUMMARY ); if ( ! is_array( $summary ) ) { return $unknown; } $counts = []; foreach ( $fields as $field ) { if ( ! isset( $summary[ $field ] ) || ! is_int( $summary[ $field ] ) || $summary[ $field ] < 0 ) { return $unknown; } $counts[ $field ] = $summary[ $field ]; } return $counts; } /** * Get boolean value from options, return as yes or no. * * @param string $key Option key name. * * @return string */ protected function get_boolean_value( string $key ): string { return (bool) $this->options->get( $key ) ? 'yes' : 'no'; } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Tracking\TrackerSnapshot 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, false given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 73
is step was already finished. if ( AdsAccountState::STEP_DONE === $state['set_id']['status'] ) { return; } $this->container->get( Middleware::class )->link_ads_account( $account_id ); // Skip billing setup flow when using an existing account. $state['set_id']['status'] = AdsAccountState::STEP_DONE; $state['billing']['status'] = AdsAccountState::STEP_DONE; $this->state->update( $state ); } /** * Performs the steps necessary to setup an ads account. * Should always resume up at the last pending or unfinished step. * If the Ads account has already been created, the ID is simply returned. * * @return array The newly created (or pre-existing) Ads ID. * @throws Exception If an error occurs during any step. */ public function setup_account(): array { $state = $this->state->get(); $ads_id = $this->options->get_ads_id(); $account = [ 'id' => $ads_id ]; foreach ( $state as $name => &$step ) { if ( AdsAccountState::STEP_DONE === $step['status'] ) { continue; } try { switch ( $name ) { case 'set_id': // Just in case, don't create another Ads ID. if ( ! empty( $ads_id ) ) { break; } $account = $this->container->get( Middleware::class )->create_ads_account(); $step['data']['sub_account'] = true; $step['data']['created_timestamp'] = time(); break; case 'billing': $this->check_billing_status( $account ); break; case 'conversion_action': $this->create_conversion_action(); break; case 'link_merchant': // Continue to next step if the MC account is not connected yet. if ( ! $this->options->get_merchant_id() ) { // Save step as pending and continue the foreach loop with `continue 2`. $state[ $name ]['status'] = AdsAccountState::STEP_PENDING; $this->state->update( $state ); continue 2; } $this->link_merchant_account(); break; case 'account_access': $this->check_ads_account_has_access(); break; default: throw new Exception( /* translators: 1: is a string representing an unknown step name */ sprintf( __( 'Unknown ads account creation step %1$s', 'google-listings-and-ads' ), $name ) ); } $step['status'] = AdsAccountState::STEP_DONE; $step['message'] = ''; $this->state->update( $state ); } catch ( Exception $e ) { $step['status'] = AdsAccountState::STEP_ERROR; $step['message'] = $e->getMessage(); $this->state->update( $state ); if ( $e->getPrevious() instanceof BadResponseException ) { /** @var BadResponseException $prev */ $prev = $e->getPrevious(); $body = method_exists( $prev, 'getResponse' ) && $prev->getResponse() ? (string) $prev->getResponse()->getBody() : ''; $decoded = json_decode( $body, true ); $error = is_array( $decoded ) ? ( $decoded['error'] ?? [] ) : []; $message = is_array( $error ) && isset( $error['message'] ) ? (string) $error['message'] : $e->getMessage(); throw new ExceptionWithResponseData( $message, $e->getCode() ?: 400, null, [ 'code' => 'API_ERROR', 'data' => $decoded, ] ); } throw $e; } } return $account; } /** * Gets the billing setup status and returns a setup URL if available. * * @return array */ public function get_billing_status(): array { $status = $this->container->get( Ads::class )->get_billing_status(); if ( BillingSetupStatus::APPROVED === $status ) { $this->state->complete_step( 'billing' ); return [ 'status' => $status ]; } $billing_url = $this->options->get( OptionsInterface::ADS_BILLING_URL ); // Check if user has provided the access and ocid is present. $connection_status = $this->container->get( Connection::class )->get_status(); $email = $connection_status['email'] ?? ''; $has_access = $this->container->get( Ads::class )->has_access( $email ); $ocid = $this->options->get( OptionsInterface::ADS_ACCOUNT_OCID, null ); // Link directly to the payment page if the customer already has access. if ( $has_access ) { $billing_url = add_query_arg( [ 'ocid' => $ocid ?: 0, ], 'https://ads.google.com/aw/signup/payment' ); } return [ 'status' => $status, 'billing_url' => $billing_url, ]; } /** * Check if the Ads account has access. * * @throws ExceptionWithResponseData If the account doesn't have access. */ private function check_ads_account_has_access() { $access_status = $this->get_ads_account_has_access(); if ( ! $access_status['has_access'] ) { throw new ExceptionWithResponseData( __( 'Account must be accepted before completing setup.', 'google-listings-and-ads' ), 428, null, $access_status ); } } /** * Gets the Ads account access status. * * @return array { * Returns the access status, last completed account setup step, * and invite link if available. * * @type bool $has_access Whether the customer has access to the account. * @type string $step The last completed setup step for the Ads account. * @type string $invite_link The URL to the invite link. * } */ public function get_ads_account_has_access() { $has_access = false; // Check if an Ads ID is present. if ( $this->options->get_ads_id() ) { $connection_status = $this->container->get( Connection::class )->get_status(); $email = $connection_status['email'] ?? ''; } // If no email, means google account is not connected. if ( ! empty( $email ) ) { $has_access = $this->container->get( Ads::class )->has_access( $email ); } // If we have access, complete the step so that it won't be called next time. if ( $has_access ) { $this->state->complete_step( 'account_access' ); } return [ 'has_access' => $has_access, 'step' => $this->state->last_incomplete_step(), 'invite_link' => $this->options->get( OptionsInterface::ADS_BILLING_URL, '' ), ]; } /** * Disconnect Ads account */ public function disconnect() { $this->options->delete( OptionsInterface::ADS_ACCOUNT_CURRENCY ); $this->options->delete( OptionsInterface::ADS_ACCOUNT_OCID ); $this->options->delete( OptionsInterface::ADS_ACCOUNT_STATE ); $this->options->delete( OptionsInterface::ADS_BILLING_URL ); $this->options->delete( OptionsInterface::ADS_CONVERSION_ACTION ); $this->options->delete( OptionsInterface::ADS_ENHANCED_CONVERSIONS_ENABLED ); $this->options->delete( OptionsInterface::ADS_EU_POLITICAL_DECLARATIONS_COMPLETE ); $this->options->delete( OptionsInterface::ADS_HAS_UNCLAIMED_INCENTIVE ); $this->options->delete( OptionsInterface::ADS_ID ); $this->options->delete( OptionsInterface::ADS_INCENTIVE_APPLIED ); $this->options->delete( OptionsInterface::ADS_INCENTIVE_APPLY_ERROR ); $this->options->delete( OptionsInterface::ADS_SETUP_COMPLETED_AT ); $this->options->delete( OptionsInterface::CAMPAIGN_CONVERT_STATUS ); $this->container->get( TransientsInterface::class )->delete( TransientsInterface::ADS_CAMPAIGN_COUNT ); $this->container->get( TransientsInterface::class )->delete( TransientsInterface::ADS_INCENTIVE_APPLIED_CHECK ); } /** * Confirm the billing flow has been completed. * * @param array $account Account details. * * @throws ExceptionWithResponseData If this step hasn't been completed yet. */ private function check_billing_status( array $account ) { $status = BillingSetupStatus::UNKNOWN; // Only check billing status if we haven't just created the account. if ( empty( $account['billing_url'] ) ) { $status = $this->container->get( Ads::class )->get_billing_status(); } if ( BillingSetupStatus::APPROVED !== $status ) { throw new ExceptionWithResponseData( __( 'Billing setup must be completed.', 'google-listings-and-ads' ), 428, null, [ 'billing_url' => $this->options->get( OptionsInterface::ADS_BILLING_URL ), 'billing_status' => $status, ] ); } } /** * Get the callback function for linking a merchant account. * * @throws Exception When the ads account hasn't been set yet. */ private function link_merchant_account() { if ( ! $this->options->get_ads_id() ) { throw new Exception( 'An Ads account must be connected' ); } $mc_state = $this->container->get( MerchantAccountState::class ); // Create link for Merchant and accept it in Ads. $waiting_acceptance = $this->container->get( Merchant::class )->link_ads_id( $this->options->get_ads_id() ); if ( $waiting_acceptance ) { $this->container->get( Ads::class )->accept_merchant_link( $this->options->get_merchant_id() ); } $mc_state->complete_step( 'link_ads' ); } /** * Create the generic GLA conversion action and store the details as an option. * * @throws Exception If the conversion action can't be created. */ private function create_conversion_action(): void { $action = $this->container->get( AdsConversionAction::class )->create_conversion_action(); $this->options->update( OptionsInterface::ADS_CONVERSION_ACTION, $action ); } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Ads\AccountService 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, false given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 73
https://kas.ci/post-sitemap.xml 2026-01-24T12:30:37+00:00 https://kas.ci/page-sitemap.xml 2026-08-27T07:55:21+00:00 https://kas.ci/product-sitemap.xml 2026-06-12T11:59:35+00:00 https://kas.ci/wcfm_vendor_groups-sitemap.xml 2026-04-03T15:17:11+00:00 https://kas.ci/faq-sitemap.xml 2018-04-07T04:19:09+00:00 https://kas.ci/porto_builder-sitemap.xml 2026-08-25T16:27:39+00:00 https://kas.ci/order_status-sitemap.xml 2025-10-30T18:01:34+00:00 https://kas.ci/post_tag-sitemap.xml 2026-01-24T12:30:37+00:00 https://kas.ci/product_brand-sitemap.xml 2026-06-03T15:49:56+00:00 https://kas.ci/pa_taille-sitemap.xml 2026-07-13T21:03:54+00:00 https://kas.ci/author-sitemap.xml 2026-02-27T11:12:02+00:00 https://kas.ci/wcfmmp-stores-sitemap.xml