Advanced Woo Search – powerful live search plugin for WooCommerce. Just start typing and you will immediately see the products that you search.
Source: https://wordpress.org/plugins/advanced-woo-search/
One of the WooCommerce site I am using this plugin for product search. Client is maintaining the stock manager for his product. So client was wanting to replace the Out of Stock status to SOLD status on product search result page. I checked the plugin’s code. There have no any filter to customize that text from your theme file or custom plugin. Therefore I use the gettext filter and change the text with text-domain name.
Open the functions.php file of your active theme or any other PHP file of your custom plugin:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php //* Do not add this line add_filter( 'gettext', 'paulc_change_stock_status_text', 20, 3 ); function paulc_change_stock_status_text( $translated_text, $text, $domain ) { if ( 'aws' == $domain ) { switch ( $translated_text ) { case 'Out of stock' : $translated_text = __( 'SOLD', 'aws' ); break; } } return $translated_text; } |
aws is the unique identifier(text domain) for the Adavanced Woo Search plugin. When $domain variable is matching with aws, I am replacing the Out of stock text to SOLD text.
Leave a Reply