Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rajeshsingh520/f54a4273fbaee42b0833d4178dfccd80 to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/f54a4273fbaee42b0833d4178dfccd80 to your computer and use it in GitHub Desktop.
code to make enquiry button work with ninja form table with variable product
add_action('wp_enqueue_scripts', function () {
wp_enqueue_script('jquery');
$inline_js = <<<'JS'
jQuery(document).on('pi_add_to_enquiry_data', function(e, data){
var id = data.id;
var form_id = '#nt_variation_form_' + id;
var qty = '#nt_product_qty_' + id;
if (jQuery(qty).length > 0) {
data.quantity = jQuery(qty).val();
}
if (jQuery(form_id).length == 0) {
return;
}
var variation_id = jQuery(form_id).find('input[name="variation_id"]').val();
data.variation_id = variation_id;
jQuery(form_id + ' select[name^=attribute_]').each(function () {
data.variation_detail[jQuery(this).attr('name')] = jQuery(this).val();
});
});
JS;
wp_add_inline_script('jquery', $inline_js);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment