From bc69b7ec03bf155112338ba2fe07635b7dab65ab Mon Sep 17 00:00:00 2001 From: joerivanveen Date: Thu, 23 Nov 2023 11:20:16 +0100 Subject: [PATCH 1/2] fix(checkout): show delivery options for tablerate when appropriate --- view/frontend/web/js/model/checkout.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/view/frontend/web/js/model/checkout.js b/view/frontend/web/js/model/checkout.js index 3a2d743e..42bec01b 100644 --- a/view/frontend/web/js/model/checkout.js +++ b/view/frontend/web/js/model/checkout.js @@ -148,7 +148,22 @@ function( */ findRateByMethodCode: function(methodCode) { return Model.rates().find(function(rate) { - return rate.method_code === methodCode; + return rate.carrier_code === methodCode; + }); + }, + + /** + * Search the rates for the given method code. + * + * @param {string} carrierCode - Carrier code to search for. + * + * @returns {Object} - The found rate, if any. + */ + findOriginalRateByCarrierCode: function(carrierCode) { + return Model.rates().find(function(rate) { + if (-1 === rate.method_code.indexOf('myparcel')) { + return rate.carrier_code === carrierCode; + } }); }, @@ -185,8 +200,14 @@ function( if ('undefined' !== typeof MyParcelConfig && MyParcelConfig.hasOwnProperty('methods')) { MyParcelConfig.methods.forEach(function(code) { + const method = Model.findOriginalRateByCarrierCode(code); + + if (! method) { + return; + } + try { - document.getElementById('label_method_' + code + '_' + code).remove(); + document.getElementById('label_method_' + method.method_code + '_' + method.carrier_code).parentNode.remove(); } catch (e) { // when the element is not there as such, it is already ok } @@ -197,7 +218,6 @@ function( row.style.display = 'none'; }); }, - /** * Get shipping method rows by finding the columns with a matching method_code and grabbing their parent. * From f21f90c4847299ae28764bbf0b53c3f675c426db Mon Sep 17 00:00:00 2001 From: joerivanveen Date: Thu, 23 Nov 2023 13:26:00 +0100 Subject: [PATCH 2/2] fix(checkout): show delivery options for tablerate when appropriate --- view/frontend/web/js/model/checkout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/web/js/model/checkout.js b/view/frontend/web/js/model/checkout.js index 42bec01b..3adb8c5c 100644 --- a/view/frontend/web/js/model/checkout.js +++ b/view/frontend/web/js/model/checkout.js @@ -148,7 +148,7 @@ function( */ findRateByMethodCode: function(methodCode) { return Model.rates().find(function(rate) { - return rate.carrier_code === methodCode; + return rate.carrier_code === methodCode || rate.method_code === methodCode; }); },