Skip to content

Conversation

@james-allan
Copy link
Contributor

@james-allan james-allan commented May 11, 2022

All Submissions:

Changes proposed in this Pull Request:

Internal project: pdjTHR-Vi-p2

This PR adds a Subscriptions item to the WooCommerce admin menu for eligible stores * . This admin screen is part of an experiment to offer eligible merchants WooCommerce Payments built in Subscriptions functionality.

* eligible stores are stores without any subscriptions functionality plugin installed, are older than 6 months and have at least 1 sale in the last 30 days.

Screen Shot 2022-05-11 at 2 45 09 pm

Closes #32682
Closes #32691
Closes #32694

This PR is made up of the following PRs:

How to test the changes in this Pull Request:

  1. Checkout this branch and build assets by running pnpm nx watch woocommerce-admin or grab a zip of this PR here → woocommerce.zip
  2. Plugin eligibility: Ensure the following plugins are not installed at all:
    • WooCommerce Subscriptions
    • WooCommerce Payments
    • Sumo Subscriptions
    • Yith Subscriptions
    • Subscripto
    • Subscriptions For WooCommerce
  3. Store tracking eligibility: Your store allows tracking.
    • This checkbox should be checked: WooCommerce → Settings → Advanced → WooCommerce.com → Enable tracking.
  4. Store location eligibility: For the menu item to be displayed your store needs to based in the US.
    • Go to WooCommerce > Settings and make sure your store is set to a US based address.
  5. Store age criteria: To view the subscription menu item your store will need to have been active for more than 6 months - we're testing this experiment on established stores. If your store doesn't meet this criteria, you can use the following code snippet:
    • update_option( 'woocommerce_admin_install_timestamp', strtotime( '-6 month' ) );
    • or change the woocommerce_admin_install_timestamp option to 1620866357 (timestamp from ~1 year ago) via the /wp-admin/options.php page.
  6. Paid order criteria: Only stores with at least 1 order in the last 30 days are eligible. If your store doesn't have an order in the last 30 days. Either:
    1. Set any existing pending or failed order to processing or completed
    2. If you don't have any order at all, you can just manually create one in WooCommerce > Orders > Add new and set it to processing or completed status
    3. ⚠️ Note: this order sale query is cached and so you may need to delete the 'woocommerce-wcpay-subscriptions_recent_sales_eligibility' transient if this criteria failed previously.
  7. If you meet all the criteria above you should see a WooCommerce > Subscriptions (new) menu item.
  8. View the WooCommerce > Subscriptions (new) page.
    • The 'new' badge should disappear on subsequent page loads.

Screen Shot 2022-05-11 at 2 34 56 pm

The error scenario

If an error occurs during plugin installation and activation an error message will be displayed directing the user to install the WooCommerce Payments plugin manually.

To test this flow:

  1. Add the following code snippet to your site.
  2. Go to WooCommerce -> Subscriptions
  3. Click "Get started"
  4. An error should occur installing the plugin. See example below.
define( 'DISALLOW_FILE_MODS', true );

Screen Shot 2022-05-11 at 3 00 59 pm

Note: The link takes the user to the WooCommerce Payments wp.org page.

The success scenario

  1. Go to WooCommerce > Subscriptions
  2. Click "Get started"
  3. WooCommerce Payments will be installed and activated in the background
  4. Once complete, you will be directed to the “Add new product” page or to the WCPay onboarding flow depending on which experiment treatment you were assigned to. Please see the "Testing the treatments" section below for more instructions.

The dismiss scenario

  1. Go to WooCommerce > Subscriptions
  2. Click "No thanks"
  3. You should be redirected to the WooCommerce > Home screen and the subscriptions menu item should no longer be displayed.

Note: If you need to bring the menu item back, delete or change the woocommerce-wcpay-subscriptions_dismissed wp option.

Testing the treatments

Download, install and activate the WooCommerce Admin Test Helper plugin.

Navigate to Tools → WCA Test Helper → Experiments. This page should contain a row for the "woocommerce_wcpay_subscriptions_page_202207_v1" experiment.

Here you can toggle between the control (treatment A) and the treatment (treatment B).

Treatment A

  1. Toggle to the control experience from Tools → WCA Test Helper → Experiments.
  2. Navigate to WooCommerce → Subscriptions.
  3. Observe the following step headers in the "You’re only steps away from selling subscriptions" section.
    1. Create a subscription
    2. Create and connect your account
    3. Provide a few business details
  4. Click the "Get started" button.
  5. The WooCommerce Payments plugin will be installed & activated and you will be redirected to the “Add new product” page.

Treatment B

  1. Toggle to the treatment experience from Tools → WCA Test Helper → Experiments.
  2. Navigate to WooCommerce → Subscriptions.
  3. Observe the following step headers in the "You’re only steps away from selling subscriptions" section.
    1. Create and connect your account
    2. Provide a few business details
    3. Create subscriptions
  4. Click the "Get started" button.
  5. The WooCommerce Payments plugin will be installed & activated and you will be redirected to the WCPay onboarding flow.

--


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 for each project being changed, ie pnpm nx changelog <project>?

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.

Chris Aprea and others added 30 commits April 22, 2022 16:11
…ns-error-notice

Display an error message when WC Payments fails to install via the Subscriptions menu item
…ns-admin-new-design

Implement the new subscriptions page design
@botwoo
Copy link
Collaborator

botwoo commented May 16, 2022

📊 Test reports for this pull request have been published and are accessible through the following links:

Latest commit referenced in the reports: Introduce susbcriptions menu item slug constant 3cecb3d
This comment will automatically be updated with the latest referenced commit when you push new changes to this pull request.


Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them.

@aprea aprea added this to the 6.6.0 milestone May 17, 2022
@botwoo
Copy link
Collaborator

botwoo commented May 17, 2022

📊 Test reports for 0afc9dd Merge branch 'trunk' into add/experiment-subscriptions-admin-menu-1 have been published and are accessible through the following links:

Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them.

@aprea aprea requested review from a team and vedanshujain and removed request for a team May 17, 2022 09:59
Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

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

Testing well, added a few questions, though. Thanks!

add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );

// Priority 50 to run after Automattic\WooCommerce\Internal\Admin\Homescreen::update_link_structure() which runs on 20.
add_action( 'admin_menu', array( $this, 'restructure_menu_order' ), 50 );
Copy link
Contributor

Choose a reason for hiding this comment

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

if this should always be called after Admin\Homescreen::update_link_structure, it might be better to call this directly. There could be other menu items interfering between priority 20 from update_link_structure and 50 here.

Copy link
Contributor Author

@james-allan james-allan May 19, 2022

Choose a reason for hiding this comment

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

Just to clarify, you recommend we call our function to move the subscriptions menu item (WcPaySubscriptionsPage::restructure_menu_order()) to be called directly from within the (Admin\Homescreen::update_link_structure()) function?

We can definitely do that however the Admin\Homescreen class specifically handles the "Home" menu item and so it would be additional code clutter for it to also be calling a function directly to wrangle another menu item.

There could be other menu items interfering between priority 20 from update_link_structure and 50 here.

I don't think this is a big concern for us if this were to happen. We'd prefer that this "Subscriptions" menu item has consistant placement with the WooCommerce Subscriptions "subscriptions" menu item, however, if something was to interfere and move it further down or up we wouldn't be too concerned. I'd be more concerned about a less cleaner code separation tbh given this is an experiment.

'title' => _x( 'Subscriptions', 'Admin menu name', 'woocommerce' ),
'parent' => 'woocommerce',
'path' => '/subscriptions',
'capability' => 'manage_options',
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be manage_woocommerce?

Copy link
Contributor

Choose a reason for hiding this comment

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

The new "Subscriptions" admin page has a "Get started" button that, when clicked, will install and activate the WooCommerce Payments plugin on the site. The user must then complete WCPay onboarding (Stripe KYC).

So this capability needs to be permissive enough to allow them to complete these actions.

I just checked the manage_woocommerce capability and I don't think it'll work here as it's granted to the Shop Manager role. This role does not have the required activate_plugins or install_plugins capabilities. (ref)

@aprea
Copy link
Contributor

aprea commented May 19, 2022

Hi @vedanshujain, apologies for the late notice but we were hoping to have this PR merged in time for the WC 6.6. code freeze (Thursday 4pm UTC).

Would you be able to approve/merge this PR assuming there's no additional blocking feedback?

/cc @haszari

@vedanshujain vedanshujain merged commit 5ab229d into trunk May 19, 2022
@vedanshujain vedanshujain deleted the add/experiment-subscriptions-admin-menu-1 branch May 19, 2022 03:02
@github-actions
Copy link
Contributor

github-actions bot commented May 19, 2022

Hi @vedanshujain, 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

@vedanshujain vedanshujain added the release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] label May 19, 2022
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. release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto]

Projects

None yet

7 participants