I would like to change the text "in stock" behind the number in stock. I tried adding this PHP code in my wordpress php editor but it doesn’t work.
Do you have any idea why?
Thank you !
add_filter( 'woocommerce_get_availability_text', 'bbloomer_custom_get_availability_text', 99, 2 );
function bbloomer_custom_get_availability_text( $availability, $product ) {
$stock = $product->get_stock_quantity();
if ( $product->is_in_stock() && $product->managing_stock() ) $availability = $stock. 'remaining copies' ;
return $availability;
}
2
Answers
Try the following instead:
Or also you can try this:
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
You can use the in build option for this go to WooCommerce->Preferences->Products->Inventar
and choose the first option. Show available Products and save.