Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks
Shipping::can_view()
Task visibility.
Method of the class: Shipping{}
No Hooks.
Return
true|false
.
Usage
$Shipping = new Shipping(); $Shipping->can_view();
Shipping::can_view() Shipping::can view code WC 9.7.1
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( 'CA', 'AU', 'NZ', 'SG', 'HK', 'GB', 'ES', 'IT', 'DE', 'FR', 'CL', 'AR', 'PE', 'BR', 'UY', 'GT', 'NL', 'AT', 'BE' ), true ); } return self::has_physical_products(); }