Hide 'add to cart' button ONLY on woocommerce shop/category pages

前端 未结 7 691
广开言路
广开言路 2021-01-03 15:56

I want to hide the button on my shop pages, but I would like to show it on other posts and pages.

I\'ve found this code to hide the add to cart button on my whole we

7条回答
  •  没有蜡笔的小新
    2021-01-03 16:31

    To remove the "Add to cart" button You need to use hook which not affect other code-

    add_action( 'woocommerce_after_shop_loop_item', 'remove_loop_button', 1 );
    function remove_loop_button()
    {
    if( is_product_category() || is_shop()) { 
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
    }
    }
    

    this will remove add to cart button from shop/category pages .

    Here you can get WooCommerce Action and Filter Hook -https://docs.woothemes.com/wc-apidocs/hook-docs.html

提交回复
热议问题