From 5be293f5c8b3c3412a0a365589aaca88f3ebd464 Mon Sep 17 00:00:00 2001 From: Ilyas Foo Date: Thu, 11 Mar 2021 17:55:59 +0800 Subject: [PATCH] Add CES survey for importing products (https://github.com/woocommerce/woocommerce-admin/pull/6419) * Add CES survey for importing products * Update readme and testing instructions --- .../woocommerce-admin/TESTING-INSTRUCTIONS.md | 11 ++++++ plugins/woocommerce-admin/readme.txt | 1 + .../Features/CustomerEffortScoreTracks.php | 38 ++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md b/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md index 9baf4f646b4..159f53d17ae 100644 --- a/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md +++ b/plugins/woocommerce-admin/TESTING-INSTRUCTIONS.md @@ -208,6 +208,17 @@ Scenario #2 - Go to Customers. - Type in anything in search bar, and press enter. - Observe CES prompt "How easy was it to use search?" is displayed + +### Add CES survey for importing products #6419 +- Make sure tracking is enabled in settings. +- Delete the option `woocommerce_ces_shown_for_actions` to make sure CES prompt triggers when updating settings. +- Enable the logging of Tracks events to your browser dev console `localStorage.setItem( 'debug', 'wc-admin:tracks' );` +- If you don't have a product CSV export, you can obtain a sample CSV [here](https://gist.githubusercontent.com/ilyasfoo/507f9579531cf4bf50fe4c0e9c48a23d/raw/05e47e6731471464c757e893c3f2d8a9b89453c0/product-export.csv). +- Go to Products > All Products. +- Click on "Import". +- Upload CSV file and finish the import process. +- Observe CES prompt "How easy was it to import products?" is displayed. + ## 2.1.2 ### Add Guards to "Deactivate Plugin" Note Handlers #6532 diff --git a/plugins/woocommerce-admin/readme.txt b/plugins/woocommerce-admin/readme.txt index 96726f5d6c7..80785851127 100644 --- a/plugins/woocommerce-admin/readme.txt +++ b/plugins/woocommerce-admin/readme.txt @@ -112,6 +112,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt - Dev: Add tilde (~) to represent client root directory for imports. #6517 - Add: Add Ireland to Square payment method #6559 - Add: CES survey for search product, order, customer #6420 +- Add: CES survey for importing products #6419 == 2.1.0 3/10/2021 == diff --git a/plugins/woocommerce-admin/src/Features/CustomerEffortScoreTracks.php b/plugins/woocommerce-admin/src/Features/CustomerEffortScoreTracks.php index 598fcb27c66..688996aefde 100644 --- a/plugins/woocommerce-admin/src/Features/CustomerEffortScoreTracks.php +++ b/plugins/woocommerce-admin/src/Features/CustomerEffortScoreTracks.php @@ -35,7 +35,12 @@ class CustomerEffortScoreTracks { const SETTINGS_CHANGE_ACTION_NAME = 'settings_change'; /** - * Action name for add product tags. + * Action name for import products. + */ + const IMPORT_PRODUCTS_ACTION_NAME = 'import_products'; + + /** + * Action name for search. */ const SEARCH_ACTION_NAME = 'ces_search'; @@ -46,7 +51,6 @@ class CustomerEffortScoreTracks { */ private $onsubmit_label; - /** * Constructor. Sets up filters to hook into WooCommerce. */ @@ -93,6 +97,8 @@ class CustomerEffortScoreTracks { ); add_action( 'load-edit.php', array( $this, 'run_on_load_edit_php' ), 10, 3 ); + add_action( 'product_page_product_importer', array( $this, 'run_on_product_import' ), 10, 3 ); + $this->onsubmit_label = __( 'Thank you for your feedback!', 'woocommerce-admin' ); } @@ -242,6 +248,34 @@ class CustomerEffortScoreTracks { update_option( self::CLEAR_CES_TRACKS_QUEUE_FOR_PAGE_OPTION_NAME, false ); } + /** + * Maybe enqueue the CES survey on product import, if step is done. + */ + public function run_on_product_import() { + // We're only interested in when the importer completes. + if ( empty( $_GET['step'] ) || 'done' !== $_GET['step'] ) { // phpcs:ignore CSRF ok. + return; + } + + if ( $this->has_been_shown( self::IMPORT_PRODUCTS_ACTION_NAME ) ) { + return; + } + + $this->enqueue_to_ces_tracks( + array( + 'action' => self::IMPORT_PRODUCTS_ACTION_NAME, + 'label' => __( + 'How easy was it to import products?', + 'woocommerce-admin' + ), + 'onsubmit_label' => $this->onsubmit_label, + 'pagenow' => 'product_page_product_importer', + 'adminpage' => 'product_page_product_importer', + 'props' => (object) array(), + ) + ); + } + /** * Enqueue the CES survey trigger for setting changes. */