Skip to content

Commit 826c5aa

Browse files
Fix fatal error on sites using WooCommerce Subscription versions below 4.0.0 (#6489)
Co-authored-by: James Allan <[email protected]>
1 parent 169787f commit 826c5aa

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fix a fatal error on sites using WC Subscriptions versions below 4.0.0

includes/subscriptions/class-wc-payments-subscriptions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public static function get_subscription_service() {
129129
* @return bool Whether the site is a duplicate URL or not.
130130
*/
131131
public static function is_duplicate_site() {
132+
if ( class_exists( 'WC_Subscriptions' ) && version_compare( WC_Subscriptions::$version, '4.0.0', '<' ) ) {
133+
return WC_Subscriptions::is_duplicate_site();
134+
}
135+
132136
return class_exists( 'WCS_Staging' ) && WCS_Staging::is_duplicate_site();
133137
}
134138
}

tests/unit/helpers/class-wc-helper-subscriptions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ function wcs_order_contains_renewal() {
9090
*/
9191
class WC_Subscriptions {
9292
/**
93-
* Subscriptions version, defaults to 3.0.7
93+
* Subscriptions version, defaults to 4.0.0
9494
*
9595
* @var string
9696
*/
97-
public static $version = '3.0.7';
97+
public static $version = '4.0.0';
9898

9999
/**
100100
* wcs_order_contains_subscription mock.
@@ -216,4 +216,8 @@ public static function wcs_create_renewal_order( $function ) {
216216
public static function wcs_order_contains_renewal( $function ) {
217217
self::$wcs_order_contains_renewal = $function;
218218
}
219+
220+
public static function is_duplicate_site() {
221+
return false;
222+
}
219223
}

0 commit comments

Comments
 (0)