Created
January 16, 2025 02:15
-
-
Save rajeshsingh520/5c010a3a98083f7630b13dcba577527a to your computer and use it in GitHub Desktop.
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_filter('pisol_enq_show_variation_for_simple', '__return_true'); | |
add_action( 'wp_enqueue_scripts', function () { | |
if ( ! is_product() ) return; | |
$js = " | |
jQuery(document).ready(function($){ | |
jQuery(document).on(\"pi_add_to_enquiry_data\", function(e, data){ | |
pi_custom(data); | |
}) | |
function pi_custom(data){ | |
jQuery(\".uni-module-radio\").each(function(e){ | |
var label = jQuery(\".uni-cpo-module-radio-label\", this).text().replace(/\\n|\\t/g, '').trim(); | |
var name = jQuery(this).attr('id'); | |
var val = jQuery(\"input[name='\"+name+\"']:checked\").val(); | |
if(val && label){ | |
data[\"variation_detail\"][label]= val; | |
} | |
}); | |
jQuery(\".uni-module-text_input\").each(function(e){ | |
var display = jQuery(this).css('display'); | |
if(display == 'none') return; | |
var label = jQuery(\".uni-cpo-module-text_input-label\", this).text().replace(/\\n|\\t/g, '').trim(); | |
var name = jQuery(this).attr('id'); | |
var val = jQuery(\"input[name='\" + name + \"']\").val(); | |
if(val && label){ | |
data[\"variation_detail\"][label]= val; | |
} | |
}); | |
jQuery(\".uni-module-select\").each(function(e){ | |
var display = jQuery(this).css('display'); | |
if(display == 'none') return; | |
var label = jQuery(\".uni-cpo-module-select-label\", this).text().replace(/\\n|\\t/g, '').trim(); | |
var name = jQuery(this).attr('id'); | |
var val = jQuery(\"select[name='\" + name + \"'] option:selected\").text(); | |
if(val && label){ | |
data[\"variation_detail\"][label]= val; | |
} | |
}); | |
jQuery(\".uni-module-checkbox\").each(function(e){ | |
var display = jQuery(this).css('display'); | |
if(display == 'none') return; | |
var label = jQuery(\".uni-cpo-module-checkbox-label\", this).text().replace(/\\n|\\t/g, '').trim(); | |
var name = jQuery(this).attr('id'); | |
var val = jQuery(\"input[name='\" + name + \"[]']:checked\").map(function() { | |
var labelText = jQuery(this).next('label').text().trim(); | |
return labelText; }).get(); | |
if(val && label){ | |
data[\"variation_detail\"][label]= val; | |
} | |
}); | |
} | |
});"; | |
wp_add_inline_script('jquery', $js, 'after'); | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment