在寻找相同的内容时,我对JS源文件进行了一些深入研究。
Woocommerce Javascript事件$( document.body ).trigger( \'init_checkout\' );
$( document.body ).trigger( \'payment_method_selected\' );
$( document.body ).trigger( \'update_checkout\' );
$( document.body ).trigger( \'updated_checkout\' );
$( document.body ).trigger( \'checkout_error\' );
$( document.body ).trigger( \'applied_coupon_in_checkout\' );
$( document.body ).trigger( \'removed_coupon_in_checkout\' );
Woocommerce购物车页面JS事件$( document.body ).trigger( \'wc_cart_emptied\' );
$( document.body ).trigger( \'update_checkout\' );
$( document.body ).trigger( \'updated_wc_div\' );
$( document.body ).trigger( \'updated_cart_totals\' );
$( document.body ).trigger( \'country_to_state_changed\' );
$( document.body ).trigger( \'updated_shipping_method\' );
$( document.body ).trigger( \'applied_coupon\', [ coupon_code ] );
$( document.body ).trigger( \'removed_coupon\', [ coupon ] );
Woocommerce单一产品页面JS事件$( \'.wc-tabs-wrapper, .woocommerce-tabs, #rating\' ).trigger( \'init\' );
Woocommerce可变产品页面JS事件$( document.body ).trigger( \'found_variation\', [variation] );
Woocommerce添加到购物车JS事件$( document.body ).trigger( \'adding_to_cart\', [ $thisbutton, data ] );
$( document.body ).trigger( \'added_to_cart\', [ response.fragments, response.cart_hash, $thisbutton ] );
$( document.body ).trigger( \'removed_from_cart\', [ response.fragments, response.cart_hash, $thisbutton ] );
$( document.body ).trigger( \'wc_cart_button_updated\', [ $button ] );
$( document.body ).trigger( \'cart_page_refreshed\' );
$( document.body ).trigger( \'cart_totals_refreshed\' );
$( document.body ).trigger( \'wc_fragments_loaded\' );
Woocommerce添加支付方式JS事件$( document.body ).trigger( \'init_add_payment_method\' );
要将侦听器绑定到这些事件,请使用:
jQuery(\'<event_target>\').on(\'<event_name>\', function(){
console.log(\'<event_name> triggered\');
});
F. ex.
jQuery(\'body\').on(\'init_checkout\', function(){
console.log(\'init_checkout triggered\');
// now.do.whatever();
});