Hello WordPress Masters,
I have a WooCommerce issue I need help with. I'm more of a front-end developer slash designer, and my attempts at solving this have been fruitless so far.
What I'm trying to do: Whenever a product is out of stock, I want to display a custom out of stock message (done) and a contact form below it (need help).
I use Contact Form 7 and have a shortcode I would normally insert. While I've figured out how to insert it with echo do_shortcode('[name_of_shortcode]');
I don't know how to make it appear only on products which are out of stock.
Here's the custom code I currently use in my child-theme's function.php file:
add_filter('woocommerce_get_availability', 'availability_filter_func');
function availability_filter_func($availability)
{
$availability['availability'] = str_ireplace('Out of stock', 'This class is not currently available at a scheduled time, but is instead being scheduled in response to customer interest. If you are interested in taking this class, please provide your contact information and we will reach out to with dates that are currently under consideration.', $availability['availability']);
return $availability;
}
As you can see, I was able to change the custom out of stock message but I have no clue how to call a shortcode after the message.
WordPress and WooCommerce Gurus, what should I do?
Thank you for your assistance and for taking time to educate me!
Tina