NO BUG: Form is not displayed when Bricks Single Product Template is activated

Can someone smarter than me explain this to me: In the WooCommerce shop, a product request form should be displayed for items that are not in stock. I have integrated the snippet accordingly and it works. However, the moment I create a single product template in Bricks (without having edited it at all), the form no longer appears.

This is the snippet:

/* 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="out-of-stock-form">';
        echo  '<p class="out-of-stock-form-message">Leider ist dieses Produkt nicht auf Lager.<br>Kontaktieren Sie uns fĂĽr mehr Informationen.</p>';
        echo  do_shortcode('[fluentform id="4"]'); // Replace with your own contact form shortcode
        echo  '</div>';
    }
}

Ok. It has to do with the “do_action” template tags introduced in 1.7, which partly remove WooCommerce actions. But that doesn’t help me and I’m as lost as before. What exactly do I have to do to include my snippet with the template tag

{do_action:woocommerce_after_single_product_summary}

at this point?

Hi @electricarts ,

If you are using add_action( 'woocommerce_single_product_summary ), you need to ensure {do_action: woocommerce_single_product_summary} is exists in your Single Product template.

Nothing to do with your snippet code.
Just need to drag a Basic Text element into your Single Product template, and insert {do_action: woocommerce_single_product_summary} as the Basic text value. (Usually above the Product title)

Then your out_of_stock_show_form function should be able to execute and output successfully.

Regards,
Jenn

1 Like

@itchycode Thanks for your reply!

Unfortunately, that doesn’t work either. Just like before. If I deactivate the Single Product Template created in Bricks, the form is displayed. If I activate the template, the form disappears.

@itchycode Sorry, my mistake. In desperation I tried many things yesterday. And within WPCodeBox, the snippet was still on another entry for “Where to insert the snippet” and not on “plugins_loaded”. It works now with your solution. Thank you very much!

1 Like

Glad to hear you resolved it :slight_smile:
Thanks for updating.
Have a nice day!