I'm currently using wordpress with contact form 7 together with recaptcha on two different kind of pages a customers site we are building.
- Contact form: https://www.alvestadtanken.se/kontakt/ (working without problem)
- Variable products without price: https://www.alvestadtanken.se/butik/dieseltankar/stationara-dieseltankar-1300-9000-liter/dieseltank-fm-5000-l/ (recaptcha dosnt load correctly and it wont submit because of missing values)
I have tried several different approaches and have boiled it down to the only difference is that on the page 2 we are loading the contact form 7 after the page is initialized trough a ajax request when the actual value (see pumpalternativ in image below) is choosen in a dropdown menu. What i think is that i need to reload/set the recaptcha after the contact form 7 is loaded, but i dont have any idea how to do this.
// Displays contact form for variations with no price(0kr) or add to cart button if price exists.
add_filter( 'woocommerce_available_variation', 'empty_and_zero_variation_prices_html', 10, 3);
function empty_and_zero_variation_prices_html( $data, $product, $variation ) {
if( '0' === $variation->get_price() || '' === $variation->get_price() || 0 == $variation->get_price() ){
$data['price_html'] = __('<div class="wpcf7-wrapper"><h5 class="text-primary font-weight-bold">Kontakta oss angående produkten</h5> ' . do_shortcode( '[contact-form-7 id="7336" title="Prisförfrågan"]' ) . '</div> ', 'woocommerce');
$data['is_purchasable'] = false;
} else {
$data['price_html'] .= __(do_shortcode( '[add_to_cart_button]' ));
}
return $data;
}
All ideas and help are welcome.
