Skip to content
Advertisement

How to check for an array of product Ids in WooCommerce

I am changing the text of the Add to cart button on shop pages in WooCommerce for specific products:

JavaScript

If I have two or more IDs that need to have the same button text, how can I add an array of these ids into my function?

Advertisement

Answer

You can use in_array() PHP conditional function like:

JavaScript

It should work.

Also you should use $product missing arguments in your hooked function.

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