From c4e071480aa37d1ebadf1c2ce36a4f34fa57905f Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 4 Jan 2019 11:04:12 +0000 Subject: [PATCH 1/6] phpcs --- .../settings/class-wc-settings-shipping.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/includes/admin/settings/class-wc-settings-shipping.php b/includes/admin/settings/class-wc-settings-shipping.php index 797551b0925..05ea60a8374 100644 --- a/includes/admin/settings/class-wc-settings-shipping.php +++ b/includes/admin/settings/class-wc-settings-shipping.php @@ -76,8 +76,8 @@ class WC_Settings_Shipping extends WC_Settings_Page { if ( '' === $current_section ) { $settings = apply_filters( - 'woocommerce_shipping_settings', array( - + 'woocommerce_shipping_settings', + array( array( 'title' => __( 'Shipping options', 'woocommerce' ), 'type' => 'title', @@ -229,7 +229,6 @@ class WC_Settings_Shipping extends WC_Settings_Page { wp_die( esc_html__( 'Zone does not exist!', 'woocommerce' ) ); } - $allowed_countries = WC()->countries->get_allowed_countries(); $wc_shipping = WC_Shipping::instance(); $shipping_methods = $wc_shipping->get_shipping_methods(); $continents = WC()->countries->get_continents(); @@ -247,7 +246,9 @@ class WC_Settings_Shipping extends WC_Settings_Page { } wp_localize_script( - 'wc-shipping-zone-methods', 'shippingZoneMethodsLocalizeScript', array( + 'wc-shipping-zone-methods', + 'shippingZoneMethodsLocalizeScript', + array( 'methods' => $zone->get_shipping_methods( false, 'json' ), 'zone_name' => $zone->get_zone_name(), 'zone_id' => $zone->get_id(), @@ -272,12 +273,13 @@ class WC_Settings_Shipping extends WC_Settings_Page { * Show zones */ protected function zones_screen() { - $allowed_countries = WC()->countries->get_allowed_countries(); $continents = WC()->countries->get_continents(); $method_count = wc_get_shipping_method_count(); wp_localize_script( - 'wc-shipping-zones', 'shippingZonesLocalizeScript', array( + 'wc-shipping-zones', + 'shippingZonesLocalizeScript', + array( 'zones' => WC_Shipping_Zones::get_zones( 'json' ), 'default_zone' => array( 'zone_id' => 0, @@ -336,7 +338,9 @@ class WC_Settings_Shipping extends WC_Settings_Page { protected function output_shipping_class_screen() { $wc_shipping = WC_Shipping::instance(); wp_localize_script( - 'wc-shipping-classes', 'shippingClassesLocalizeScript', array( + 'wc-shipping-classes', + 'shippingClassesLocalizeScript', + array( 'classes' => $wc_shipping->get_shipping_classes(), 'default_shipping_class' => array( 'term_id' => 0, @@ -354,7 +358,8 @@ class WC_Settings_Shipping extends WC_Settings_Page { // Extendable columns to show on the shipping classes screen. $shipping_class_columns = apply_filters( - 'woocommerce_shipping_classes_columns', array( + 'woocommerce_shipping_classes_columns', + array( 'wc-shipping-class-name' => __( 'Shipping class', 'woocommerce' ), 'wc-shipping-class-slug' => __( 'Slug', 'woocommerce' ), 'wc-shipping-class-description' => __( 'Description', 'woocommerce' ), From ff3a852b7f818fbf10dbcdab9f1866cecb7a042c Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 4 Jan 2019 11:04:17 +0000 Subject: [PATCH 2/6] Zones should use shipping countries, not allowed countries --- includes/admin/settings/class-wc-settings-shipping.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/admin/settings/class-wc-settings-shipping.php b/includes/admin/settings/class-wc-settings-shipping.php index 05ea60a8374..59de3406339 100644 --- a/includes/admin/settings/class-wc-settings-shipping.php +++ b/includes/admin/settings/class-wc-settings-shipping.php @@ -229,6 +229,7 @@ class WC_Settings_Shipping extends WC_Settings_Page { wp_die( esc_html__( 'Zone does not exist!', 'woocommerce' ) ); } + $allowed_countries = WC()->countries->get_shipping_countries(); $wc_shipping = WC_Shipping::instance(); $shipping_methods = $wc_shipping->get_shipping_methods(); $continents = WC()->countries->get_continents(); @@ -273,6 +274,7 @@ class WC_Settings_Shipping extends WC_Settings_Page { * Show zones */ protected function zones_screen() { + $allowed_countries = WC()->countries->get_shipping_countries(); $continents = WC()->countries->get_continents(); $method_count = wc_get_shipping_method_count(); From da32fe3b8ae73448a33830839c3e273256029ca3 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 4 Jan 2019 11:05:29 +0000 Subject: [PATCH 3/6] Include country name alongside states so selectwoo can search properly Seems 'alt' was there in the hope select2 would search that but it's not possible without custom matchers. This instead will show state and country like this: `New York, United States.` This lets you find NY by searching for US --- .../html-admin-page-shipping-zone-methods.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php b/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php index 9524a51a17d..d376613d3f4 100644 --- a/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php +++ b/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php @@ -42,16 +42,18 @@ if ( ! defined( 'ABSPATH' ) ) {