Set adding_to_cart trigger to variable. If false, do not fire ajax. Closes #25759.

This commit is contained in:
Kathy Daring 2020-02-25 13:12:27 -07:00
parent 4138aecdcd
commit 38e081e590
1 changed files with 25 additions and 23 deletions

View File

@ -76,8 +76,9 @@ jQuery( function( $ ) {
});
// Trigger event.
$( document.body ).trigger( 'adding_to_cart', [ $thisbutton, data ] );
var valid = $( document.body ).triggerHandler( 'adding_to_cart', [ $thisbutton, data ] );
if( valid !== false ) {
e.data.addToCartHandler.addRequest({
type: 'POST',
url: wc_add_to_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_to_cart' ),
@ -104,6 +105,7 @@ jQuery( function( $ ) {
dataType: 'json'
});
}
}
};
/**