WordPress Contact Enquiry Form get Product Variation Data (Title, Color, Size etc)

iEntegre
2 min readJul 20, 2022

First You need a plugin for use short code (dynamictext, hiddendynamic)

You can download here (Contact Form 7 Dynamic Text Extension)

Here we will make additional modifications to reflect the Product information as additional information in the Enquiry form.

You can obtain additional information by editing the codes below as you wish.

Add the following codes to your theme’s functions.php file or you can embed it in any plugin.

/**
* iEntegre WordPress Modification
* WordPress Contact Enquiry Form get Product Variation Data (Title, Color, Size etc)
*/
// Clear cache First Remove action Modification
remove_action( 'wp_footer', 'ientegre_copy_variation_info_js' );
// Add Modification to WordPress Footer Section
add_action( 'wp_footer', 'ientegre_copy_variation_info_js' );
function ientegre_copy_variation_info_js() {
if ( !is_product() ) {
return;
}
$product = wc_get_product( get_the_ID() );
if ( ! 'variable' == $product->get_type() ) {
return;
}

?>
<script>
jQuery( document ).ready( function( $ ) {
var $variations_form_select = '.variations_form select';

var copyVariationsToInput = function() {…

--

--