Hello, my Add To Cart button isn’t working and this is the error code. Does anyone know how to fix this?
It looks like that function was removed from use and replaced with an approach utilizing the FormData.
Here is code that I found after a quick search:
delete config.headers['Content-Type'];
const formData = new FormData(this.form);
formData.append('sections', this.cartNotification.getSectionsToRender().map((section) => section.id));
formData.append('sections_url', window.location.pathname);
config.body = formData;
As referenced here: https://github.com/Shopify/dawn/commit/2d1c8321c9e2b4a3ce0a1857b7e29ec8d621bbf5#diff-92893e2971854a3c90f551e524273b7ae674cc9fb847096959496ee3bdb470baR26 and here: Support file upload line item properties on Product Forms and Cart Notifications by LucasLacerdaUX · Pull Request #745 · Shopify/dawn · GitHub
I am unsure how your theme is missing the code but if you include that in place of the old code as it shows in the first link I shared above it might work (as I have not tested it).
Hope that helps!
Thank you, I tried this and it did not work.
Do you have any other solutions? Thank you!!!
