Created
April 30, 2026 05:40
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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