Skip to content

Commit

Permalink
Add missing tracking data for the migration process (#2765)
Browse files Browse the repository at this point in the history
* Update tracking data when the migration is completed

* Move plugin entry deactivated message to WooCommerce Shipping

* Add missing imports for tracks in a static method
  • Loading branch information
Ferdev committed Jul 30, 2024
1 parent 097f66d commit f59291e
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions woocommerce-services.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,26 @@ public static function plugin_deactivation() {
* When we deactivate the plugin after wcshipping_migration_state has started,
* that means the migration is done. We can mark it as completed before we deactivate the plugin.
*/
require_once __DIR__ . '/classes/class-wc-connect-logger.php';
require_once __DIR__ . '/classes/class-wc-connect-tracks.php';
require_once __DIR__ . '/classes/class-wc-connect-wcst-to-wcshipping-migration-state-enum.php';

$migration_state = get_option( 'wcshipping_migration_state' );
if ( ! $migration_state || intval( $migration_state ) !== WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED ) {
update_option( 'wcshipping_migration_state', WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED );
$result = update_option( 'wcshipping_migration_state', WC_Connect_WCST_To_WCShipping_Migration_State_Enum::COMPLETED );

if ( $result ) {
$core_logger = new WC_Logger();
$logger = new WC_Connect_Logger( $core_logger );
$tracks = new WC_Connect_Tracks( $logger, __FILE__ );
$tracks->record_user_event(
'migration_flag_state_update',
array(
'migration_state' => $migration_state,
'updated' => $result,
)
);
}
}
}

Expand Down Expand Up @@ -959,7 +974,6 @@ public function init_shipping() {
add_filter( 'woocommerce_hidden_order_itemmeta', array( $this, 'hide_wc_connect_package_meta_data' ) );
add_filter( 'is_protected_meta', array( $this, 'hide_wc_connect_order_meta_data' ), 10, 3 );
add_action( 'current_screen', array( $this, 'edit_orders_page_actions' ) );
add_action( 'after_plugin_row_woocommerce-services/woocommerce-services.php', array( $this, 'add_custom_message_to_plugin_list' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -1562,30 +1576,6 @@ public function edit_orders_page_actions() {
}
}

/**
* Add a "deactivated" message to the plugin list table for WooCommerce Shipping & Tax
*
* @param string $plugin_file
* @param array $plugin_data
*/
public function add_custom_message_to_plugin_list() {
if ( false ) {
printf(
'<style>
.plugins tr[data-slug="woocommerce-services"] td, .plugins tr[data-slug="woocommerce-services"] th { box-shadow: none; }
</style>
<tr class="plugin-update-tr active update">
<td colspan="4" class="plugin-update colspanchange">
<div class="notice inline notice-warning" style="border:0; border-left: 5px solid #4AB866; padding: 12px; background-color: #EFF9F1;">
<p>%s</p>
</div>
</td>
</tr>',
wp_kses_post( __( 'WooCommerce Shipping & Tax has been deactivated. Your data and settings have been carried over to the dedicated WooCommerce Shipping and WooCommerce Tax extensions.<br />For support, please <a href="https://woocommerce.com/my-account/create-a-ticket/">contact our Happiness Engineers</a>.', 'woocommerce-services' ) )
);
}
}

/**
* Registers the React UI bundle
*/
Expand Down

0 comments on commit f59291e

Please sign in to comment.