Last active
April 16, 2026 07:11
-
-
Save rajeshsingh520/3a80dbd94cbf0398f008594d5a563ed9 to your computer and use it in GitHub Desktop.
Enquiry plugin working with YITH WooCommerce Product Add-ons & Extra Options
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_eqw_product_price_filter', function($price, $product, $product_in_cart){ | |
| if(isset($product_in_cart['variation_detail']['price']) ){ | |
| $raw_price = $product_in_cart['variation_detail']['price']; | |
| $clean_price = str_replace(',', '', $raw_price); | |
| if(is_numeric($clean_price)){ | |
| return (float) $clean_price; | |
| } | |
| } | |
| return $price; | |
| },10,3); | |
| add_filter('pisol_enq_variation_label', function($variations){ | |
| unset($variations['price']); | |
| return $variations; | |
| }); | |
| add_action( 'wp_enqueue_scripts', function () { | |
| $js = " | |
| jQuery(document).on('pi_add_to_enquiry_data', function(e, data){ | |
| if(jQuery('.yith-wapo-block').length == 0) return; | |
| jQuery('.yith-wapo-block').each(function(){ | |
| if(jQuery('.yith-wapo-addon-type-checkbox',this).length !== 0){ | |
| jQuery('.yith-wapo-addon-type-checkbox',this).each(function(){ | |
| var option_group_label = jQuery('.wapo-addon-title',this).text(); | |
| var count = 1; | |
| jQuery('.yith-wapo-option', this).each(function(){ | |
| var value = jQuery('.yith-wapo-addon-label', this).text().trim(); | |
| var label = option_group_label+' '+count; | |
| if(jQuery('input', this).is(':checked')){ | |
| data['variation_detail'][label] = value; | |
| count++; | |
| } | |
| }) | |
| }); | |
| } | |
| if(jQuery('.yith-wapo-addon-type-select',this).length !== 0){ | |
| jQuery('.yith-wapo-addon-type-select',this).each(function(){ | |
| var select_group_label = jQuery('.wapo-addon-title',this).text(); | |
| var value = jQuery('.yith-wapo-option-value',this).val(); | |
| if(value){ | |
| value = jQuery('.yith-wapo-option-value', this).find('option:selected').text(); | |
| data['variation_detail'][select_group_label] = value; | |
| } | |
| }); | |
| } | |
| if (jQuery('#wapo-total-order-price').length) { | |
| var price_element = jQuery('#wapo-total-order-price .amount').clone(); | |
| // remove currency span (works for any currency position) | |
| price_element.find('.woocommerce-Price-currencySymbol').remove(); | |
| var price = price_element.text().trim(); | |
| data['variation_detail']['price'] = price; | |
| } | |
| }); | |
| }); | |
| "; | |
| 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