I am using "Add a select field that will change price in Woocommerce simple products" answer code. It only uses a single selection field for filtering. I want to extend this code using jQuery to be able to use multiple fields for filtering.
Example: 2 select fields, one text, a checkbox and some radio buttons that will all determine the final calculated price.
// Select field
woocommerce_form_field('materials_pack', array(
'type' => 'select',
'class' => array('material-field form-row-wide'),
'label' => __('Select Materials:', $domain),
'required' => true,
'options' => $options,
),'');
<script>
jQuery(function($){
var a = <?php echo json_encode($prices); ?>,
b = 'p.price',
c = 'select[name="materials_pack"]';
$(c).on( 'change', function(){
$.each( a, function( key, value ){
if( $(c).val() == key )
$(b).html(value);
});
});
});
</script>
How to use it for multi fields? and how do the jquery script?