From 259489a0b9ddd569dc39ac5d6cc22fa88d4ce12d Mon Sep 17 00:00:00 2001 From: Sam Seay Date: Thu, 8 Oct 2020 14:08:03 +1300 Subject: [PATCH] Fix a bug in tax automation logic and track the event in analytics (https://github.com/woocommerce/woocommerce-admin/pull/5276) --- .../src/Features/OnboardingAutomateTaxes.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-admin/src/Features/OnboardingAutomateTaxes.php b/plugins/woocommerce-admin/src/Features/OnboardingAutomateTaxes.php index 1356289f002..31e43c219d8 100644 --- a/plugins/woocommerce-admin/src/Features/OnboardingAutomateTaxes.php +++ b/plugins/woocommerce-admin/src/Features/OnboardingAutomateTaxes.php @@ -56,9 +56,10 @@ class OnboardingAutomateTaxes { $wcs_tos_accepted = \WC_Connect_Options::get_option( 'tos_accepted' ); } - if ( $jetpack_connected && $wcs_version && $wcs_tos_accepted ) { + if ( $jetpack_connected && $wcs_version && $wcs_tos_accepted && self::automated_tax_is_supported() ) { update_option( 'wc_connect_taxes_enabled', 'yes' ); update_option( 'woocommerce_calc_taxes', 'yes' ); + self::track_tax_automation(); Confirm_Tax_Settings::possibly_add_note(); } } @@ -67,6 +68,13 @@ class OnboardingAutomateTaxes { * Check if automated taxes are supported. */ private static function automated_tax_is_supported() { - return in_array( WC()->countries->get_base_country(), \OnboardingTasks::get_automated_tax_supported_countries(), true ); + return in_array( WC()->countries->get_base_country(), OnboardingTasks::get_automated_tax_supported_countries(), true ); + } + + /** + * Track when a user has tax automation enabled. + */ + private static function track_tax_automation() { + wc_admin_record_tracks_event( 'tasklist_task_completed', array( 'task_name' => 'tax_automated' ) ); } }