UPDATED: Added compatibility with WC 3+
I tested it and it will not send any data related to the selected options, because it simply displays the selected contact form below the "Add to Cart" button (on pages with one product). In addition, this plugin has not been updated since more than 2 years, so it is deprecated.
:
: WooCommerce 7
, 7 .
, , , ( ).
/ 2 : Color Size.
Contact form 7 , :
<label> Your Name (required)
[text* your-name] </label>
<label> Your Email (required)
[email* your-email] </label>
<label> Subject (required)
[text* your-subject class:product_name] </label>
<label> Your Message
[textarea your-message] </label>
[submit "Send"]
[text your-product class:product_details]
[text your-product class:product_details]. "" [your-product] " ", :
From: [your-name] <[your-email]>
Subject: [your-subject]
Product: [your-product]
Message Body:
[your-message]
--------------
This e-mail was sent from a contact form 7
funtion PHP woocommerce_after_add_to_cart_form:
add_action( 'woocommerce_after_add_to_cart_form', 'product_enquiry_custom_form' );
function product_enquiry_custom_form() {
global $product, $post;
$contact_form_shortcode = '[contact-form-7 id="382" title="form"]';
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
$product_title = $post->post_title;
$email_subject = __( 'Enquire about', 'woocommerce' ) . ' ' . $product_title;
foreach($product->get_available_variations() as $variation){
$variation_id = $variation['variation_id'];
foreach($variation['attributes'] as $key => $value){
$key = ucfirst( str_replace( 'attribute_pa_', '', $key ) );
$variations_attributes[$variation_id][$key] = $value;
}
}
?>
<style>
.wpcf7-form-control-wrap.your-product{ opacity:0;width:0px;height:0px;overflow: hidden;display:block;margin:0;padding:0;}
</style>
<?php
echo '<h3>'.$email_subject.'</h3><br>
<div class="enquiry-form">' . do_shortcode( $contact_form_shortcode ) . '</div>';
?>
<script>
(function($){
<?php
$js_array = json_encode($variations_attributes);
echo 'var $variationsAttributes = '. $js_array ;
?>
$('.product_name').val('<?php echo $email_subject; ?>');
var $attributes;
$('td.value select').blur(function() {
var $variationId = $('input[name="variation_id"]').val();
if (typeof $variationId !== 'undefined' ){
for(key in $variationsAttributes){
if( key == $variationId ){
$attributes = $variationsAttributes[key];
break;
}
}
}
if ( typeof $attributes !== 'undefined' ){
var $attributesString = '';
for(var attrKey in $attributes){
$attributesString += ' ' + attrKey + ': ' + $attributes[attrKey] + ' — ';
}
$('.product_details').val( 'Product <?php echo $product_title; ?> (ID <?php echo $product_id; ?>): ' + $attributesString );
}
});
})(jQuery);
</script>
<?php
}
function.php ( ), .
, :
:
:

( , jQuery):

, , ...
, , :
From: John Smith <j.smith@themain.com>
Subject: Enquire about Ship Your Idea
Product: Product Ship Your Idea (ID 40): Color: black — Size: 12 —
Message Body:
I send this request about this very nice product … I send this request about this very nice product …
--
This e-mail was sent from a contact form 7
, Everithing , , .