WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. aeight
    Member
    Posted 11 months ago #

    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.

    Greets

    http://wordpress.org/plugins/woocommerce/

  2. jameskoster
    Member
    Plugin Author

    Posted 11 months 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
    Member
    Posted 11 months 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
    Member
    Posted 11 months 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 );
    }
    add_action('init','remove_loop_button');

    [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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.