Change Add To Cart button text based on Woocommerce parent product categories
问题 I am using the following code to change the wording on a Woo product add to cart button based on its parent category. The code works but has the following bug. If one of the parent categories is empty (i.e. does not have any sub cats) then the code no longer works. So the current code must be missing a string to check if parent category is empty or not but I do not know how to code that. This is the snippet I am running: // Utility function to get the childs array from all parent categories