Skip to content

Commit 88cd4b6

Browse files
retrofoxmatticbot
authored andcommitted
Premium Analytics: show the WooCommerce tab on every site running WooCommerce (#53588)
* show the WooCommerce tab without the store flag * drop the store section feature flag * drop the dead Enablement_Setting require from the test Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/39227527123 Upstream-Ref: Automattic/jetpack@3296752
1 parent 1ed7735 commit 88cd4b6

3 files changed

Lines changed: 5 additions & 22 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This is an alpha version! The changes listed here are not final.
2020
### Changed
2121
- Gate the WooCommerce tab and its widgets in the package: WooCommerce active, the reader's store reports capability, and the Bookings extension for the bookings widgets.
2222
- Rearrange the WooCommerce tab's default layout, which no longer includes the sales, orders and visitors over time widgets.
23+
- Show the WooCommerce tab on every site running WooCommerce, to readers of the store reports.
2324
- Store visitors by location: Remove the region toggle and list countries worldwide.
2425
- Top performing products and bookings: Show the rows as soon as the report answers; the thumbnails fill in behind.
2526
- Update package dependencies.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The widgets read those reports with the client in `src/reports/`: one hook per r
1010

1111
The widget types live in `widgets/`. wp-build builds them, and the package registers them from the build manifest when the dashboard's widget contract is 1.11 or newer. They draw with the kinds the dashboard SDK exports, so the charts are the dashboard's own. The time series family is here: net, total and gross sales, orders, average order value, average items per order, bookings and visitors over time. So are the breakdowns: new vs returning customer, payment status, orders fulfillment, coupon usage over time, bookings by status and sessions by device; the leaderboards: top performing products and bookings, and sales by UTM source, channel and campaign; Store performance, the store metrics as tabs over one chart, picked in the widget header, with the `jetpack.woocommerceStats.storePerformance.metrics` filter for a plugin to add its own (the package adds Bookings this way, from `packages/store-performance-bookings`, on a store running the extension); the conversion funnel, for every product and for bookings; the columns: revenue by customer type, sales by device, total returns and sales by coupon, with the bookings variants of the first two; and visitors by location, countries listed beside a map.
1212

13-
The plugin that bundles it, Jetpack or the standalone Premium Analytics plugin, calls `Analytics_Dashboard::init()`. The package gates the section and its widget types itself: WooCommerce active, the store-reports capability, the Bookings extension for the bookings widgets and the Bookings metric, and the dashboard's store-section flag on a site that opted in on its own.
13+
The plugin that bundles it, Jetpack or the standalone Premium Analytics plugin, calls `Analytics_Dashboard::init()`. The package gates the section and its widget types itself: WooCommerce active, the store-reports capability, and the Bookings extension for the bookings widgets and the Bookings metric.
1414

1515
## Using this package in your WordPress plugin
1616

‎src/class-analytics-dashboard.php‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Automattic\Jetpack\WooCommerceStats;
99

10-
use Automattic\Jetpack\PremiumAnalytics\Enablement_Setting;
1110
use Automattic\Jetpack\PremiumAnalytics\Sync\Sync_Status_Tracker;
1211
use function Automattic\Jetpack\PremiumAnalytics\get_dashboard_default_widget_instance;
1312
use function Automattic\Jetpack\PremiumAnalytics\register_dashboard_section;
@@ -327,13 +326,13 @@ public static function register_widget_types( $registry ) {
327326
}
328327

329328
/**
330-
* Whether the WooCommerce tab is available: WooCommerce is active, the reader may see store
331-
* reports, and a site that opted in on its own carries the dashboard's store flag.
329+
* Whether the WooCommerce tab is available: WooCommerce is active and the reader may see store
330+
* reports.
332331
*
333332
* @return bool
334333
*/
335334
public static function is_section_available() {
336-
return self::is_store_section_enabled() && self::is_woocommerce_available() && self::current_user_can_view_store_reports();
335+
return self::is_woocommerce_available() && self::current_user_can_view_store_reports();
337336
}
338337

339338
/**
@@ -364,23 +363,6 @@ public static function current_user_can_view_store_reports() {
364363
return current_user_can( 'manage_options' ) || current_user_can( 'view_woocommerce_reports' );
365364
}
366365

367-
/**
368-
* The dashboard's soft-launch policy: a site that opted in through the option needs the store
369-
* flag; the blog sticker and the enabled filter leave the option off and keep every section.
370-
*
371-
* @return bool
372-
*/
373-
private static function is_store_section_enabled() {
374-
if ( ! get_option( Enablement_Setting::ENABLED_OPTION ) ) {
375-
return true;
376-
}
377-
378-
// An older dashboard package may have loaded dashboard-policy.php without the flag.
379-
$is_flag_enabled = 'Automattic\\Jetpack\\PremiumAnalytics\\is_dashboard_store_section_enabled';
380-
381-
return function_exists( $is_flag_enabled ) && $is_flag_enabled();
382-
}
383-
384366
/**
385367
* Whether the WooCommerce Bookings extension is active; `is_plugin_active()` only exists in
386368
* admin contexts, hence the guard.

0 commit comments

Comments
 (0)