Skip to content
Advertisement

Custom “Out of stock” text based on product category in WooCommerce

Every out of stock product says “Out of Stock”

There are plenty of functions.php scripts that overwrite the text but I am only trying to overwrite the text specific to “Category A” or if I know the category “id” number, that could work too.

I found this script but it allows you to modify the txt per product id only.

JavaScript

How can I further adapt this script taking into account the category?

Advertisement

Answer

To check for product category you can use has_term()

JavaScript

Checks if the current post has any of given terms.


So you get:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement