cancel
Showing results for 
Search instead for 
Did you mean: 

shipping method custom html dom changes

shipping method custom html dom changes

version 2.4.3, this issue seems to be resolved in v2.4.5

 

On guest checkout, changing the dom in the shipping method list, something triggers a new call to /default/rest/default/V1/guest-carts/:quoteid/estimate-shipping-methods, so any changes you do are overriden. 

 

Goal: I'm trying to add a button via Js to the shipping method when certain conditions are met. 

As far as I could backtrace it an observer checks for changes in the checkout. this ends up in function in knockout.js
isDifferent: function(oldValue, newValue) {
return !this['equalityComparer'] || !this['equalityComparer'](oldValue, newValue);
}

Added a console log to that function to check what's inside in  this['equalityComparer']. Turns out it's always 
function valuesArePrimitiveAndEqual(a, b) {
var oldValueIsPrimitive = (a === null) || (typeof(a) in primitiveTypes);
return oldValueIsPrimitive ? (a === b) : false;
}

Even when it's an object. 

What seems to be happening is the shipping settings are re-created, so even though the values are the same the reference is different and therefore it triggers a call to refresh the shipping-methods 

Is there any way around this that does not involve declaring a custom field? Perhaps a way to stop propagation on select-shipping-method so that the dom observer is not triggered?