Support » Plugin: WooCommerce » Woocommerce: is_product_category is always false

  • Resolved rt32kd


    Based on the Woocommerce documentation I expect is_product_category() to return true when I’m on a categories page. I want to do this with is_purchasable() so that I can remove the “add to cart” button on each product in the category so that it forces them to buy on the product page.

    is_product_category() never fires however. Does anybody have any idea why? Or any alternative approach to determining if it’s a category page?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi rt32kd,
    To remove the “Add to cart” on an archieve/category page I am assuming you would want to remove it from the shop page as so people would have to go to the single product page as well, so you could just use:

    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );

    Hi Brad

    No I’d like to keep it purchasable on the single product page. The single product page has custom fields so I want to control where the customer adds the product to their basket.

    Hi @rt32kd, perfect! The code provided before will show “Add to cart” button on the single product page, but it will remove it from a category/archive page, a shop page and related product widgets.


    Hi @brad unfortunately it still doesn’t remove it – possibly for the same reason that is_product_category() doesn’t work? Is it possible that WordPress doesn’t recognise it as a categories page?

    Brad Davis


    @rt32kd, possibly the theme you are using has added it to another hook so when you use the above snippet the function is not there to unhook/remove. Are you able to look through your theme to see if it has been added/hooked to another function? It would look something like

    add_action( 'NEW HOOK NAME', 'woocommerce_template_loop_add_to_cart', XX );

    The “XX” would be a number and if find it you can copy it and then just change add_action to remove_action in your functions.php file.

    • This reply was modified 11 months ago by Brad Davis.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Woocommerce: is_product_category is always false’ is closed to new replies.