Custom text depending on stock status
-
Hi,
I posted to WooThemes forum at the beginning of the week and had no response so thought I’d see if you guys and girls had any advice ??
I need some help forming an IF and ELSE statement in my functions.php file.
What I want to achieve is that if a product is out of stock and available for backorder, it will display a message such as available for pre order and the add to cart button on the single product page will also say pre order now.
I then also want it to say if a product is marked as in stock to actually say available instead and the add to cart button text to remain the same.
So far I have this;
/** * WORKING EXAMPLE: CUSTOM: Changes Woocommerce Backorder Text on single product page */ function woocommercecustomgetavailability( $availabilityinfo, $wcproduct ){ if( $availabilityinfo['availability'] == 'Available on backorder' ){ $availabilityinfo['availability'] = "Custom order - allow 2 weeks"; } return $availabilityinfo; } addfilter( 'woocommercegetavailability', 'woocommercecustomgetavailability', 10, 2); addfilter( 'woocommerceproductaddtocarttext', 'wooarchivecustomcartbutton_text' ); // 2.1 + function wooarchivecustomcartbutton_text() { return __( 'Pre Order', 'woocommerce' ); }
But I can’t seem to get it to check the In Stock availability or change the add to cart text.
I know the code is incomplete to achieve what I want but I can’t seem to figure it out (I am no coder)
Can anybody please help?
Many thanks
- The topic ‘Custom text depending on stock status’ is closed to new replies.