Firstly, thanks for viewing this question. I've searched and gone through many similar questions however i've not managed to find a perfect fix.
Im setting up a website using wordpress/woocommerce, however most of our products have a set lead time therefore everything is on "back order - allow" status. Instead of showing "on backorder" on each product page, I wanted to see if it was possible to create a custom field in each product and replace the "on backorder" text to show that custom field.
Currently, i've been using the following code that just changes the text for every product however, not all products are on that specific lead time.
add_filter( 'woocommerce_get_availability', 'backorder_text', 10, 2);
function backorder_text($available) {
return str_replace('Available on backorder', 'Approx lead time: 2-4 working weeks', $available);
}
I appreciate I would need to set up a custom field in each product with the set time, but i'm not entirely sure how to link that specfic custom field per each product to that php code (or rather, whether its actually possible).
Any help would be fantastic - even if its to tell me it can't be done!
This can be done with the following code, that will handle products and product variation too:
Code goes in function.php file of your active child theme (or active theme). Tested and works.
For all products (except variable products, see after) you will get:
For product variations (of a variable product):