WC_Products_Tracking::track_product_updated_client_side( WP_Post $post )
Track the Update button being clicked on the client side.
Description Description
This is needed because track_product_updated (using the edit_post hook) is called in response to a number of other triggers.
Parameters Parameters
- $post
-
(Required) The post, not used.
Source Source
File: includes/tracks/events/class-wc-products-tracking.php
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' ).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;
} );
}
"
);
}