From b2687e779b950e8de08cc0739ba3faab044fc556 Mon Sep 17 00:00:00 2001 From: Matt Allan Date: Mon, 14 Oct 2024 14:32:40 +1000 Subject: [PATCH] Prevents fatal error from occurring when calling the `get_total_tax_refunded()` data store function. (#698) * Fix fatal error when calculationg total tax refunded on a subscription * add changelog entry --- changelog.txt | 1 + .../class-wcs-orders-table-subscription-data-store.php | 2 +- includes/data-stores/class-wcs-subscription-data-store-cpt.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 395f9cbd2..c0e4bf57e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ * Fix - Correctly updates a subscription status to `cancelled` during a payment failure call when the current status is `pending-cancel`. * Fix - Clear the `cancelled_email_sent` meta when a subscription is reactivated to allow the customer to receive future cancellation emails. * Fix - Prevent deprecation notices after updating to WooCommerce 9.3. +* Fix - Prevent PHP fatal error that occurs when calculating the total tax refunded on a subscription. * Dev - Only initialise the `WCS_WC_Admin_Manager` class on stores running WC 9.2 or older. This class handled integration with the Woo Navigation feature that was removed in WC 9.3. = 7.5.0 - 2024-09-12 = diff --git a/includes/data-stores/class-wcs-orders-table-subscription-data-store.php b/includes/data-stores/class-wcs-orders-table-subscription-data-store.php index c715af9a5..f0edd6914 100644 --- a/includes/data-stores/class-wcs-orders-table-subscription-data-store.php +++ b/includes/data-stores/class-wcs-orders-table-subscription-data-store.php @@ -247,7 +247,7 @@ public function get_total_refunded( $subscription ) { public function get_total_tax_refunded( $subscription ) { $total = 0; - foreach ( $subscription->get_related_orders() as $order ) { + foreach ( $subscription->get_related_orders( 'all' ) as $order ) { $total += parent::get_total_tax_refunded( $order ); } diff --git a/includes/data-stores/class-wcs-subscription-data-store-cpt.php b/includes/data-stores/class-wcs-subscription-data-store-cpt.php index b28e7a86b..cf87304e2 100644 --- a/includes/data-stores/class-wcs-subscription-data-store-cpt.php +++ b/includes/data-stores/class-wcs-subscription-data-store-cpt.php @@ -305,7 +305,7 @@ public function get_total_tax_refunded( $subscription ) { $total = 0; - foreach ( $subscription->get_related_orders() as $order ) { + foreach ( $subscription->get_related_orders( 'all' ) as $order ) { $total += parent::get_total_tax_refunded( $order ); }