1function hide_non_applicable_coupons() { 2 var coupon_elements = document.getElementsByClassName( 'cart-discount' ); 3 4 for ( var i = 0; i < coupon_elements.length; i++ ) { 5 if ( 6 0 !== 7 coupon_elements[ i ].getElementsByClassName( 'wcs-hidden-coupon' ) 8 .length 9 ) { 10 coupon_elements[ i ].style.display = 'none'; 11 } 12 } 13} 14 15hide_non_applicable_coupons(); 16 17jQuery( function ( $ ) { 18 $( document.body ).on( 'updated_cart_totals updated_checkout', function () { 19 hide_non_applicable_coupons(); 20 } ); 21 22 /** 23 * Update all subscriptions shipping methods which inherit the chosen method from the initial 24 * cart when the customer changes the shipping method. 25 */ 26 $( document ).on( 27 'change', 28 'select.shipping_method, :input[name^=shipping_method]', 29 function ( event ) { 30 var shipping_method_option = $( event.target ); 31 var shipping_method_id = shipping_method_option.val(); 32 var package_index = shipping_method_option.data( 'index' ); 33 34 // We're only interested in the initial cart shipping method options which have int package indexes. 35 if ( ! Number.isInteger( package_index ) ) { 36 return; 37 } 38 39 // Find all recurring cart info elements with the same package index as the changed shipping method. 40 $( 41 '.recurring-cart-shipping-mapping-info[data-index=' + 42 package_index + 43 ']' 44 ).each( function () { 45 // Update the corresponding subscription's hidden chosen shipping method. 46 $( 47 'input[name="shipping_method[' + 48 $( this ).data( 'recurring_index' ) + 49 ']"]' 50 ).val( shipping_method_id ); 51 } ); 52 } 53 ); 54 55 $( '.payment_methods [name="payment_method"]' ).on( 'click', function () { 56 if ( $( this ).hasClass( 'supports-payment-method-changes' ) ) { 57 $( '.update-all-subscriptions-payment-method-wrap' ).show(); 58 } else { 59 $( '.update-all-subscriptions-payment-method-wrap' ).hide(); 60 } 61 } ); 62} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.