-
-
Save artikus11/e8b79287911eb30b3acde3979502f3ae to your computer and use it in GitHub Desktop.
Woocommerce Javascript events #woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Woocommerce JS events. Страница оформления заказа | |
$( 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' ); | |
//Woocommerce JS events. Страница корзины | |
$( 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 events. Страница товара | |
$( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' ); | |
//Woocommerce JS events. Добавление товара в корзину | |
$( 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 events. Методы оплаты | |
$( document.body ).trigger( 'init_add_payment_method' ); | |
// Пример использования: | |
jQuery('<event_target>').on('<event_name>', function(){ | |
console.log('<event_name> triggered'); | |
}); | |
// Например обновление страницы оформелния заказа при изменении поля региона | |
$('body').on('change', '#billing_state', function(){ | |
$( document.body ).trigger( 'update_checkout' ); | |
}); | |
// Или обновление страницы оформления заказа при изменении метода доставки | |
jQuery( document ).ready( function( $ ) { | |
$( document.body ).on( 'updated_checkout updated_shipping_method', function( event, xhr, data ) { | |
$( 'input[name^="shipping_method"]' ).on( 'change', function() { | |
$( '.woocommerce-billing-fields__field-wrapper' ).block( { | |
message: null, | |
overlayCSS: { | |
background: '#fff', | |
'z-index': 1000000, | |
opacity: 0.3 | |
} | |
} ); | |
} ); | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment