Support » Plugins and Hacks » Hide "add to cart" on free products

Hide "add to cart" on free products

  • Hey,

    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.



Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author James Koster


    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().

    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 🙁

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide "add to cart" on free products’ is closed to new replies.