Fix cart ajax triggers

Closes #18498
This commit is contained in:
Mike Jolley 2018-01-18 16:31:17 +00:00
parent dbb6e2716d
commit 1fc6155167
2 changed files with 14 additions and 14 deletions

View File

@ -102,7 +102,7 @@ jQuery( function( $ ) {
}
$( '.woocommerce-cart-form' ).replaceWith( $new_form );
$( '.woocommerce-cart-form' ).find( 'input[name="update_cart"]' ).prop( 'disabled', true );
$( '.woocommerce-cart-form' ).find( ':input[name="update_cart"]' ).prop( 'disabled', true );
if ( $notices.length > 0 ) {
show_notice( $notices );
@ -158,7 +158,7 @@ jQuery( function( $ ) {
);
$( document ).on(
'change',
'select.shipping_method, input[name^=shipping_method]',
'select.shipping_method, :input[name^=shipping_method]',
this.shipping_method_selected
);
$( document ).on(
@ -185,7 +185,7 @@ jQuery( function( $ ) {
shipping_method_selected: function() {
var shipping_methods = {};
$( 'select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]' ).each( function() {
$( 'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
} );
@ -271,11 +271,11 @@ jQuery( function( $ ) {
function() { cart.update_cart.apply( cart, [].slice.call( arguments, 1 ) ); } );
$( document ).on(
'click',
'.woocommerce-cart-form input[type=submit]',
'.woocommerce-cart-form :input[type=submit]',
this.submit_click );
$( document ).on(
'keypress',
'.woocommerce-cart-form input[type=number]',
'.woocommerce-cart-form :input[type=number]',
this.input_keypress );
$( document ).on(
'submit',
@ -298,14 +298,14 @@ jQuery( function( $ ) {
'.woocommerce-cart-form .cart_item :input',
this.input_changed );
$( '.woocommerce-cart-form input[name="update_cart"]' ).prop( 'disabled', true );
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', true );
},
/**
* After an input is changed, enable the update cart button.
*/
input_changed: function() {
$( '.woocommerce-cart-form input[name="update_cart"]' ).prop( 'disabled', false );
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', false );
},
/**
@ -376,9 +376,9 @@ jQuery( function( $ ) {
* @param {Object} evt The JQuery event
*/
cart_submit: function( evt ) {
var $submit = $( document.activeElement );
var $clicked = $( 'input[type=submit][clicked=true]' );
var $form = $( evt.currentTarget );
var $submit = $( document.activeElement ),
$clicked = $( ':input[type=submit][clicked=true]' ),
$form = $( evt.currentTarget );
// For submit events, currentTarget is form.
// For keypress events, currentTarget is input.
@ -394,11 +394,11 @@ jQuery( function( $ ) {
return false;
}
if ( $clicked.is( 'input[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) {
if ( $clicked.is( ':input[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) {
evt.preventDefault();
this.quantity_update( $form );
} else if ( $clicked.is( 'input[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) {
} else if ( $clicked.is( ':input[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) {
evt.preventDefault();
this.apply_coupon( $form );
}
@ -410,7 +410,7 @@ jQuery( function( $ ) {
* @param {Object} evt The JQuery event
*/
submit_click: function( evt ) {
$( 'input[type=submit]', $( evt.target ).parents( 'form' ) ).removeAttr( 'clicked' );
$( ':input[type=submit]', $( evt.target ).parents( 'form' ) ).removeAttr( 'clicked' );
$( evt.target ).attr( 'clicked', 'true' );
},

File diff suppressed because one or more lines are too long