// ========================================================================= // ADD CUSTOM MESSAGE IF SPECIFIC PRODUCT CATEGORY OUT OF STOCK // ========================================================================= add_filter( 'woocommerce_get_availability', 'woo_custom_get_availability', 1, 2); function woo_custom_get_availability( $availability, $_product ) { global $product; //CATEGORY 1 if ( has_term( 'CATEGORY_NAME_1', 'product_cat', $product->get_id() ) ) { // Change In Stock Text if ( $_product->is_in_stock() ) { $availability['availability'] = __('Available!', 'woocommerce'); } // Change Out of Stock Text if ( ! $_product->is_in_stock() ) { $availability['availability'] = __('Jelenleg nincs kitűzve tréning időpont', 'woocommerce'); } return $availability; } //CATEGORY 2 else if ( has_term( 'CATEGORY_NAME_2', 'product_cat', $product->get_id() ) ) { // Change In Stock Text if ( $_product->is_in_stock() ) { $availability['availability'] = __('Available!', 'woocommerce'); } // Change Out of Stock Text if ( ! $_product->is_in_stock() ) { $availability['availability'] = __('Jelenleg nincs kitűzve tréning időpont', 'woocommerce'); } return $availability; } else{ // Change In Stock Text if ( $_product->is_in_stock() ) { $availability['availability'] = __('Készleten', 'woocommerce'); } // Change Out of Stock Text if ( ! $_product->is_in_stock() ) { $availability['availability'] = __('Elfogyott', 'woocommerce'); } return $availability; } }
Kip Creativ says
Thank you. I have been looking for this snippet for several days! Great!