Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
88 stars 33 forks source link

Move the subscriptions empty state screen from WooPayments to core #489

Closed james-allan closed 1 year ago

james-allan commented 1 year ago

Fixes #https://github.com/woocommerce/woocommerce-subscriptions/issues/4549

Description

In WooPayments v3.4 we introduced empty state screens for the WooCommerce Subscriptions admin list table. see https://github.com/Automattic/woocommerce-payments/pull/3403

As part of that PR there were 2 variations of that screen.

  1. If the merchant had not onboarded to WooPayments it would include a button for them to onboard.
  2. If the merchant had onboarded, it would include base screen which mentioned that subscriptions will be listed here and a link to create a product. See screenshot below.

This PR moves the base screen to subscriptions core so that all subscription-core client products (WooPayments and Woo Subscriptions) have the updated empty state screen.

Screenshot 2023-08-02 at 9 46 56 am

Note This will require a set of accompanying changes in Woo Payments that this version of core is merged into to ensure no breakage.

How to test this PR

Warning When testing this PR beware that the function used to determine whether to display the empty state (ie do subscriptions exist) uses a caching system and so it's suggested that if you flip between having and not having subscriptions that you clear the cache or bypass it in cache_and_get().

  1. Make sure you have WC Subscriptions plugin active.
  2. Delete all your subscriptions.
    • If you'd prefer to keep them, you can do a bulk post type update and restore it after testing.
  3. Go to the WooCommerce > Subscriptions screen.
    • On trunk you'll see an empty list with simple html elements (p and a tags).
    • On this branch you should see the new empty state screen.
  4. The button should take you to the edit product page.
  5. Purchase a subscription.
  6. Go to the subscriptions admin list table.
    • You should see the subscription you just purchased listed.
  7. Filter the list table by searching for an dummy string - we want to test 0 results.
    • You should just see the "No subscriptions found." text.

This PR deprecates the old hook woocommerce_subscriptions_not_found_label. This hook used to filter the plain text "No Subscriptions found", however it was being used by WooPayments to also return full HTML content. Given the name ("label"), it no longer makes sense for it to exist in that form. I've deprecated it, still call it but have replaced it with a new hook woocommerce_subscriptions_not_found_html.

To test the deprecation you can enable WooPayments, disable WC Subscriptions and reload the WooCommerce > Subscriptions screen. You should see the same empty state but this deprecation warning should be shown.

woocommerce_subscriptions_not_found_label is deprecated since version 6.1.0! Use woocommerce_subscriptions_not_found_html instead.

Product impact