Reputation: 1945
I want to change In Stock label into in stock in product edit inventory section on admin section. I have used following code but its changing the text on front end not changing on back-end i want to change the label on back-end not in front end. I have attached the screenshot of where i want to change the text.
Screen Shot : https://prnt.sc/obz1uc
add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);
function custom_get_availability( $availability, $_product ) {
if ( $_product->is_in_stock() ) $availability['availability'] = __('in stock', 'woocommerce');
}
Could you please help me to solve the issue, Thank you in advance.
Upvotes: 1
Views: 596
Reputation: 1590
Try this:
function custom_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'In Stock' :
$translated_text = 'in stock';
break;
}
return $translated_text;
}
add_filter( 'gettext', 'custom_text_strings', 20, 3 );
Let me know if it does the job and good luck ;)
PS. you could add an additional check on the $domain var to make sure to target on WooCommerce text.
Upvotes: 1