Changing text for reserved products
-
Hi, thanks for the plugin. It’s been a great help to our project.
So, with our project having unique items with only one item in stock each, with Cart Stock Reducer we are able to reserve items in users baskets for 10 minutes.
Our issue is that we are required to display items that are sold. Therefore we display all items, even ones that are out of stock, and have some code to change the standard “Read More’ text to “Sold” for both the shop and product pages. That code is:
/** Change out of stock text */ function change_text_soldout ( $text, $product) { if ( !$product->is_in_stock() ) { $text = __('Sold', 'woocommerce'); } return $text; } add_filter('woocommerce_get_availability_text', 'change_text_soldout', 10, 2 ); /** Replace Read More with Out of Stock */ add_filter('gettext', 'wps_translate_words_array'); add_filter('ngettext', 'wps_translate_words_array'); function wps_translate_words_array( $translated ) { $words = array( // 'word to translate' = > 'translation' 'Read More' => 'Sold', ); $translated = str_ireplace(array_keys($words), $words, $translated); return $translated; }
However, when someone reserves an item in their basket, this reduces the stock to 0 and therefore the shop page displays “SOLD”, which is incorrect. Is it possible to hook the ‘virtual’ stock rather than the ‘actual’ stock. So that ‘SOLD’ only appears for items with an actual stock of 0 ?
Any guidance would be great. Thank you.
Jim
- The topic ‘Changing text for reserved products’ is closed to new replies.