Woocommerce - How to remove the Add to Cart Button on product listing

心不动则不痛 提交于 2019-12-03 04:06:18

I don't know how to do it from WooCommerce but with following code it is possible, just make sure that these PHP code should execute, so, put it at suitable place in PHP file where some PHP codes are executing, best place would be any wordpress plugin's base file, be careful while updating that plugin as these code will get lost after updating.

add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );

function remove_add_to_cart_buttons() {
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}

You can remove the add to cart button from product pages by adding this in woocommerce.php (located wp-content/plugins/woocommerce)

function Wp() {
remove_action( 'woocommerce_after_shop_loop_item', 
'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 
'woocommerce_template_single_add_to_cart');
return WooCommerce::instance();
}

After adding this code, reload the page and you will see that the button has been hidden.

You can also remove the add to cart button from specific Product pages using this code in functions.php (located in the theme folder):

add_filter('woocommerce_is_purchasable', 'wp_specific_product');
function wp_specific_product($purchaseable_product_wp, $product) 
{
return ($product->id == specific_product_id (512) ? false : 
$purchaseable_product_wp);
}

For reference you can see

https://wpitech.com/hide-disable-add-to-cart-button-in-woocommerce-store/

We have found the answer by coding a little bit, in wordpress:

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');

here: https://www.igniweb.com/remove-add-to-cart-button-wordpress/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!