From ada613b105cfcd009808ac0a36257304a925ea0e Mon Sep 17 00:00:00 2001 From: Robert Grundeken Date: Mon, 17 Feb 2020 10:03:57 +0100 Subject: [PATCH 1/7] GW-34 Free Shipping Added --- assets/js/admin/gls_admin.js | 23 ++++ includes/admin/class-gls-admin.php | 1 + .../class-gls-settings-delivery-options.php | 5 +- ...settings-woocommerce-shipping-instance.php | 90 +++++++++++++++ includes/class-gls-delivery-options.php | 63 ++++++++++- languages/gls-woocommerce-nl_NL.mo | Bin 11621 -> 12672 bytes languages/gls-woocommerce-nl_NL.po | 105 +++++++++++++----- languages/gls-woocommerce.pot | 91 ++++++++++----- 8 files changed, 316 insertions(+), 62 deletions(-) create mode 100644 includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php diff --git a/assets/js/admin/gls_admin.js b/assets/js/admin/gls_admin.js index 600b1ae..af8d528 100644 --- a/assets/js/admin/gls_admin.js +++ b/assets/js/admin/gls_admin.js @@ -5,6 +5,29 @@ return; } + // Toggle free shipping fields (via ajax request) + $(document).on("change", '#tig_glstig_gls_freeshipping_enabled', function() { + toggleFreeShippingFields($(this).val()); + }); + + $(document).on("click", '.wc-shipping-zone-method-settings', function() { + toggleFreeShippingFields($('#tig_glstig_gls_freeshipping_enabled').val()); + }); + + function toggleFreeShippingFields(value) { + $("#tig_glstig_gls_freeshipping").parent().parent().parent().css('display','none'); + $("#tig_glstig_gls_freeshipping_extra").parent().parent().parent().parent().css('display','none'); + + if (value == 1 ) { + $("#tig_glstig_gls_freeshipping").parent().parent().parent().css('display','table-row'); + $("#tig_glstig_gls_freeshipping_extra").parent().parent().parent().parent().css('display','table-row'); + } + } + + if ($("#tig_glstig_gls_freeshipping_enabled").length) { + toggleFreeShippingFields($("#tig_glstig_gls_freeshipping_enabled").val()); + } + var is_blocked = function ($node) { return $node.is('.processing') || $node.parents('.processing').length; }; diff --git a/includes/admin/class-gls-admin.php b/includes/admin/class-gls-admin.php index b011ac8..461a298 100644 --- a/includes/admin/class-gls-admin.php +++ b/includes/admin/class-gls-admin.php @@ -61,6 +61,7 @@ public function includes() include_once dirname(__FILE__) . '/class-gls-admin-assets.php'; include_once dirname(__FILE__) . '/class-gls-admin-meta-boxes.php'; include_once dirname(__FILE__) . '/class-gls-admin-api-notice.php'; + include_once dirname(__FILE__) . '/settings/class-gls-settings-woocommerce-shipping-instance.php'; } /** diff --git a/includes/admin/settings/class-gls-settings-delivery-options.php b/includes/admin/settings/class-gls-settings-delivery-options.php index 64ad05e..3f8d626 100644 --- a/includes/admin/settings/class-gls-settings-delivery-options.php +++ b/includes/admin/settings/class-gls-settings-delivery-options.php @@ -389,8 +389,9 @@ public function get_gls_shipping_methods($methods, $zone) if (!empty($methods)) { foreach ($methods as $method) { if (get_class($method) == 'GLS_Shipping_Method' ) { - $enabled_string = ($method->enabled == 'yes') ? __('active', 'gls_woocommerce') : __('deactive', 'gls_woocommerce'); - $gls_shipping_method[] = '' . $method->title . '  ' . $enabled_string. ''; + $enabled_string = ($method->enabled == 'yes') ? __('active', 'gls-woocommerce') : __('deactive', 'gls-woocommerce'); + $freeshipping_string = ((int)$method->instance_settings['freeshipping_enabled'] > 0 && (float)$method->instance_settings['freeshipping'] > 0) ? sprintf(__('free shipping above %s %s (excl. tax) ', 'gls-woocommerce'), (float)$method->instance_settings['freeshipping'], get_option('woocommerce_currency')) : __('no free shipping', 'gls-woocommerce'); + $gls_shipping_method[] = '' . $method->title . '  ' . $enabled_string. '  (' . $freeshipping_string . ')'; } } } diff --git a/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php b/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php new file mode 100644 index 0000000..6f7a353 --- /dev/null +++ b/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php @@ -0,0 +1,90 @@ + __('Enable free shipping','gls-woocommerce'), + 'type' => 'select', + 'description' => __('Enable free shipping above an order amount','gls-woocommerce'), + 'desc_tip' => true, + 'options' => array(1 => 'Yes', 0 => 'No'), + 'default' => '0' + ); + + $form_field_freeshipping = array( + 'title' => __('Apply free shipping above order amount','gls-woocommerce'), + 'type' => 'price', + 'disabled' => false, + 'description' => __('Enter the order amount (excl. tax) above (and equal) which free shipping will be applied.','gls-woocommerce'), + 'desc_tip' => true, + 'default' => '0' + ); + + $form_field_freeshipping_extra = array( + 'title' => __('Apply free shipping to extra services','gls-woocommerce'), + 'type' => 'checkbox', + 'description' => __('Enable this when extra service costs are also free when free shipping applies.','gls-woocommerce'), + 'default' => 'no', + 'desc_tip' => true + ); + + + $form_fields['freeshipping_enabled'] = $form_field_freeshipping_enabled; + $form_fields['freeshipping'] = $form_field_freeshipping; + $form_fields['freeshipping_extra'] = $form_field_freeshipping_extra; + + return $form_fields; + } +} + +new GLS_Settings_Woocommerce_Shipping_Instance(); \ No newline at end of file diff --git a/includes/class-gls-delivery-options.php b/includes/class-gls-delivery-options.php index 5539156..50b7f05 100644 --- a/includes/class-gls-delivery-options.php +++ b/includes/class-gls-delivery-options.php @@ -389,20 +389,81 @@ public static function adjust_shipping_rate($rates){ return $rates; } + // Free Shipping + $freeshipping = self::calculate_gls_freeshipping(); + $freeshipping_extra = self::get_shipping_method_instance_setting('freeshipping_extra'); + $service = $session->get('gls_service'); $details = $service['details'] ?? []; $fee = $details['fee'] ?? ''; foreach ($rates as &$rate) { if ($rate->get_method_id() == 'tig_gls') { - $rate->cost += (float) $fee; + if ($freeshipping) { + $rate->cost = 0; + } + + if (!$freeshipping || $freeshipping_extra == "no") { + $rate->cost += (float)$fee; + } + + if ($rate->cost <= 0) { + $rate->cost = 0; + $rate->label = $rate->label . __(' (free shipping)','gls-woocommerce'); + } + $tax_array = WC_Tax::calc_tax($rate->cost, WC_Tax::get_rates(), false ); + $rate->set_taxes($tax_array); } } return $rates; } + /** + * @return bool + */ + public static function calculate_gls_freeshipping() + { + $enabled = (int)self::get_shipping_method_instance_setting('freeshipping_enabled'); + + if (!$enabled) { + return false; + } + + $freeshipping_amount = (float)self::get_shipping_method_instance_setting('freeshipping'); + + if ($freeshipping_amount > 0) { + $session = WC()->session; + $cart_totals = $session->get('cart_totals'); + if ($freeshipping_amount <= ($cart_totals['subtotal'] + $cart_totals['subtotal_tax'])) { + return true; + } + } + return false; + } + + /** + * @param $setting_name + * @return |null + */ + public static function get_shipping_method_instance_setting($setting_name) + { + $session = WC()->session; + $chosen_shipping_method = $session->get('chosen_shipping_methods'); + + $shipping_method_id = explode(':',$chosen_shipping_method[0]); + $current_shipping_methods = WC()->shipping->get_shipping_methods(); + $current_shipping_method = $current_shipping_methods[$shipping_method_id[1]]; + + //get instance setting + if ($current_shipping_method->instance_settings[$setting_name]) { + return $current_shipping_method->instance_settings[$setting_name]; + } + + return null; + } + /** * @param $order * @param $data diff --git a/languages/gls-woocommerce-nl_NL.mo b/languages/gls-woocommerce-nl_NL.mo index 2323066e8b2a1afb1ffa581d31267e3c99031067..4ea5311f1e515c0702fe4b5a84d35cbdcc2979a5 100644 GIT binary patch delta 3657 zcma*pe{5Cd9mnyfE48%cM=N0EhvUIf=xwp`Qz+n&-%wC=LMy^L&%O7wz3t)N%e|+) zfV#^TjGHzjt`&PX%jreVxh|gjZ zK8IWIm$(i;##y+wA%0E|Zsa(`1$Y))@Q?Uc(xE2RGq|s2f&I zHfAgK;&u2_NyLYi!oYzWNxO* z*^3%r!To-;nfz-lo^mI?kLu{>*ny`}HSlMoT1^w{pwzFyrI^Am;WKFQS9mx60dL1e ztdHKRK~xbw>O6%i!b@d#)X~443#lk|*o{BKW2l*RP!QX2B`(9GxExQTet!$Krk7DO zZlYHeYYS2aW)bSTb;v51ZKw>Fd)ZN{9>L>P%mnp-1W(fqx1)aFg6g;j7vbZ`B+Xe= z242N2_%GB1)>3K8&>;Q*e~1=Wv(fYRA(=0mfSpcGgs2C-fIIObY5;TR#Z}*mD$?cH zh3iq*KjF^5h?6<~HEL$BI4?VA-W<>T4kX#88z<@g&$FW&AI4~AsQ3LW>U;1qDrJ|D zNtm}#Z%G}!vpQxWYQ`JzG0fwW_z@1{V=S}=t^(Kt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2=wfe4 zxuKW Date: Fri, 21 Feb 2020 16:30:52 +0100 Subject: [PATCH 2/7] Removed the Display of prices from extra services by free shipping --- ...settings-woocommerce-shipping-instance.php | 2 +- includes/class-gls-delivery-options.php | 34 ++++++++++++++++-- languages/gls-woocommerce-nl_NL.mo | Bin 12672 -> 12742 bytes languages/gls-woocommerce-nl_NL.po | 14 ++++++-- languages/gls-woocommerce.pot | 34 ++++++++++++++---- 5 files changed, 71 insertions(+), 13 deletions(-) diff --git a/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php b/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php index 6f7a353..5dd1c89 100644 --- a/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php +++ b/includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php @@ -57,7 +57,7 @@ public function filter_woocommerce_shipping_instance_form_fields_tig_gls ($form_ 'type' => 'select', 'description' => __('Enable free shipping above an order amount','gls-woocommerce'), 'desc_tip' => true, - 'options' => array(1 => 'Yes', 0 => 'No'), + 'options' => array(0 => __('No','gls-woocommerce'), 1 => __('Yes','gls-woocommerce')), 'default' => '0' ); diff --git a/includes/class-gls-delivery-options.php b/includes/class-gls-delivery-options.php index 50b7f05..057361c 100644 --- a/includes/class-gls-delivery-options.php +++ b/includes/class-gls-delivery-options.php @@ -240,9 +240,20 @@ function (&$option) use ($enabled_options) { */ private function additional_fee($option, $enabled_options) { + + $freeshipping = self::has_gls_freeshipping(); + $freeshipping_extra = self::get_shipping_method_instance_setting('freeshipping_extra'); + if ($freeshipping && $freeshipping_extra =="yes") { + return ''; + } + $code = 'gls_' . strtolower($option->service); $fee = isset($enabled_options[$code]) ? $enabled_options[$code]->additional_fee : ''; + if ($fee < 0 && $freeshipping) { + return ''; + } + return $fee; } @@ -390,7 +401,7 @@ public static function adjust_shipping_rate($rates){ } // Free Shipping - $freeshipping = self::calculate_gls_freeshipping(); + $freeshipping = self::has_gls_freeshipping(); $freeshipping_extra = self::get_shipping_method_instance_setting('freeshipping_extra'); $service = $session->get('gls_service'); @@ -423,7 +434,7 @@ public static function adjust_shipping_rate($rates){ /** * @return bool */ - public static function calculate_gls_freeshipping() + public static function has_gls_freeshipping() { $enabled = (int)self::get_shipping_method_instance_setting('freeshipping_enabled'); @@ -456,6 +467,13 @@ public static function get_shipping_method_instance_setting($setting_name) $current_shipping_methods = WC()->shipping->get_shipping_methods(); $current_shipping_method = $current_shipping_methods[$shipping_method_id[1]]; + //fallback; manual init instance to get to config settings + if (!isset($current_shipping_method)) { + $current_shipping_method = $current_shipping_methods[$shipping_method_id[0]]; + $current_shipping_method->instance_id = $shipping_method_id[1]; + $current_shipping_method->init_instance_settings(); + } + //get instance setting if ($current_shipping_method->instance_settings[$setting_name]) { return $current_shipping_method->instance_settings[$setting_name]; @@ -494,6 +512,18 @@ public function format_shop_delivery_fee() return; } + $freeshipping = self::has_gls_freeshipping(); + + //negative fee + free shipping means display no value + if ($additional_fee < 0 && $freeshipping) { + return; + } + + $freeshipping_extra = self::get_shipping_method_instance_setting('freeshipping_extra'); + if ($freeshipping && $freeshipping_extra == "yes") { + return; + } + $tax = WC_Tax::calc_tax((float) $additional_fee, WC_Tax::get_rates(), false); return wc_price((float) reset($tax) + (float) $additional_fee); diff --git a/languages/gls-woocommerce-nl_NL.mo b/languages/gls-woocommerce-nl_NL.mo index 4ea5311f1e515c0702fe4b5a84d35cbdcc2979a5..985c61e5981b6c3217fd5365c68908bed5dcce10 100644 GIT binary patch delta 2818 zcmYk;dra0<9LMp)9Uh3A+*Be$Fa#x#OF|HF5s4m1K@^FIi-1Cz2pS6ch#T43=%SNN zSGLuhvM|!zArgrge`79TSTG-yYc69V@j9yMM~uSXunO;CDdvS5vkC`M&v_Foa0=Jr zpO}X6Va8m*5?rTl=c&Zf5b=O90horBn2Gwre%yi+7>IX~A2ZJfUp4o!98I_}4?+b- zU^{By{ix?0w_e0luD{1vP5VBT1R6s47K1b?NR!FJ4On8Y`%nWof-yLXn(+kc`ybo( zS+oL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-nl_NL.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: GLS for Woocommerce v1\n" -"POT-Creation-Date: 2020-02-14 16:13+0100\n" -"PO-Revision-Date: 2020-02-14 16:14+0100\n" +"POT-Creation-Date: 2020-02-21 15:37+0100\n" +"PO-Revision-Date: 2020-02-21 15:38+0100\n" "Last-Translator: \n" "Language-Team: TIG support@tig.nl\n" "Language: nl\n" @@ -432,6 +432,14 @@ msgstr "Gratis verzenden aanzetten" msgid "Enable free shipping above an order amount" msgstr "Verzendkosten vervallen bij orderbedrag vanaf" +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:60 +msgid "No" +msgstr "Nee" + +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:60 +msgid "Yes" +msgstr "Ja" + #: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:65 msgid "Apply free shipping above order amount" msgstr "Verzendkosten vervallen bij orderbedrag vanaf" @@ -500,7 +508,7 @@ msgstr "Klonen verboden." msgid "Unserializing instances of this class is forbidden." msgstr "Unserializing instanties van deze klasse is verboden." -#: includes/class-gls-delivery-options.php:412 +#: includes/class-gls-delivery-options.php:423 msgid " (free shipping)" msgstr " (gratis verzenden)" diff --git a/languages/gls-woocommerce.pot b/languages/gls-woocommerce.pot index 5177b09..72fd70c 100644 --- a/languages/gls-woocommerce.pot +++ b/languages/gls-woocommerce.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2020-02-14 11:27+0100\n" +"POT-Creation-Date: 2020-02-21 15:37+0100\n" "PO-Revision-Date: 2020-01-06 13:34+0100\n" "Last-Translator: \n" "Language-Team: \n" @@ -392,21 +392,37 @@ msgstr "" msgid "The \"%s\" delivery option is currently disabled" msgstr "" -#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:55 -msgid "Apply free shipping above order amount (0 = off)" +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:56 +msgid "Enable free shipping" msgstr "" -#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:57 +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:58 +msgid "Enable free shipping above an order amount" +msgstr "" + +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:60 +msgid "No" +msgstr "" + +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:60 +msgid "Yes" +msgstr "" + +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:65 +msgid "Apply free shipping above order amount" +msgstr "" + +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:68 msgid "" "Enter the order amount (excl. tax) above (and equal) which free shipping " -"will be applied. 0 = free shipping turned off." +"will be applied." msgstr "" -#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:63 +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:74 msgid "Apply free shipping to extra services" msgstr "" -#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:65 +#: includes/admin/settings/class-gls-settings-woocommerce-shipping-instance.php:76 msgid "" "Enable this when extra service costs are also free when free shipping " "applies." @@ -456,6 +472,10 @@ msgstr "" msgid "Unserializing instances of this class is forbidden." msgstr "" +#: includes/class-gls-delivery-options.php:423 +msgid " (free shipping)" +msgstr "" + #: includes/options/class-gls-option-s12.php:41 msgid "TimeDefiniteService (Saturday before 12.00 AM)" msgstr "" From 7caecf18fd9a454b57e90c1e3b8ea41f8cca862f Mon Sep 17 00:00:00 2001 From: Robert Grundeken Date: Fri, 21 Feb 2020 16:52:32 +0100 Subject: [PATCH 3/7] fixed: add to cart freezes, when no chosen shipping method --- includes/class-gls-delivery-options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-gls-delivery-options.php b/includes/class-gls-delivery-options.php index 057361c..d1c7955 100644 --- a/includes/class-gls-delivery-options.php +++ b/includes/class-gls-delivery-options.php @@ -468,7 +468,7 @@ public static function get_shipping_method_instance_setting($setting_name) $current_shipping_method = $current_shipping_methods[$shipping_method_id[1]]; //fallback; manual init instance to get to config settings - if (!isset($current_shipping_method)) { + if (!isset($current_shipping_method) && $chosen_shipping_method) { $current_shipping_method = $current_shipping_methods[$shipping_method_id[0]]; $current_shipping_method->instance_id = $shipping_method_id[1]; $current_shipping_method->init_instance_settings(); From dee44b614d96ad092bb0596be4a2cce8d987bcbf Mon Sep 17 00:00:00 2001 From: Jasper Smits Date: Wed, 26 Feb 2020 11:19:39 +0100 Subject: [PATCH 4/7] GLS2L7 fix voor altijd shopreturnlabel --- includes/api/label/class-gls-api-label-create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/api/label/class-gls-api-label-create.php b/includes/api/label/class-gls-api-label-create.php index 88c7e0a..57518ea 100644 --- a/includes/api/label/class-gls-api-label-create.php +++ b/includes/api/label/class-gls-api-label-create.php @@ -126,7 +126,7 @@ public function setBody() private function map_services($details, $type = null, $countryCode = 'NL') { $service = [ - "shopReturnService" => (bool) ($this->options['shop_return'] && $countryCode == 'NL') + "shopReturnService" => (bool) ($this->options['shop_return'] == 'yes' && $countryCode == 'NL') ]; switch ($type) { case 'ParcelShop': From db11746a7b4e7cb721df67268dc3a87dcf1afb0e Mon Sep 17 00:00:00 2001 From: Daan van den Bergh Date: Fri, 28 Feb 2020 16:06:22 +0100 Subject: [PATCH 5/7] GLS2L-8: Entire $_POST array was being cleaned, even when $clean was set to false. Now works as expected. --- includes/class-gls.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/class-gls.php b/includes/class-gls.php index 5c714a4..7079a52 100644 --- a/includes/class-gls.php +++ b/includes/class-gls.php @@ -305,7 +305,11 @@ public function ajax_url() */ public function post($key = null, $clean = true) { - if (!$key) { + if (!$key && !$clean) { + return wp_unslash($_POST); + } + + if (!$key && $clean) { return wc_clean(wp_unslash($_POST)); } From 1eeeda962011a8423054c425845dad39427aa8df Mon Sep 17 00:00:00 2001 From: Robert Grundeken Date: Fri, 6 Mar 2020 00:33:57 +0100 Subject: [PATCH 6/7] Fix for missing email when creating labels --- includes/api/label/class-gls-api-label-create.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/includes/api/label/class-gls-api-label-create.php b/includes/api/label/class-gls-api-label-create.php index 57518ea..52cb34e 100644 --- a/includes/api/label/class-gls-api-label-create.php +++ b/includes/api/label/class-gls-api-label-create.php @@ -90,6 +90,13 @@ public function setBody() $labelType = $this->get_label_type(); $shipmentId = $order->ID; + // @todo fix correct email when stored. This fixes that sometimes emailaddresses are empty or incomplete + // which stops the label creation + if ($delivery_address['email'] != $order->get_billing_email()) { + $delivery_address['email'] = $order->get_billing_email(); + $delivery_address['phone'] = $order->get_billing_phone(); + } + $data = GLS_Api::add_shipping_information(); $data["services"] = $this->map_services($delivery_option['details'], $delivery_option['type'], $delivery_address['countryCode']); $data["trackingLinkType"] = 'u'; From b6bfdbdb923ade9efc848c47dba251bfc0923696 Mon Sep 17 00:00:00 2001 From: Robert Grundeken Date: Mon, 9 Mar 2020 13:35:27 +0100 Subject: [PATCH 7/7] Version Bump, Updated ReadMe's, Updated language packs --- composer.json | 2 +- gls-woocommerce.php | 2 +- includes/class-gls.php | 2 +- languages/gls-woocommerce-nl_NL.mo | Bin 12742 -> 12742 bytes languages/gls-woocommerce-nl_NL.po | 6 +++--- languages/gls-woocommerce.pot | 4 ++-- readme.md | 3 +++ readme.txt | 5 ++++- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 0c230c8..ab92499 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ }, "type": "woocommerce-plugin", "license": "CC-BY-NC-ND-3.0", - "version": "1.1.3", + "version": "1.2.0", "authors": [ { "name": "TIG", diff --git a/gls-woocommerce.php b/gls-woocommerce.php index 2817b85..9b17a31 100644 --- a/gls-woocommerce.php +++ b/gls-woocommerce.php @@ -4,7 +4,7 @@ * Plugin Name: GLS for WooCommerce * Plugin URI: https://gls-group.eu/NL/nl/home * Description: GLS offers shipping solutions nationally and internationally in Europe and worldwide. By using this plugin you can integrate GLS shipping methods in WooCommerce. - * Version: 1.1.3 + * Version: 1.2.0 * Author: TIG * Author URI: https://tig.nl/ * License: GPL2v2 or later diff --git a/includes/class-gls.php b/includes/class-gls.php index 7079a52..9c1612c 100644 --- a/includes/class-gls.php +++ b/includes/class-gls.php @@ -44,7 +44,7 @@ final class GLS * * @var string */ - public $version = '1.1.3'; + public $version = '1.2.0'; /** * The single instance of the class. diff --git a/languages/gls-woocommerce-nl_NL.mo b/languages/gls-woocommerce-nl_NL.mo index 985c61e5981b6c3217fd5365c68908bed5dcce10..2e284c64c8d499c25c4ad41f038305892ac6ea92 100644 GIT binary patch delta 23 ecmX?>d@Ol`ge;e_u7Rb3p|O>*$z~d@Ol`ge;elu92aFp{bRz#bzbhB_aS_N(R{g diff --git a/languages/gls-woocommerce-nl_NL.po b/languages/gls-woocommerce-nl_NL.po index 5faeef9..f973f98 100644 --- a/languages/gls-woocommerce-nl_NL.po +++ b/languages/gls-woocommerce-nl_NL.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: GLS for Woocommerce v1\n" -"POT-Creation-Date: 2020-02-21 15:37+0100\n" -"PO-Revision-Date: 2020-02-21 15:38+0100\n" +"POT-Creation-Date: 2020-03-09 13:34+0100\n" +"PO-Revision-Date: 2020-03-09 13:34+0100\n" "Last-Translator: \n" "Language-Team: TIG support@tig.nl\n" "Language: nl\n" @@ -472,7 +472,7 @@ msgstr "Postcode en/of land niet opgegeven." msgid "No postcode specified." msgstr "Geen postcode opgegeven." -#: includes/api/label/class-gls-api-label-create.php:178 +#: includes/api/label/class-gls-api-label-create.php:185 msgid "Your order is sent." msgstr "Uw order is verstuurd." diff --git a/languages/gls-woocommerce.pot b/languages/gls-woocommerce.pot index 72fd70c..b190ad7 100644 --- a/languages/gls-woocommerce.pot +++ b/languages/gls-woocommerce.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2020-02-21 15:37+0100\n" +"POT-Creation-Date: 2020-03-09 13:34+0100\n" "PO-Revision-Date: 2020-01-06 13:34+0100\n" "Last-Translator: \n" "Language-Team: \n" @@ -436,7 +436,7 @@ msgstr "" msgid "No postcode specified." msgstr "" -#: includes/api/label/class-gls-api-label-create.php:178 +#: includes/api/label/class-gls-api-label-create.php:185 msgid "Your order is sent." msgstr "" diff --git a/readme.md b/readme.md index b2d7d33..9620ea9 100644 --- a/readme.md +++ b/readme.md @@ -45,6 +45,9 @@ Tracking links and PDF Labels are automatically included in the WooCommerce orde ### ShopReturnService * Automatically include a return label with every requested shipping label. +### Free Shipping +* Setup free shipping above an order amount per shipping destination. + ## Installation ### WordPress.org Repository diff --git a/readme.txt b/readme.txt index 4c35c6f..1d478ed 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Requires at least: 4.6 Tested up to: 5.3 WC Tested up to: 3.9 Requires PHP: 7.1 -Stable tag: 1.1.3 +Stable tag: 1.2.0 License: CC-BY-NC-ND-3.0 License URI: http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US @@ -39,6 +39,9 @@ To use this plugin you need to be a business customer of [GLS Netherlands](https * **FlexDeliveryService**: The recipient can choose an alternative delivery option before the first delivery attempt. * **ShopReturnService**: Automatically include a return label with every requested shipping label. += Free Shipping = +* Setup free shipping above an order amount per shipping destination. + == Installation == 1. From your WordPress admin area, go to: *Plugins > Add new*.