Pricing Rules re-order bug in admin
-
Hi, thanks for this plugin.
There is a problem when i need to re-order pricing rules in admin Boxtal Connect rate page.
When I click on ‘save’ after one or more re-ordering, nothing happens in the window.
I could detect a javascript error in console :
TypeError: i.querySelector(…) is null
shipping-method.min.js:1:1983
submitForm http://xxx.com/wp-content/plugins/boxtal-connect/Boxtal/BoxtalConnectWoocommerce/assets/js/shipping-method.min.js?ver=1.1.6:1
submitForm self-hosted:974Please, answer on this forum, not by email.
Thanks in advance.Laurent
-
Hi, I got the same problem. I don’t know if it’s due to conflict between plugins or an error. But it’s really annoying if I have to rewrite each rules. Did you find a solution ?
J’ai unminify le fichier shipping-method.min.js
ligne 50 :submitForm: function(e)
Dans la boucle ligne55 : quand r vaut 0 : [name=’pricing-items[” + 0 + ‘][“price-from”]
ca n’existe pas car le HTMLTableRowElement inspecté vaut pour cette ligne : name=’pricing-items[1][“price-from”], soit l’ancienne position.Est ce possible d’avoir de l’aide, un patch?. Je n’ai pas le temps de devoir debugger. les input:name=pricing-items[ x ][..] devraient se raffraichir lorsqu’on drag&drop pour prendre leur nouvelle position ?
Je fais peut être fausse route, mais c’est urgent, mercifor (var r = 0; r < n.length; r++) { var i = n[r], o = { "price-from": i.querySelector("[name='pricing-items[" + r + ']["price-from"]\']').value, "price-to": i.querySelector("[name='pricing-items[" + r + ']["price-to"]\']').value, "weight-from": i.querySelector("[name='pricing-items[" + r + ']["weight-from"]\']').value, "weight-to": i.querySelector("[name='pricing-items[" + r + ']["weight-to"]\']').value, "shipping-class": Array.apply(null, i.querySelector("[name='pricing-items[" + r + ']["shipping-class"][]\']').options).filter(function(e) { return e.selected }).map(function(e) { return e.value }), "parcel-point-network": Array.apply(null, i.querySelector("[name='pricing-items[" + r + ']["parcel-point-network"][]\']').options).filter(function(e) { return e.selected }).map(function(e) { return e.value }), pricing: i.querySelector("[name='pricing-items[" + r + ']["pricing"]\']').value, "flat-rate": i.querySelector("[name='pricing-items[" + r + ']["flat-rate"]\']').value }; t.push(o) }Well, Boxtal doesn’t seem interested by this bug…
Looking at js code (thx @yohanndev) i can tell that those selector are more complicated than necessary.
There is no need to access td with complete name, taking just td which contains price-from or price-to… is enough to get the value.So in instruction beginning in line 57, i have replaced every selector from
querySelector("[name='pricing-items[" + r + ']["price-from"]\']')
to
querySelector("[name*='price-from']")
Like that we don’t care if row have number 0 or 1 or 2 inside its name.I give you the whole line 57 to replace :
o = { "price-from": i.querySelector("[name*='price-from']").value, "price-to": i.querySelector("[name*='price-to']").value, "weight-from": i.querySelector("[name*='weight-from']").value, "weight-to": i.querySelector("[name*='weight-to']").value, "shipping-class": Array.apply(null, i.querySelector("[name*='shipping-class']").options).filter(function(e) { return e.selected }).map(function(e) { return e.value }), "parcel-point-network": Array.apply(null, i.querySelector("[name*='parcel-point-network']").options).filter(function(e) { return e.selected }).map(function(e) { return e.value }), pricing: i.querySelector("[name*='pricing'").value, "flat-rate": i.querySelector("[name*='flat-rate'").value };Replacing just this line is enough to make re-ordering recorded again.
I hope that Boxtal will update the plugin fast with this code because i don’t like changes in plugin core files.
EDIT : Humm, my code don’t work… Flat-rate is not recorded anymore !
Be careful, i have missed 2 bracket in the previous code…
Here is the good one :o = { "price-from": i.querySelector("[name*='price-from']").value, "price-to": i.querySelector("[name*='price-to']").value, "weight-from": i.querySelector("[name*='weight-from']").value, "weight-to": i.querySelector("[name*='weight-to']").value, "shipping-class": Array.apply(null, i.querySelector("[name*='shipping-class']").options).filter(function(e) { return e.selected }).map(function(e) { return e.value }), "parcel-point-network": Array.apply(null, i.querySelector("[name*='parcel-point-network']").options).filter(function(e) { return e.selected }).map(function(e) { return e.value }), pricing: i.querySelector("[name*='pricing']").value, "flat-rate": i.querySelector("[name*='flat-rate']").value };-
This reply was modified 7 years, 3 months ago by
LaurentAngeli.
Well, there was another error on pricing selector.
Add brackets [] around ‘pricing’.
here is the final code which work.o={ "price-from":i.querySelector("[name*='price-from']").value, "price-to":i.querySelector("[name*='price-to']").value, "weight-from":i.querySelector("[name*='weight-from']").value, "weight-to":i.querySelector("[name*='weight-to']").value, "shipping-class":Array.apply(null,i.querySelector("[name*='shipping-class']").options).filter(function(e){return e.selected}).map(function(e){return e.value}), "parcel-point-network":Array.apply(null,i.querySelector("[name*='parcel-point-network']").options).filter(function(e){return e.selected}).map(function(e){return e.value}), pricing:i.querySelector("[name*='[\"pricing\"]']").value, "flat-rate":i.querySelector("[name*='flat-rate']").value };-
This reply was modified 7 years, 3 months ago by
LaurentAngeli.
-
This reply was modified 7 years, 3 months ago by
LaurentAngeli.
Fantastic, I like internet for this kind of idea sharing. Your code works perfectly. Thank you
-
This reply was modified 7 years, 3 months ago by
The topic ‘Pricing Rules re-order bug in admin’ is closed to new replies.