Paste those into your theme’s functions.php and edit the contact form shortcode inside do_shortcode function.

/* Show contact form instead of "Out Of Stock" message */
add_action('woocommerce_single_product_summary', 'out_of_stock_show_form', 20);
function out_of_stock_show_form() {
    global $product;
    if(!$product->is_in_stock( )) {
        echo  '<div class="oos-form">';
		echo  'This date is already sold out.<br>Contact us if you can\'t find the date you want:';
		echo  do_shortcode('[contact-form-7 404 "Not Found"]');
        echo  '</div>';
    }
}

/* This one will work on Variable Product - When a Variation is out of stock */
add_filter( 'woocommerce_available_variation', 'variation_out_of_stock_show_form', 10, 3 );
function variation_out_of_stock_show_form( $data, $product, $variation ) {
    if( ! $data['is_in_stock'] )
	{
        $data['availability_html'] = '<div class="oos-form">';
		$data['availability_html'] .= 'This date is already sold out.<br>Contact us if you can\'t find the date you want:';
		$data['availability_html'] .= do_shortcode('[contact-form-7 404 "Not Found"]');
        $data['availability_html'] .= '</div>';
	}
    return $data;
}

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?