Developer forum

Forum » Swift » Cart bug
Peter Leleulya
Peter Leleulya
Reply
Input and stock are strings.
When increasing the amount in the cart your function is comparing string values.
You should convert to floats, something like this:
 
var UpdateQuantity = debounce(function (input, stock) {
 
          i = parseFloat(input.value);
          s = parseFloat(stock);
 
          if (i <= s) {
input.classList.remove("is-invalid");
input.closest(".js-input-group").querySelector(".js-not-enough-stock").classList.add("d-none");
              console.log("submit");
document.querySelector("#ordersubmit").submit();
          } else {
input.value = stock;
input.classList.add("is-invalid");
input.closest(".js-input-group").querySelector(".js-not-enough-stock").classList.remove("d-none");
}
}, 300);

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Peter

Thanks - we have this on our list already - we are on it!

BR Nicolai

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

Hi,

The fix is out in 1.21.0.
https://github.com/dynamicweb/Swift/releases/tag/v1.21.0
The specific fix is here:
https://github.com/dynamicweb/Swift/commit/a140b794de50a3f53c2985b53afbf9171061d1b7

BR,
Merethe Vrå Andersen

 

You must be logged in to post in the forum