• Resolved silviubogan

    (@silviubogan)


    Hi!

    How can I replace the the Add to Cart button with a custom button? I managed to add the new button but I have to remove the old button and I do not know what is the correct way to do that. I would avoid writing a custom plugin, I would like to do this by customizing the Storefront theme only.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi
    You can use this line of code:

    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

    This code removes add to cart button, quantity, variation select area.
    If you need remove just add to cart button, use this snippet:

    add_action( 'woocommerce_single_product_summary', 'ywp_replace_add_to_cart_btn', 31 );
    function ywp_replace_add_to_cart_btn() {
    ?>
        <style>div.quantity,.single_add_to_cart_button{display:none}</style>
        // Remove add to cart button and quantity input box, restrict user use inspect element in him/her browser
        <script>jQuery(document).ready(function($){$('div.quantity,.single_add_to_cart_button'),remove()})</script>
    <?php
        // Add your custom button
        echo '<a href="#" class="single_add_to_cart_button button alt">Custom button</a>';
    }
    

    Good luck

    Thread Starter silviubogan

    (@silviubogan)

    Thank you!

    You’re welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I remove the the Add to Cart button in the product pages?’ is closed to new replies.