-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Add WooCommerce > Subscriptions admin menu item and empty state offer screen #32957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WooCommerce > Subscriptions admin menu item and empty state offer screen #32957
Conversation
…eriment-subscriptions-admin-menu-1
…ns-error-notice Display an error message when WC Payments fails to install via the Subscriptions menu item
…iment-subscriptions-admin-menu-1
…eriment-subscriptions-admin-new-design
Co-authored-by: James Allan <[email protected]>
…ns-admin-new-design Implement the new subscriptions page design
…ns-admin-menu-experiment-framework Add experiment functionality to the WooCommerce → Subscriptions page
|
📊 Test reports for this pull request have been published and are accessible through the following links:
Latest commit referenced in the reports: Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them. |
|
📊 Test reports for 0afc9dd
Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them. |
vedanshujain
left a comment
There was a problem hiding this 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 ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_structureand 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.
plugins/woocommerce/src/Internal/Admin/WcPaySubscriptionsPage.php
Outdated
Show resolved
Hide resolved
| 'title' => _x( 'Subscriptions', 'Admin menu name', 'woocommerce' ), | ||
| 'parent' => 'woocommerce', | ||
| 'path' => '/subscriptions', | ||
| 'capability' => 'manage_options', |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
plugins/woocommerce/src/Internal/Admin/WcPaySubscriptionsPage.php
Outdated
Show resolved
Hide resolved
plugins/woocommerce/src/Internal/Admin/WcPaySubscriptionsPage.php
Outdated
Show resolved
Hide resolved
Using these two order properties instead of the paid_date field is more performance friendly as both fields are in the wp-posts table - not in the post_meta table. ref: https://github.com/woocommerce/woocommerce/pull/32957/files/71e9657e52d7d6c8bee863ca064bb2153ee11798#r875545984
|
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 |
|
Hi @vedanshujain, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:
|
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.
Closes #32682
Closes #32691
Closes #32694
This PR is made up of the following PRs:
How to test the changes in this Pull Request:
pnpm nx watch woocommerce-adminor grab a zip of this PR here → woocommerce.zipupdate_option( 'woocommerce_admin_install_timestamp', strtotime( '-6 month' ) );woocommerce_admin_install_timestampoption to1620866357(timestamp from ~1 year ago) via the/wp-admin/options.phppage.'woocommerce-wcpay-subscriptions_recent_sales_eligibility'transient if this criteria failed previously.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:
❗Note: The link takes the user to the WooCommerce Payments wp.org page.
The success scenario
The dismiss scenario
Note: If you need to bring the menu item back, delete or change the
woocommerce-wcpay-subscriptions_dismissedwp 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
Treatment B
--
Other information:
pnpm nx changelog <project>?FOR PR REVIEWER ONLY: