Title: Bug found (with solution)
Last modified: November 22, 2016

---

# Bug found (with solution)

 *  [johnnynext](https://wordpress.org/support/users/johnnynext/)
 * (@johnnynext)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/bug-found-with-solution/)
 * Hi. I found a bug where the plugin removes the cart button for all the categories
   created prior to installation.
 * The solution should be where the code reads:
 * /**
    * Appling Filter on single product page * [@global](https://wordpress.org/support/users/global/)
   type $product */ if (!function_exists(‘wpiudacb_user_filter_addtocart_for_single_product_page’)){
 *  function wpiudacb_user_filter_addtocart_for_single_product_page() {
    global 
   $product; global $post; $terms = get_the_terms($product->id, ‘product_cat’); 
   $cat_option = ‘default’; $cat_inquire_us_link = ”; if (!empty($terms)) { foreach(
   $terms as $cat) { if (get_option(“wpiudacb_category_disable_add_to_cart_$cat-
   >term_id”) != ‘Default’) { $cat_option = get_option(“wpiudacb_category_disable_add_to_cart_
   $cat->term_id”); $cat_inquire_us_link = get_option(“wpiudacb_inqure_us_link_$
   cat->term_id”); } } } if ($cat_option != ‘default’) { remove_action(‘woocommerce_single_product_summary’,‘
   woocommerce_template_single_add_to_cart’, 30);
 * it should be:
 * /**
    * Appling Filter on single product page * [@global](https://wordpress.org/support/users/global/)
   type $product */ if (!function_exists(‘wpiudacb_user_filter_addtocart_for_single_product_page’)){
 *  function wpiudacb_user_filter_addtocart_for_single_product_page() {
    global 
   $product; global $post; $terms = get_the_terms($product->id, ‘product_cat’); 
   $cat_option = ‘default’; $cat_inquire_us_link = ”; if (!empty($terms)) { foreach(
   $terms as $cat) { if (get_option(“wpiudacb_category_disable_add_to_cart_$cat-
   >term_id”) != ‘Default’) { $cat_option = get_option(“wpiudacb_category_disable_add_to_cart_
   $cat->term_id”); $cat_inquire_us_link = get_option(“wpiudacb_inqure_us_link_$
   cat->term_id”); } } } **if (($cat_option != false ) && ($cat_option != ‘default’)){
   add_filter( ‘woocommerce_is_purchasable’, false );
 * This is because the options on those categories are not set. I also took the 
   liberty of replacing remove_action(‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’,
   30); with add_filter( ‘woocommerce_is_purchasable’, false ); that i think is 
   more clean.

The topic ‘Bug found (with solution)’ is closed to new replies.

 * ![](https://ps.w.org/remove-add-to-cart-woocommerce/assets/icon-128x128.png?rev
   =1786874)
 * [Remove Add to Cart WooCommerce](https://wordpress.org/plugins/remove-add-to-cart-woocommerce/)
 * [Support Threads](https://wordpress.org/support/plugin/remove-add-to-cart-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/remove-add-to-cart-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/remove-add-to-cart-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/remove-add-to-cart-woocommerce/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [johnnynext](https://wordpress.org/support/users/johnnynext/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/bug-found-with-solution/)
 * Status: not resolved