Create a shipping zone containing the store’s country when enabling shipping calculation from the setup wizard.

This commit is contained in:
Jeff Stieler 2017-04-20 23:02:59 -06:00
parent e96a1eb744
commit f2f803d007
1 changed files with 12 additions and 0 deletions

View File

@ -532,6 +532,18 @@ class WC_Admin_Setup_Wizard {
if ( $enable_shipping ) {
update_option( 'woocommerce_ship_to_countries', '' );
WC_Admin_Notices::add_notice( 'no_shipping_methods' );
/*
* Create a shipping zone containing the country the store is located in.
*/
$default_country = get_option( 'woocommerce_default_country' );
$location = wc_format_country_state_string( $default_country );
$zone = new WC_Shipping_Zone( null );
$zone->set_zone_order( 0 );
$zone->add_location( $location['country'], 'country' );
$zone->set_zone_name( $zone->get_formatted_location() );
$zone->save();
} else {
update_option( 'woocommerce_ship_to_countries', 'disabled' );
}