The add to cart button is not working on my product page, the following error shows up in the console:
Uncaught TypeError: Cannot read property 'submit' of undefined at HTMLButtonElement.onclick
This is the code on the add to basket button –
<button type="button" title="Add to Basket" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span>Add to Basket</span></span></button>
Having had a look I think I may have found the reason that it is not adding to cart. The form which the button submits has a different id to the actual form. Is this the reason for not submitting? And if so, how do I change this?
<form action="https://cbccomputers.com/checkout/cart/add/uenc/aHR0cHM6Ly9jYmNjb21wdXRlcnMuY29tL3Bjcy1sYXB0b3BzLXRhYmxldHMvY29tcHV0ZXJzL3Bjcy9kZWxsLXZvc3Ryby0zMjY4LWkzLmh0bWw_X19fU0lEPVU,/product/61297/form_key/Qj8R0mDVuAViFpbP/" method="post" id="product_addtocart_form">
Relatively new to Magento and developing so any advice is helpful as it is quite urgent?
Thanks.
Best Answer
change code from the original
to