I want to replace the button ‘Add to cart’ from a specific category and from product type ‘simple product’.. And I want to do that on the page where I can see all the products and on inside page..

Here is something what i’ve tried..but just hide my button from all post of my category..

function western_custom_buy_buttons(){

   $product = get_product();

   if ( has_term( 'categ1', 'product_cat') ){

       // removing the purchase buttons

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

       remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );

       remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );

       remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );

       remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );

   }

}

add_action( 'wp', 'western_custom_buy_buttons' );

Read more here: Replace add to cart button with Read more on Woocommerce


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: