Skip to content

Commit 0a92e3d

Browse files
authored
Clear GLS info JS (#14)
* fix: clear gls info JS * fix: reference error. * fix: remove default
1 parent aed9565 commit 0a92e3d

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

README.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: goran87
33
Tags: gls, shipping, woocommerce shipping
44
Requires at least: 4.4
55
Tested up to: 6.7
6-
Stable tag: 1.2.3
6+
Stable tag: 1.2.4
77
License: GPLv2
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -63,6 +63,9 @@ To install and configure this plugin:
6363

6464
== Changelog ==
6565

66+
= 1.2.4 =
67+
* Fixed issue when changing shipping method would leave pickup info
68+
6669
= 1.2.3 =
6770
* Added WebshopEngine in request logs.
6871

assets/js/gls-shipping-public.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,28 @@
7777
}
7878
});
7979

80+
function clearGLSPickupInfo() {
81+
var glsPickupInfo = document.getElementById("gls-pickup-info");
82+
var glsPickupInfoData = document.getElementById(
83+
"gls-pickup-info-data"
84+
);
85+
86+
if (glsPickupInfo) {
87+
glsPickupInfo.innerHTML = "";
88+
glsPickupInfo.style.display = "none";
89+
}
90+
if (glsPickupInfoData) {
91+
glsPickupInfoData.value = "";
92+
}
93+
}
94+
8095
function updateCheckout() {
8196
var selectedShippingMethod = document.querySelector(
8297
'input[name="shipping_method[0]"]:checked'
8398
);
8499
var glsMap = document.getElementById("gls-map");
85-
var glsPickupInfo = document.getElementById("gls-pickup-info");
100+
101+
clearGLSPickupInfo();
86102

87103
if (selectedShippingMethod) {
88104
switch (selectedShippingMethod.value) {
@@ -92,15 +108,17 @@
92108
case "gls_shipping_method_parcel_shop":
93109
glsMap.setAttribute("filter-type", "parcel-shop");
94110
break;
95-
default:
96-
if (glsPickupInfo) {
97-
glsPickupInfo.style.display = "none";
98-
}
99-
break;
100111
}
101112
}
102113
}
103114

115+
// Event listener for shipping method change
116+
document.body.addEventListener("change", function (event) {
117+
if (event.target.name === "shipping_method[0]") {
118+
updateCheckout();
119+
}
120+
});
121+
104122
document.body.addEventListener("updated_checkout", updateCheckout);
105123
});
106124
})();

gls-shipping-for-woocommerce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Plugin Name: GLS Shipping for WooCommerce
55
* Description: Offical GLS Shipping for WooCommerce plugin
6-
* Version: 1.2.3
6+
* Version: 1.2.4
77
* Author: Inchoo
88
* License: GPLv2
99
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -24,7 +24,7 @@ final class GLS_Shipping_For_Woo
2424
{
2525
private static $instance;
2626

27-
private $version = '1.2.3';
27+
private $version = '1.2.4';
2828

2929
private function __construct()
3030
{

0 commit comments

Comments
 (0)