8889841chome/clixcotz/cbo.clix.co.tz/wp-content/themes/bookworm/assets/js/variation-radio-scripts.js000064400000001751150521376630026357 0ustar00;(function ( $ ) { 'use strict'; /** * @TODO Code a function the calculate available combination instead of use WC hooks */ $.fn.bookworm_variations_radio_style_form = function () { return this.each( function() { var $form = $( this ); $form .on( 'click', '.custom-radio', function ( e ) { e.preventDefault(); var $el = $( this ); $el.find( '.custom-control-input' ).prop( "checked", true ); var attributes = $(this).data( 'attributes' ); $.map( attributes, function( val, i ) { var attribute_name = val.attribute_name, attribute_value = val.attribute_value, $select = $form.find( 'select[name="'+ attribute_name +'"]' ); $select.trigger( 'focusin' ); $select.val( attribute_value ); $select.change(); }); } ); } ); }; $( function () { $( '.variations_form' ).bookworm_variations_radio_style_form(); $( document.body ).trigger( 'bookworm_variations_radio_style_initialized' ); } ); })( jQuery );