Hello @David1994 ,
We would like to help you with this issue. Here are some solutions that will work in your favor.
- Firstly, third-party apps may affect your theme functionality, because most of the apps donât function with the ajax cart.
- For making your theme functionality compatible with the third-party app you need to contact the app support they will resolve your issue.
- Also, if you check the documentation of the app you can get the solution there.
- You can also try to replace your Product-form.js code with the code below, this is the latest working code of this file and it will surely enable the theme functionality.
Here is the code for Product-form.js
if (!customElements.get(âproduct-formâ)) {
customElements.define(âproduct-formâ, class ProductFormextends HTMLElement {
constructor() {
super();
this.form = this.querySelector(âformâ);
this.form.querySelector(â[name=id]â).disabled = false;
this.form.addEventListener(âsubmitâ, this.onSubmitHandler.bind(this));
this.cartNotification = document.querySelector(âcart-notificationâ);
}
onSubmitHandler(evt) {
evt.preventDefault();
constsubmitButton = this.querySelector(â[type=âsubmitâ]â);
if (submitButton.classList.contains(âloadingâ)) return;
this.handleErrorMessage();
this.cartNotification.setActiveElement(document.activeElement);
submitButton.setAttribute(âaria-disabledâ, true);
submitButton.classList.add(âloadingâ);
this.querySelector(â.loading-overlay__spinnerâ).classList.remove(âhiddenâ);
constconfig = fetchConfig(âjavascriptâ);
config.headers[âX-Requested-Withâ] = âXMLHttpRequestâ;
deleteconfig.headers[âContent-Typeâ];
constformData = newFormData(this.form);
formData.append(âsectionsâ, this.cartNotification.getSectionsToRender().map((section) => section.id));
formData.append(âsections_urlâ, window.location.pathname);
config.body = formData;
fetch(${routes.cart_add_url}, config)
.then((response) => response.json())
.then((response) => {
if (response.status) {
this.handleErrorMessage(response.description);
return;
}
this.cartNotification.renderContents(response);
Shopify.shippingBar.update();
})
.catch((e) => {
console.error(e);
})
.finally(() => {
submitButton.classList.remove(âloadingâ);
submitButton.removeAttribute(âaria-disabledâ);
this.querySelector(â.loading-overlay__spinnerâ).classList.add(âhiddenâ);
});
}
handleErrorMessage(errorMessage = false) {
this.errorMessageWrapper = this.errorMessageWrapper || this.querySelector(â.product-form__error-message- wrapperâ);
this.errorMessage = this.errorMessage || this.errorMessageWrapper.querySelector(â.product-form__error-messageâ);
this.errorMessageWrapper.toggleAttribute(âhiddenâ, !errorMessage);
if (errorMessage) {
this.errorMessage.textContent = errorMessage;
}
}
});
}
Hope it helps. Please connect with us if you need further assistance.
All the best,
Team CedCommerce