Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions inc/managers/class-payment-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ public function check_pending_payments($user): void {
}

foreach ($customer->get_memberships() as $membership) {
/*
* Skip memberships that never completed checkout. A pending
* membership represents an abandoned checkout — showing a popup
* for it is misleading and may point to a WC order that no
* longer exists.
*/
if (in_array($membership->get_status(), ['pending', 'cancelled'], true)) {
continue;
}

$pending_payment = $membership->get_last_pending_payment();

if ($pending_payment) {
Expand Down Expand Up @@ -236,6 +246,10 @@ public function render_pending_payments(): void {
$pending_payments = [];

foreach ($customer->get_memberships() as $membership) {
if (in_array($membership->get_status(), ['pending', 'cancelled'], true)) {
continue;
}

$pending_payment = $membership->get_last_pending_payment();

if ($pending_payment) {
Expand Down
13 changes: 13 additions & 0 deletions inc/models/class-customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,23 @@ public function has_trialed() {
$this->has_trialed = $this->get_meta(self::META_HAS_TRIALED);

if ( ! $this->has_trialed) {
/*
* Exclude pending memberships from this check.
*
* WP Ultimo sets date_trial_end at form submit, before payment is
* collected. Without this filter an abandoned checkout permanently
* blocks future trials because has_trialed() finds the pending
* membership and returns true immediately.
*
* We intentionally keep 'cancelled' in scope: a user who started a
* trial, then cancelled their active membership, genuinely consumed
* their trial and should not receive a second one.
*/
$trial = wu_get_memberships(
[
'customer_id' => $this->get_id(),
'date_trial_end__not_in' => [null, '0000-00-00 00:00:00'],
'status__not_in' => ['pending'],
'fields' => 'ids',
'number' => 1,
]
Expand Down
Loading