WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
класс не описан

Automattic\WooCommerce\Admin\Features

OnboardingAutomateTaxes{} WC 1.0

This contains logic for setting up shipping when the profiler completes.

Хуков нет.

Возвращает

Null. Ничего.

Использование

$OnboardingAutomateTaxes = new OnboardingAutomateTaxes();
// use class methods

Методы

  1. __construct()
  2. automated_tax_is_supported()
  3. on_onboarding_profile_completed()
  4. track_tax_automation()

Код OnboardingAutomateTaxes{} WC 4.7.1

<?php
class OnboardingAutomateTaxes {
	/**
	 * Constructor.
	 */
	public function __construct() {
		add_action(
			'woocommerce_onboarding_profile_completed',
			array(
				__CLASS__,
				'on_onboarding_profile_completed',
			)
		);

		add_action(
			'jetpack_authorize_ending_authorized',
			array(
				__CLASS__,
				'on_onboarding_profile_completed',
			)
		);
	}

	/**
	 * Set up automated taxes.
	 */
	public static function on_onboarding_profile_completed() {
		$jetpack_connected = null;
		$wcs_version       = null;
		$wcs_tos_accepted  = null;

		if ( class_exists( '\Jetpack_Data' ) ) {
			$user_token        = \Jetpack_Data::get_access_token( JETPACK_MASTER_USER );
			$jetpack_connected = isset( $user_token->external_user_id );
		}

		if ( class_exists( '\WC_Connect_Loader' ) ) {
			$wcs_version = \WC_Connect_Loader::get_wcs_version();
		}

		if ( class_exists( '\WC_Connect_Options' ) ) {
			$wcs_tos_accepted = \WC_Connect_Options::get_option( 'tos_accepted' );
		}

		if ( $jetpack_connected && $wcs_version && $wcs_tos_accepted && self::automated_tax_is_supported() ) {
			update_option( 'wc_connect_taxes_enabled', 'yes' );
			update_option( 'woocommerce_calc_taxes', 'yes' );
			self::track_tax_automation();
			Confirm_Tax_Settings::possibly_add_note();
		}
	}

	/**
	 * Check if automated taxes are supported.
	 */
	private static function automated_tax_is_supported() {
		return in_array( WC()->countries->get_base_country(), OnboardingTasks::get_automated_tax_supported_countries(), true );
	}

	/**
	 * Track when a user has tax automation enabled.
	 */
	private static function track_tax_automation() {
		wc_admin_record_tracks_event( 'tasklist_task_completed', array( 'task_name' => 'tax_automated' ) );
	}
}