Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

Shipping::can_view()publicWC 1.0

Task visibility.

Метод класса: Shipping{}

Хуков нет.

Возвращает

true|false.

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

$Shipping = new Shipping();
$Shipping->can_view();

Код Shipping::can_view() WC 7.1.0

public function can_view() {
	if ( Features::is_enabled( 'shipping-smart-defaults' ) ) {
		if ( 'yes' === get_option( 'woocommerce_admin_created_default_shipping_zones' ) ) {
			// If the user has already created a default shipping zone, we don't need to show the task.
			return false;
		}

		/**
		 * Do not display the task when:
		 * - The store sells digital products only
		 * Display the task when:
		 * - We don't know where the store's located
		 * - The store is located in the UK, Australia or Canada
		*/

		if ( self::is_selling_digital_type_only() ) {
			return false;
		}

		$default_store_country = wc_format_country_state_string( get_option( 'woocommerce_default_country', '' ) )['country'];

		// Check if a store address is set so that we don't default to WooCommerce's default country US.
		// Similar logic: https://github.com/woocommerce/woocommerce/blob/059d542394b48468587f252dcb6941c6425cd8d3/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/index.js#L511-L516.
		$store_country = '';
		if ( ! empty( get_option( 'woocommerce_store_address', '' ) ) || 'US' !== $default_store_country ) {
			$store_country = $default_store_country;
		}

		// Unknown country.
		if ( empty( $store_country ) ) {
			return true;
		}

		return in_array( $store_country, array( 'AU', 'CA', 'GB' ), true );
	}

	return self::has_physical_products();
}