Skip to content

Conversation

@Jinksi
Copy link
Contributor

@Jinksi Jinksi commented May 4, 2022

All Submissions:

Changes proposed in this Pull Request:

This PR prevents rendering the WooCommerce > Subscriptions menu item for WooCommerce stores that are ineligible for the experiment, as defined in #32682.

A store is ineligible for the experiment if:

  • The store has WooCommerce Payments installed.
  • The store has any subscription plugins installed, as discussed here: pdjTHR-WQ-p2.
  • The store address is not USA (eligible for WCPay Subscriptions).
  • The store has:
    • Been live for < 6 months.
    • Had < 1 sale in last 30 days.

Conflicting subscription plugins, installed and confirmed to ensure ineligibility:

Part of #32682

How to test the changes in this Pull Request:

  1. Checkout this branch. I recommend running a fresh wp-env from the plugins/woocommerce directory, so you can delete plugins in an isolated environment.
  2. Make your store eligible for the experiment:
    1. Delete any subscription plugins and WooCommerce Payments (if installed).
    2. Set your store’s address to a location in USA.
    3. Set your store’s installation timestamp to a time >= 6 months age. Do this by updating the woocommerce_admin_install_timestamp option in the wp_options table to a Unix timestamp that is >= 6 months in the past.
      I installed the WP Console plugin and used it to run the following:
      update_option( 'woocommerce_admin_install_timestamp', strtotime( '-6 months' ) );
    4. If your store has not had a completed order in the last 30 days, create a test order and mark it as completed.
      Delete the existing cached transient: Using WP Console, run delete_transient( 'woocommerce-wcpay-subscriptions_recent_sales_eligibility' );
  3. You should see the WooCommerce > Subscriptions menu item and be able to click on it to view the empty state page.
  4. Test store location ineligibility:
    1. Set your store’s address to a location in a country other than USA.
    2. Refresh/navigate to WooCommerce admin, the WooCommerce > Subscriptions menu item should not be visible.
    3. Reset the store location to USA to become eligible, as per step 2.
  5. Test store age ineligibility:
    1. Set your store’s installation timestamp to a time < 6 months age, using method from step 2.
      update_option( 'woocommerce_admin_install_timestamp', strtotime( '-1 month' ) );
    2. Refresh/navigate to WooCommerce admin, the WooCommerce > Subscriptions menu item should not be visible.
    3. Reset the store age to become eligible, as per step 2.
  6. Store sales ineligibility:
    1. Delete any orders from the last 30 days.
    2. Delete the existing transient cache:
      Using WP Console, run delete_transient( 'woocommerce-wcpay-subscriptions_recent_sales_eligibility' );
    3. Refresh/navigate to WooCommerce admin, the WooCommerce > Subscriptions menu item should not be visible.
    4. Create a test order and set the order status to Completed, then delete the cached transient to become eligible, as per step 2.
  7. WooCommerce Payments ineligibility:
    1. Install and optionally activate WooCommerce Payments.
    2. Refresh/navigate to WooCommerce admin, the WooCommerce > Subscriptions menu item should be visible. Clicking on this should navigate you to the WCPay Subscriptions page, rather than the empty state experiment page.
    3. Delete the plugin to become eligible, as per step 2.
  8. Subscriptions plugin ineligibility (repeat the following steps for multiple subscriptions plugins):
    1. Install and optionally activate a subscription plugin.
    2. Refresh/navigate to WooCommerce admin.
      1. If a WooCommerce > Subscriptions menu item exists, clicking it should not navigate to the empty state subscriptions page.
    3. Delete the plugin to become eligible, as per step 2.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you created a changelog file by running pnpm nx affected --target=changelog?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@Jinksi Jinksi requested review from aprea and james-allan May 4, 2022 05:50
@github-actions github-actions bot added focus: react admin plugin: woocommerce Issues related to the WooCommerce Core plugin. labels May 4, 2022
@Jinksi Jinksi changed the title Add/experiment subscriptions admin menu eligibility Ensure subscriptions menu (experiment) is only visible to eligible stores May 4, 2022
Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

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

Nice work on this so far @Jinksi. I haven't had a chance to test it yet but gave some initial feedback about the wc_get_orders() query.

@Jinksi Jinksi marked this pull request as ready for review May 5, 2022 02:34
Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

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

Changes look good and work well in testing. I've just left a comment about adding 1 additional slug for other subscription plugin options.

We may need to confirm internally the sale criteria but otherwise this works for me.

Nice work @Jinksi !

Jinksi and others added 3 commits May 10, 2022 04:02
…eriment-subscriptions-admin-menu-eligibility

# Conflicts:
#	plugins/woocommerce/src/Internal/Admin/WcPaySubscriptionsPage.php
@james-allan
Copy link
Contributor

LGTM! Nice work @Jinksi

Here's the set of tests I've run locally:

Location:

  • Not shown to AUS based stores.
  • Shown for US based stores.

Store Age:

  • Shown for stores active for at least 6 months.
  • Not shown for a store active in the last 6 months. (not at least 6 months old).

Recent Sales:

  • Shown for stores with a sale in the last month.
    • Confirmed for an order from today
    • Confirmed for an order from 2 weeks ago
    • Confirmed from an order exactly 30 days ago.
    • Note I had to delete the transient each time to test these.
  • Hidden for stores without a sale in the last 30 days.

Subscription plugins:

  • 'woocommerce-payments',
  • 'woocommerce-subscriptions',
  • 'subscriptio',
  • 'subscriptions-for-woocommerce',
  • 'subscriptions-for-woocommerce-pro', 🔴
  • 'sumosubscriptions',
  • 'yith-woocommerce-subscription',
  • 'xa-woocommerce-subscriptions', 🔴

The two plugins noted with a 🔴 I wasn't able to test without getting my hands on the plugin itself. IMO it's reasonably safe to assume those slugs are correct after we found them referenced in the internal data sources.

@Jinksi Jinksi merged commit c924fbd into add/experiment-subscriptions-admin-menu-1 May 11, 2022
@Jinksi Jinksi deleted the add/experiment-subscriptions-admin-menu-eligibility branch May 11, 2022 00:01
@github-actions
Copy link
Contributor

Hi @Jinksi, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants