Question

Is their a way to disable ajax add to cart only on the product page but keep it working on other pages in Magento 2?

Edit: After the answer of William. I have checked the addtocart.phtml file but their is no piece of code like he suggested. Their are code available which is as follows:

<?php  if($block->isRedirectToCartEnabled()) : ?>

    <script type="text/x-magento-init">

        {

            "#product_addtocart_form": {

                "Magento_Catalog/product/view/validation": {

                    "radioCheckboxClosest": ".nested"

                }

            }

        }

    </script>

    <?php else : ?>

    <script type="text/x-magento-init">

        {

            "#product_addtocart_form": {

                "Magento_Catalog/js/validate-product": {}

            }

        }

    </script>

    <?php endif; ?>

Please help me to figure it out. Thanks

Was it helpful?

Solution

Replace your this code

<script type="text/x-magento-init">
        {
            "#product_addtocart_form": {
                "Magento_Catalog/product/view/validation": {
                    "radioCheckboxClosest": ".nested"
                }
            }
        }
</script>

WITH

<script type="text/x-magento-init">
{
    "#product_addtocart_form": {
        "Magento_Catalog/product/view/validation": {
            "bindSubmit": true,
            "radioCheckboxClosest": ".nested"
        }
    }
}
</script>

OTHER TIPS

In your theme, override /Magento_Catalog/templates/product/view/addtocart.phtml (see http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/templates/template-override.html) Assuming that your theme is based on the Magento's core theme, find the following script:

"catalogAddToCart": {
                "bindSubmit": true
            }

And change to bindSubmit to false.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top