Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Conversation

@octaedro
Copy link
Contributor

Fixes #4213

This PR adds a note to remind the user to test the checkout process.
This note should be triggered when the user has a payment method AND adds or imports products.

Segmentation:
New users with setup_client: false on wcadmin_storeprofiler_store_details_continue
Timing:
"After triggering:
wcadmin_product_add_publish or wcadmin_product_import_complete
AND
task_name: payments on wcadmin_tasklist_task_completed
Cadence: Once

Screenshots

screenshot-one wordpress test-2020 07 14-12_54_00

Detailed test instructions:

  • Execute the cron. To do it you can install this plugin and go to /wp-admin/tools.php?page=crontrol_admin_manage_pageand press wc_admin_daily.
  • Add a new product.
  • At the end of the process, the note should be visible.
  • Remove the note and the variable: wc_admin_note_test_checkout_product_added from the database with a sentence like this:
DELETE FROM `wp_options` WHERE `wp_options`.`option_name` = 'wc_admin_note_test_checkout_product_added';
DELETE FROM `wp_wc_admin_notes` WHERE `wp_wc_admin_notes`.`name` = 'wc-admin-test-checkout';
  • Import products.

  • At the end of the process, the note should be visible.

  • Verify the call to action button in the note opens the store frontend in a new tab

Changelog Note:

Dev: New notification: Don't forget to test your checkout

@octaedro octaedro added [Status] Needs Review focus: inbox Issues related to inbox notifications labels Jul 14, 2020
@octaedro octaedro requested a review from a team July 14, 2020 15:55
@octaedro octaedro self-assigned this Jul 14, 2020
// Make sure a product was published or imported.
$product_added = get_option(
self::PRODUCT_ADDED_OPTION_NAME
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than hook into the importer and post status transition hooks, what do you think about checking the status of the products step in the task list instead? Seems like this could be simpler if we were just checking for the products and payments steps to be complete.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like this idea Jeff!

Copy link
Contributor Author

@octaedro octaedro Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jeffstieler, thanks for your review.
Diving a little bit into that part of the code, I realized that the check (that later will be used to set the products state in the task list) is calculated in the API side in the method check_task_completion and it's asking for products with state published or draft. From what I understand, this could be a problem since we need to show the note after the product publication, but the list item could be set as completed without a published product.
Please correct me if I misunderstood your suggestion or I'm forgetting something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. looks like that wasn't the original intention and was updated later: #2667 (comment)

Perhaps we should look at only marking the step complete if there are published products? cc: @timmyc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I concur there, but cc @pmcpinto to verify for sure. The product step right now will get marked as done even when a product is in the draft state. But I definitely like tying this note to that step being completed because it will eliminate this note possibly being shown on an established site.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jeffstieler and @timmyc, I removed the verification of the products with state draft in the commit 14d5df2 and it looks like everything is working well.

I was thinking about when this note should be shown. If the user doesn't set a payment method when the Add my products task list is completed, the note won't be shown. Also, we don't save a timestamp when we update the products' task list, which means that we don't know when we completed this task list item.

The note reminds the user Don't forget to test your checkout, so it looks like we should show the note if the user adds their first product and has the other conditions we need. For instance, a user could have everything set but no products for a month. Should we show the note if they suddenly add a product?

If the answer is yes, I think that we should verify the published date of the first product, and if it's within the last 30 (or 15, or 10) minutes and fulfills the other conditions, I would trigger the note.
Does this make sense?

$note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'test-checkout', __( 'Test checkout', 'woocommerce-admin' ), site_url() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use wc_get_page_permalink( 'shop' ) here it will direct them to the shop, and automatically falls back to the site url.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I replaced the method in the commit 58c866a

@jeffstieler jeffstieler added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed [Status] Needs Review labels Jul 16, 2020
@pmcpinto
Copy link

The product step right now will get marked as done even when a product is in the draft state. But I definitely like tying this note to that step being completed because it will eliminate this note possibly being shown on an established site.

Can we use the store creation date to avoid show this to existing stores? We have a good amount of new users that add a product without going through the task list step. Is this step being marked as completed even if they add a product without passing by this task?

@octaedro
Copy link
Contributor Author

octaedro commented Jul 20, 2020

Hi @pmcpinto,

Can we use the store creation date to avoid show this to existing stores?

Looking at the notification message I was thinking that maybe we could do the verification using the date of the first published product to show this note.
I'm thinking about the case where a user could have everything set in their store but no products for a month. After adding their first product we can incentivize them to take a look at their checkout process.
Maybe we can check if the user added a product in the last half hour to show this note.
Does this make sense?

We have a good amount of new users that add a product without going through the task list step. Is this step being marked as completed even if they add a product without passing by this task?

Yes, we mark the step as complete even if the user adds a product without passing by this task.

@pmcpinto
Copy link

Does this make sense?

Yep, sounds good to me. Thanks for the suggestion!

@octaedro
Copy link
Contributor Author

octaedro commented Jul 21, 2020

According to Pedro's answer I added the time validation (30 minutes) to the first published product in the commit 04faa14.
At the same time, now we're checking the status of the products step in the task list (as @jeffstieler suggested) and I added another hook to do the same with the payment methods step.
Also, I did a rebase since there were a few conflicts between branches.
I think that now this PR is ready for another look.

@octaedro octaedro added [Status] Needs Review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Jul 21, 2020
}

$oldest_product_timestamp = $products[0]->get_date_created()->getTimestamp();
$half_hour_in_seconds = 0.5 * HOUR_IN_SECONDS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: 30 * MINUTE_IN_SECONDS would avoid float and int comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I modified it in the commit 8d31053

return;
}

$content = __( 'Make sure that your checkout is working properly before your launch your store. Go through your checkout process in its entirety: from adding a product to your cart, choosing a shipping location, and making a payment.', 'woocommerce-admin' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "before your launch your store" -> "before you launch your store".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I changed it in the commit 85a0054

Copy link
Contributor

@jeffstieler jeffstieler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tested well - just need to fix a typo and make some minor code tweaks. Pre-approving.

@jeffstieler jeffstieler added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. [Status] Ready to Merge and removed [Status] Needs Review labels Jul 21, 2020
octaedro added 4 commits July 22, 2020 14:27
This commit adds a note to test the checkout process

# Conflicts:
#	src/Events.php
#	src/FeaturePlugin.php
…tion"

This commit modifies the code to not set the products task list item as done when they have state draft.
This commit adds a product published date control to the note
@octaedro
Copy link
Contributor Author

As all the fixes have been addressed I'm going to merge this PR.

@octaedro octaedro removed the needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. label Jul 22, 2020
@octaedro octaedro merged commit 4b7cbb8 into main Jul 22, 2020
@octaedro octaedro deleted the add/4213 branch July 22, 2020 18:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

focus: inbox Issues related to inbox notifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New notification: Don't forget to test your checkout

5 participants