' !== $post->post_type || 'products' !== self::get_active_task() || ! self::is_active_task_complete() ) { return; } wp_enqueue_script( 'onboarding-product-notice', Loader::get_url( 'wp-admin-scripts/onboarding-product-notice', 'js' ), array( 'wp-i18n', 'wp-data' ), WC_ADMIN_VERSION_NUMBER, true ); } /** * Hooks into the post page to display a different success notice and sets the active page as the site's home page if visted from onboarding. * * @param string $hook Page hook. */ public static function add_onboarding_homepage_notice_admin_script( $hook ) { global $post; if ( 'post.php' === $hook && 'page' === $post->post_type && isset( $_GET[ self::ACTIVE_TASK_TRANSIENT ] ) && 'homepage' === $_GET[ self::ACTIVE_TASK_TRANSIENT ] ) { // phpcs:ignore csrf ok. wp_enqueue_script( 'onboarding-homepage-notice', Loader::get_url( 'wp-admin-scripts/onboarding-homepage-notice', 'js' ), array( 'wc-navigation', 'wp-i18n', 'wp-data', 'wc-tracks' ), WC_ADMIN_VERSION_NUMBER, true ); } } /** * Adds a notice to return to the task list when the save button is clicked on tax settings pages. */ public static function add_onboarding_tax_notice_admin_script() { $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; // phpcs:ignore csrf ok, sanitization ok. $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : ''; // phpcs:ignore csrf ok, sanitization ok. if ( 'wc-settings' === $page && 'tax' === $tab && 'tax' === self::get_active_task() && ! self::is_active_task_complete() ) { wp_enqueue_script( 'onboarding-tax-notice', Loader::get_url( 'wp-admin-scripts/onboarding-tax-notice', 'js' ), array( 'wc-navigation', 'wp-i18n', 'wp-data' ), WC_ADMIN_VERSION_NUMBER, true ); } } /** * Adds a notice to return to the task list when the product importeris done running. * * @param string $hook Page hook. */ public function add_onboarding_product_import_notice_admin_script( $hook ) { $step = isset( $_GET['step'] ) ? $_GET['step'] : ''; // phpcs:ignore csrf ok, sanitization ok. if ( 'product_page_product_importer' === $hook && 'done' === $step && 'product-import' === self::get_active_task() ) { delete_transient( self::ACTIVE_TASK_TRANSIENT ); wp_enqueue_script( 'onboarding-product-import-notice', Loader::get_url( 'wp-admin-scripts/onboarding-product-import-notice', 'js' ), array( 'wc-navigation', 'wp-i18n', 'wp-data' ), WC_ADMIN_VERSION_NUMBER, true ); } } /** * Get an array of countries that support automated tax. * * @return array */ public static function get_automated_tax_supported_countries() { // https://developers.taxjar.com/api/reference/#countries . $tax_supported_countries = array_merge( array( 'US', 'CA', 'AU' ), WC()->countries->get_european_union_countries() ); return $tax_supported_countries; } /** * Returns a list of Stripe supported countries. This method can be removed once merged to core. * * @return array */ private static function get_stripe_supported_countries() { // https://stripe.com/global. return array( 'AU', 'AT', 'BE', 'BG', 'BR', 'CA', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HK', 'IN', 'IE', 'IT', 'JP', 'LV', 'LT', 'LU', 'MY', 'MT', 'MX', 'NL', 'NZ', 'NO', 'PL', 'PT', 'RO', 'SG', 'SK', 'SI', 'ES', 'SE', 'CH', 'GB', 'US', 'PR', ); } /** * Records an event when all tasks are completed in the task list. * * @param mixed $old_value Old value. * @param mixed $new_value New value. */ public static function track_completion( $old_value, $new_value ) { if ( $new_value ) { wc_admin_record_tracks_event( 'tasklist_tasks_completed' ); } } /** * Records an event when all tasks are completed in the extended task list. * * @param mixed $old_value Old value. * @param mixed $new_value New value. */ public static function track_extended_completion( $old_value, $new_value ) { if ( $new_value ) { wc_admin_record_tracks_event( 'extended_tasklist_tasks_completed' ); } } /** * Records an event for individual task completion. * * @param mixed $old_value Old value. * @param mixed $new_value New value. */ public static function track_task_completion( $old_value, $new_value ) { $old_value = is_array( $old_value ) ? $old_value : array(); $untracked_tasks = array_diff( $new_value, $old_value ); foreach ( $untracked_tasks as $task ) { wc_admin_record_tracks_event( 'tasklist_task_completed', array( 'task_name' => $task ) ); } } /** * Update registered extended task list items. */ public static function update_option_extended_task_list() { if ( ! \Automattic\WooCommerce\Admin\Loader::is_admin_page() || ! \Automattic\WooCommerce\Admin\Features\Onboarding::should_show_tasks() ) { return; } $extended_tasks_list_items = get_option( 'woocommerce_extended_task_list_items', array() ); $registered_extended_tasks_list_items = apply_filters( 'woocommerce_get_registered_extended_tasks', array() ); if ( $registered_extended_tasks_list_items !== $extended_tasks_list_items ) { update_option( 'woocommerce_extended_task_list_items', $registered_extended_tasks_list_items ); update_option( 'woocommerce_extended_task_list_hidden', 'no' ); } } }