Revert "Fix terms counts in wcadmin_product_add_publish Tracks event" (#49797)
* Revert "Fix terms counts in wcadmin_product_add_publish Tracks event (#48194)"
This reverts commit 7d5b3a81a2
.
* Add changelog
* Add comment back in to fix linter
This commit is contained in:
parent
7500365057
commit
726e5fb0d8
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Revert fixing terms count in tracking PR as it caused product_add_publish to be triggered more than usual.
|
|
@ -334,7 +334,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
$product->apply_changes();
|
$product->apply_changes();
|
||||||
|
|
||||||
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||||
do_action( 'woocommerce_update_product', $product->get_id(), $product, $changes );
|
do_action( 'woocommerce_update_product', $product->get_id(), $product );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,8 +29,7 @@ class WC_Products_Tracking {
|
||||||
add_action( 'load-edit.php', array( $this, 'track_products_view' ), 10 );
|
add_action( 'load-edit.php', array( $this, 'track_products_view' ), 10 );
|
||||||
add_action( 'load-edit-tags.php', array( $this, 'track_categories_and_tags_view' ), 10, 2 );
|
add_action( 'load-edit-tags.php', array( $this, 'track_categories_and_tags_view' ), 10, 2 );
|
||||||
add_action( 'edit_post', array( $this, 'track_product_updated' ), 10, 2 );
|
add_action( 'edit_post', array( $this, 'track_product_updated' ), 10, 2 );
|
||||||
add_action( 'woocommerce_new_product', array( $this, 'track_product_published' ), 10, 3 );
|
add_action( 'wp_after_insert_post', array( $this, 'track_product_published' ), 10, 4 );
|
||||||
add_action( 'woocommerce_update_product', array( $this, 'track_product_published' ), 10, 3 );
|
|
||||||
add_action( 'created_product_cat', array( $this, 'track_product_category_created' ) );
|
add_action( 'created_product_cat', array( $this, 'track_product_category_created' ) );
|
||||||
add_action( 'edited_product_cat', array( $this, 'track_product_category_updated' ) );
|
add_action( 'edited_product_cat', array( $this, 'track_product_category_updated' ) );
|
||||||
add_action( 'add_meta_boxes_product', array( $this, 'track_product_updated_client_side' ), 10 );
|
add_action( 'add_meta_boxes_product', array( $this, 'track_product_updated_client_side' ), 10 );
|
||||||
|
@ -304,21 +303,24 @@ class WC_Products_Tracking {
|
||||||
/**
|
/**
|
||||||
* Send a Tracks event when a product is published.
|
* Send a Tracks event when a product is published.
|
||||||
*
|
*
|
||||||
* @param int $product_id Product ID.
|
* @param int $post_id Post ID.
|
||||||
* @param WC_Product $product Product object.
|
* @param WP_Post $post Post object.
|
||||||
* @param array $changes Product changes.
|
* @param bool $update Whether this is an existing post being updated.
|
||||||
|
* @param null|WP_Post $post_before Null for new posts, the WP_Post object prior
|
||||||
|
* to the update for updated posts.
|
||||||
*/
|
*/
|
||||||
public function track_product_published( $product_id, $product, $changes = null ) {
|
public function track_product_published( $post_id, $post, $update, $post_before ) {
|
||||||
if (
|
if (
|
||||||
! isset( $product ) ||
|
'product' !== $post->post_type ||
|
||||||
'product' !== $product->post_type ||
|
'publish' !== $post->post_status ||
|
||||||
'publish' !== $product->get_status( 'edit' ) ||
|
( $post_before && 'publish' === $post_before->post_status )
|
||||||
( $changes && ! isset( $changes['status'] ) )
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$product_type_options = self::get_product_type_options( $product_id );
|
$product = wc_get_product( $post_id );
|
||||||
|
|
||||||
|
$product_type_options = self::get_product_type_options( $post_id );
|
||||||
$product_type_options_string = self::get_product_type_options_string( $product_type_options );
|
$product_type_options_string = self::get_product_type_options_string( $product_type_options );
|
||||||
|
|
||||||
$properties = array(
|
$properties = array(
|
||||||
|
@ -332,7 +334,7 @@ class WC_Products_Tracking {
|
||||||
'is_virtual' => $product->is_virtual() ? 'yes' : 'no',
|
'is_virtual' => $product->is_virtual() ? 'yes' : 'no',
|
||||||
'manage_stock' => $product->get_manage_stock() ? 'yes' : 'no',
|
'manage_stock' => $product->get_manage_stock() ? 'yes' : 'no',
|
||||||
'menu_order' => $product->get_menu_order() ? 'yes' : 'no',
|
'menu_order' => $product->get_menu_order() ? 'yes' : 'no',
|
||||||
'product_id' => $product_id,
|
'product_id' => $post_id,
|
||||||
'product_gallery' => count( $product->get_gallery_image_ids() ),
|
'product_gallery' => count( $product->get_gallery_image_ids() ),
|
||||||
'product_image' => $product->get_image_id() ? 'yes' : 'no',
|
'product_image' => $product->get_image_id() ? 'yes' : 'no',
|
||||||
'product_type' => $product->get_type(),
|
'product_type' => $product->get_type(),
|
||||||
|
|
Loading…
Reference in New Issue