WC_Products_Tracking::track_product_updated_client_side() public WC 1.0
Track the Update button being clicked on the client side. This is needed because track_product_updated (using the edit_post hook) is called in response to a number of other triggers.
{} Это метод класса: WC_Products_Tracking{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WC_Products_Tracking = new WC_Products_Tracking(); $WC_Products_Tracking->track_product_updated_client_side( $post );
- $post(WP_Post) (обязательный)
- The post, not used.
Код WC_Products_Tracking::track_product_updated_client_side() WC Products Tracking::track product updated client side WC 5.0.0
public function track_product_updated_client_side( $post ) {
wc_enqueue_js(
"
if ( $( 'h1.wp-heading-inline' ).text().trim() === '" . __( 'Edit product', 'woocommerce' ) . "') {
var initialStockValue = $( '#_stock' ).val();
var hasRecordedEvent = false;
$( '#publish' ).on( 'click', function() {
if ( hasRecordedEvent ) {
return;
}
var currentStockValue = $( '#_stock' ).val();
var properties = {
product_type: $( '#product-type' ).val(),
is_virtual: $( '#_virtual' ).is( ':checked' ) ? 'Y' : 'N',
is_downloadable: $( '#_downloadable' ).is( ':checked' ) ? 'Y' : 'N',
manage_stock: $( '#_manage_stock' ).is( ':checked' ) ? 'Y' : 'N',
stock_quantity_update: ( initialStockValue != currentStockValue ) ? 'Y' : 'N',
};
window.wcTracks.recordEvent( 'product_update', properties );
hasRecordedEvent = true;
} );
}
"
);
}