WC_Coupons_Tracking::tracks_coupons_bulk_actions
Enqueue JS to handle tracking for bulk editing of coupons.
Method of the class: WC_Coupons_Tracking{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Coupons_Tracking = new WC_Coupons_Tracking(); $WC_Coupons_Tracking->tracks_coupons_bulk_actions();
WC_Coupons_Tracking::tracks_coupons_bulk_actions() WC Coupons Tracking::tracks coupons bulk actions code WC 10.8.1
public function tracks_coupons_bulk_actions() {
$handle = 'wc-tracks-coupons-bulk-actions';
wp_register_script( $handle, '', array(), WC_VERSION, array( 'in_footer' => true ) );
wp_enqueue_script( $handle );
wp_add_inline_script(
$handle,
"
(function() {
'use strict';
function trackBulkAction( selectorId ) {
return function() {
const select = document.getElementById( selectorId );
const action = select ? select.value : null;
if ( action && '-1' !== action && window.wcTracks && window.wcTracks.recordEvent ) {
window.wcTracks.recordEvent( 'coupons_view_bulk_action', { action: action } );
}
};
}
const topButton = document.getElementById( 'doaction' );
const bottomButton = document.getElementById( 'doaction2' );
if ( topButton ) {
topButton.addEventListener( 'click', trackBulkAction( 'bulk-action-selector-top' ) );
}
if ( bottomButton ) {
bottomButton.addEventListener( 'click', trackBulkAction( 'bulk-action-selector-bottom' ) );
}
})();
"
);
}