Automattic\WooCommerce\Internal\Admin\Schedulers
MailchimpScheduler::run()
Attempt to subscribe store_email to MailChimp.
Метод класса: MailchimpScheduler{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$MailchimpScheduler = new MailchimpScheduler(); $MailchimpScheduler->run();
Код MailchimpScheduler::run() MailchimpScheduler::run WC 8.1.1
public function run() { // Abort if we've already subscribed to MailChimp. if ( 'yes' === get_option( self::SUBSCRIBED_OPTION_NAME ) ) { return false; } $profile_data = get_option( 'woocommerce_onboarding_profile' ); if ( ! isset( $profile_data['is_agree_marketing'] ) || false === $profile_data['is_agree_marketing'] ) { return false; } // Abort if store_email doesn't exist. if ( ! isset( $profile_data['store_email'] ) ) { return false; } // Abort if failed requests reaches the threshold. if ( intval( get_option( self::SUBSCRIBED_ERROR_COUNT_OPTION_NAME, 0 ) ) >= self::MAX_ERROR_THRESHOLD ) { return false; } $response = $this->make_request( $profile_data['store_email'] ); if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) { $this->handle_request_error(); return false; } $body = json_decode( $response['body'] ); if ( isset( $body->success ) && true === $body->success ) { update_option( self::SUBSCRIBED_OPTION_NAME, 'yes' ); return true; } $this->handle_request_error( $body ); return false; }