Hey Alan,
Thanks for picking this up.
This is the current InitAdd function:
initAdd:function(){
if (document.getElementsByClassName(‘scope-product-form’).length !== 0) {
document.getElementsByClassName(‘scope-product-form’)[0].getElementsByTagName(‘form’)[0].addEventListener(‘submit’, function(_evt){
Cart.currentTotal = parseInt(document.getElementsByClassName(‘js-cart-count’)[0].innerHTML)
_evt.preventDefault();
let _data = new FormData(this);
let _object = {};
_data.forEach(function(_value, _key){
_object[_key] = _value;
});
let _json = JSON.stringify(_object);
let _xhr = new XMLHttpRequest();
_xhr.onreadystatechange = function() {
if (_xhr.readyState === 4) {
let _temp = document.createElement(“DIV”);
_temp.innerHTML = _xhr.responseText;
if (_temp.getElementsByClassName(‘c-cart__wrapper’).length !== 0 && document.getElementsByClassName(‘c-cart__wrapper’).length !== 0) {
document.getElementsByClassName(‘c-cart__wrapper’)[0].innerHTML = _temp.getElementsByClassName(‘c-cart__wrapper’)[0].innerHTML;
Cart.initQtyUpdate();
Cart.doToggle();
} else if (_temp.getElementsByClassName(‘c-cart’).length !== 0 && document.getElementsByClassName(‘c-cart’).length !== 0) {
document.getElementsByClassName(‘c-cart’)[0].innerHTML = _temp.getElementsByClassName(‘c-cart’)[0].innerHTML;
}
Resize.doResize();
let _success = document.getElementById(‘js-product-title’).innerHTML + ’ added to your cart’;
document.getElementById(‘js-cart-notification’).innerHTML = _success;
let _qtyEls = document.getElementsByClassName(‘c-cart__item__form__qty’);
if (_qtyEls.length > 0) {
for (let _k=0;_k<_qtyEls.length;_k++) {
Cart.checkQty(document.getElementsByClassName(‘c-cart__item__form__qty’)[_k], true);
}
}
if (Cart.timer !== null) {
clearTimeout(Cart.timer);
}
document.getElementsByClassName(‘js-cart-count’)[0].innerHTML = _temp.getElementsByClassName(‘js-cart-count’)[0].innerHTML;
if (Cart.currentTotal === parseInt(_temp.getElementsByClassName(‘js-cart-count’)[0].innerHTML)) {
alert(‘Sorry, we could not add any more of this product to your cart as stock is limited.’)
} else {
Cart.currentTotal = parseInt(_temp.getElementsByClassName(‘js-cart-count’)[0].innerHTML);
}
document.documentElement.classList.add(‘state-cart-open’);
Resize.doResize();
}
}
_xhr.open(“POST”, this.getAttribute(‘action’), true);
_xhr.setRequestHeader(‘Content-Type’, ‘application/json’);
_xhr.send(_json);
});
}
},
-
Helper.docReady(Boot.site) → Boot.site() → Cart.init() → Cart.initAdd()
-
Cart.initAdd() binds the first .scope-product-form form
(single-form binding) and posts JSON to the form action
. On response it swaps .c-cart__wrapper
/.c-cart
, updates .js-cart-count
, opens the drawer, and calls Resize.
409 Conflict Response details:
Request URL: https://kloke.com.au/cart/update.js?from_update_cart_attributes
Request Method: Post
X-Request-ID: a0a37a04-00e3-4cee-90b9-a549aef86442-1760677210
Request Payload: (sanitized):
{
“attributes”: { “GE_frtToken”: “[redacted]” }
}
I have a HAR file for you, would you mind sharing an email address or a secure upload link where I can send it privately? Please let me know if you need anything else
Thanks,
Dow