WooCommerce - excelling eCommerce
Hide "add to cart" on free products (4 posts)

  1. aeight
    Posted 1 year ago #


    is there any way to hide the "add to cart"-Button on the single-Product page IF the product is for free ? I'm making a big CSV-Import and some product-prices are set to zero - so i just want to hide the "add to cart" button on these products, so these are not buyable.



  2. jameskoster
    Plugin Author

    Posted 1 year ago #

    Yup, just create a new function hooked into init which checks a product price, if it's zero remove the add to cart button using remove_action().

  3. aeight
    Posted 1 year ago #

    Great - thanks for the quick answer! Would you be so kind and post the code here? Don't know how to do it on my own :(

  4. aeight
    Posted 1 year ago #

    So i can remove the button with:

    function remove_loop_button(){
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    But how can i do this only if the price is zero ? Please help

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.