Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

Shipping::can_view │ public │ WC 1.0

Task visibility.

Method of the class: Shipping{}

No Hooks.

Returns

bool.

Usage

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

Shipping::can_view() code WC 11.1.2

public function can_view() {
	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( 'US', 'CA', 'AU', 'NZ', 'SG', 'HK', 'GB', 'ES', 'IT', 'DE', 'FR', 'MX', 'CO', 'CL', 'AR', 'PE', 'BR', 'UY', 'GT', 'NL', 'AT', 'BE', 'IE', 'PT' ), true );
}