I am using the dawn theme. My third-party app will override the original Add to Cart button of the Dawn theme. However, the app won't update the increment icon of the cart sign, the pop-up of the cart notification won't show as well. In the code of the product-form.js file, the icon and notification are rendered after a response is passed. Anyone can give me some hints to modify my code to keep the original feature available?
please look in the code
if (!customElements.get('product-form')) {
customElements.define('product-form', class ProductForm extends HTMLElement {
constructor() {
super();
this.form.addEventListener('submit', this.onSubmitHandler.bind(this));
this.cart = document.querySelector('cart-notification');
}
onSubmitHandler(evt) {
evt.preventDefault();
const config = fetchConfig('javascript');
config.headers['X-Requested-With'] = 'XMLHttpRequest';
delete config.headers['Content-Type'];
const formData = new FormData(this.form);
fetch(`${routes.cart_add_url}`, config)
.then((response) => response.json())
.then((response) => {
this.cart.renderContents(response); //when item add //to cart, the
//renderContents() will be called to
//show cart notification
}
}
}
}