Skip to content

Commit

Permalink
Updates to 5.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
WooCommerce committed Oct 18, 2023
1 parent ad47a6a commit 5eedf6a
Show file tree
Hide file tree
Showing 52 changed files with 1,121 additions and 730 deletions.
23 changes: 23 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
*** Woo Subscriptions Changelog ***

2023-10-18 - version 5.6.0
* Add: Introduce the "Subscription Relationship" column under the Orders list admin page when HPOS is enabled.
* Add: Use admin theme color and the correct WooCommerce colors.
* Fix: Resolved an issue that caused subscriptions to go on-hold when a customer fails or abandons an early renewal order payment.
* Fix: Resolved an issue that caused subscriptions with an unpaid early renewal order to be incorrectly considered as needing payment.
* Fix: When HPOS is enabled, make the orders_by_type_query filter box work in the WooCommerce orders screen.
* Fix: Ensure renewal orders paid via the Block Checkout are correctly linked to their subscription.
* Fix: Resolved an issue that caused paying for failed/pending parent orders that include Product Add-ons to not calculate the correct total.
* Fix: Ensure the order needs processing transient is deleted when a subscription order (eg renewal) is created. Fixes issues with renewal orders going straight to a completed status.
* Fix: Store the correct subscription start date in postmeta and ordermeta when HPOS and data syncing is being used.
* Fix: When HPOS is enabled, deleting a customer will now delete their subscriptions.
* Fix: Missing styles on the Edit Subscription page when HPOS is enabled.
* Fix: Resolve an issue that would cause additional subscriptions to be created when completing a switch via the Block Checkout.
* Fix: Resolve an issue that would cause 3rd party plugin edit product fields with the show_if_variable-subscription class to be incorrectly hidden.
* Fix: Allow gateways to execute action on payment method deletion before updating the subscription.
* Fix: Ensure subscriptions have a date created that correctly accounts for the site's timezone. Fixes issues with subscriptions having a date created double the site's UTC offset.
* Fix: When HPOS is enabled, fix quick-editing the subscription statuses on the admin list table.
* Dev: PHP 8.2: Fix "Creation of dynamic property" warnings.
* Dev: PHP 8.2: Fix "Automatic conversion of false to array is deprecated" warnings.
* Dev: PHP warnings from using debug_backtrace().
* Dev: Updated subscriptions-core to 6.4.0
* Dev: Updated the hooks for Checkout Blocks, replacing the deprecated `woocommerce_blocks_checkout_` prefixed hooks with `woocommerce_store_api_checkout`.

2023-09-21 - version 5.5.0
* Tweak - Use admin theme color in selectors.
* Tweak - Change plugin name to Woo Subscriptions.
Expand Down
13 changes: 9 additions & 4 deletions includes/admin/reports/class-wcs-report-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public static function get_data( $args = array() ) {

$cached_results = get_transient( strtolower( __CLASS__ ) );

// Set a default value for cached results for PHP 8.2+ compatibility.
if ( empty( $cached_results ) ) {
$cached_results = [];
}

// Subscription signups this month
$query = $wpdb->prepare(
"SELECT COUNT(DISTINCT wcsubs.ID) AS count
Expand All @@ -69,7 +74,7 @@ public static function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = $wpdb->get_var( apply_filters( 'woocommerce_subscription_dashboard_status_widget_signup_query', $query ) );
$update_cache = true;
Expand Down Expand Up @@ -128,7 +133,7 @@ public static function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = $wpdb->get_var( apply_filters( 'woocommerce_subscription_dashboard_status_widget_renewal_query', $query ) );
$update_cache = true;
Expand Down Expand Up @@ -162,7 +167,7 @@ public static function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = $wpdb->get_var( apply_filters( 'woocommerce_subscription_dashboard_status_widget_renewal_revenue_query', $query ) );
$update_cache = true;
Expand All @@ -185,7 +190,7 @@ public static function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = $wpdb->get_var( apply_filters( 'woocommerce_subscription_dashboard_status_widget_cancellation_query', $query ) );
$update_cache = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ public static function get_data( $args = array() ) {
$cached_results = get_transient( strtolower( __CLASS__ ) );
$query_hash = md5( $total_query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
// Set a default value for cached results for PHP 8.2+ compatibility.
if ( empty( $cached_results ) ) {
$cached_results = [];
}

if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
// Enable big selects for reports
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_customer_total_data', $wpdb->get_row( $total_query ) );
Expand Down Expand Up @@ -268,7 +273,7 @@ public static function get_data( $args = array() ) {

$query_hash = md5( $renewal_switch_total_query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
// Enable big selects for reports
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_customer_total_renewal_switch_data', $wpdb->get_row( $renewal_switch_total_query ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ public static function get_data( $args = array() ) {
$cached_results = get_transient( strtolower( __CLASS__ ) );
$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
// Set a default value for cached results for PHP 8.2+ compatibility.
if ( empty( $cached_results ) ) {
$cached_results = [];
}

if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_product_data', $wpdb->get_results( $query, OBJECT_K ), $args );
set_transient( strtolower( __CLASS__ ), $cached_results, WEEK_IN_SECONDS );
Expand Down Expand Up @@ -214,7 +219,7 @@ public static function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_product_lifetime_value_data', $wpdb->get_results( $query, OBJECT_K ), $args );
set_transient( strtolower( __CLASS__ ), $cached_results, WEEK_IN_SECONDS );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ public function get_data( $args = array() ) {

$cached_results = get_transient( strtolower( get_class( $this ) ) );

// Set a default value for cached results for PHP 8.2+ compatibility.
if ( empty( $cached_results ) ) {
$cached_results = [];
}

// Check if we need to update the cache with the query results from the figures generated by get_order_report_data().
foreach ( array( 'new_subscriptions' => 'new_subscriptions', 'renewals' => 'renewal', 'resubscribes' => 'resubscribe', 'switches' => 'switch' ) as $report => $property_key ) { // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
$query_hash = $this->report_data->{"{$report}_query_hash"};
Expand Down Expand Up @@ -314,7 +319,7 @@ public function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_subscription_events_sign_up_data', (array) $wpdb->get_results( $query ), $args );
$update_cache = true;
Expand Down Expand Up @@ -379,7 +384,7 @@ public function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_subscription_events_subscriber_count_data', (array) $wpdb->get_results( $query ), $args );
$update_cache = true;
Expand Down Expand Up @@ -408,7 +413,7 @@ public function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_subscription_events_cancel_count_data', (array) $wpdb->get_results( $query ), $args );
$update_cache = true;
Expand Down Expand Up @@ -438,7 +443,7 @@ public function get_data( $args = array() ) {

$query_hash = md5( $query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_subscription_events_ended_count_data', (array) $wpdb->get_results( $query ), $args );
$update_cache = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class WCS_Report_Upcoming_Recurring_Revenue extends WC_Admin_Report {

public $order_ids_recurring_totals = null;

public $average_sales = 0;

/**
* Get the legend for the main chart sidebar
* @return array
Expand Down Expand Up @@ -161,7 +163,12 @@ public function get_data( $args = array() ) {
$cached_results = get_transient( strtolower( get_class( $this ) ) );
$query_hash = md5( $base_query );

if ( $args['no_cache'] || false === $cached_results || ! isset( $cached_results[ $query_hash ] ) ) {
// Set a default value for cached results for PHP 8.2+ compatibility.
if ( empty( $cached_results ) ) {
$cached_results = [];
}

if ( $args['no_cache'] || ! isset( $cached_results[ $query_hash ] ) ) {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$cached_results[ $query_hash ] = apply_filters( 'wcs_reports_upcoming_recurring_revenue_data', $wpdb->get_results( $base_query, OBJECT_K ), $args );
set_transient( strtolower( get_class( $this ) ), $cached_results, WEEK_IN_SECONDS );
Expand Down
Loading

0 comments on commit 5eedf6a

Please sign in to comment.