Skip to content

Commit c3f1950

Browse files
committed
Fix - Update subscription reactivation status based on payment completion
1 parent 59d7b8f commit c3f1950

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

modules/membership/includes/AJAX.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,10 +1374,16 @@ public static function reactivate_membership() {
13741374
if ( ! empty( $order_associated_with_subscription_id['order_type'] ) && $order_associated_with_subscription_id['order_type'] === $membership_details['type'] ) {
13751375
if ( isset( $membership_details['type'] ) && 'subscription' !== $membership_details['type'] ) {
13761376
$subscription_repository = new SubscriptionRepository();
1377+
1378+
// Only restore to 'active' if the order's payment has actually been approved/completed
1379+
// (e.g. Bank Transfer orders stay 'pending' until an admin approves them); otherwise
1380+
// restore to 'pending' instead of bypassing the manual payment verification flow.
1381+
$reactivated_status = ( 'completed' === ( $order_associated_with_subscription_id['status'] ?? '' ) ) ? 'active' : 'pending';
1382+
13771383
$subscription_repository->update(
13781384
$subscription_id,
13791385
array(
1380-
'status' => 'active',
1386+
'status' => $reactivated_status,
13811387
)
13821388
);
13831389

modules/membership/includes/Admin/Repositories/SubscriptionRepository.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,16 @@ public function reactivate_subscription_by_id( $subscription_id, $send_email = t
140140

141141
$subscription_service = new SubscriptionService();
142142
$subscription_service->reactivate_subscription( $order, $subscription );
143+
144+
// Only restore to 'active' if the order's payment has actually been approved/completed
145+
// (e.g. Bank Transfer orders stay 'pending' until an admin approves them); otherwise
146+
// restore to 'pending' instead of bypassing the manual payment verification flow.
147+
$reactivated_status = ( 'completed' === ( $order['status'] ?? '' ) ) ? 'active' : 'pending';
148+
143149
$result = $this->update(
144150
$subscription_id,
145151
array(
146-
'status' => 'active',
152+
'status' => $reactivated_status,
147153
)
148154
);
149155
if ( ! $result ) {

0 commit comments

Comments
 (0)