Skip to content
Open
Changes from all commits
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
16 changes: 15 additions & 1 deletion inc/checkout/class-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3068,6 +3068,20 @@ public function process_checkout() {
* It ensure that the cart is the same used in beginning of the process.
*/
$this->order = $payment->get_meta('wu_original_cart');

/*
* The original cart is only stored for payments created through the
* normal checkout flow (process_order). Payments created elsewhere
* (webhooks, admin, the register API) have no 'wu_original_cart' meta,
* so get_meta() returns its `false` default. Bail cleanly instead of
* fatally calling a method on a boolean.
*/
if ( ! ($this->order instanceof \WP_Ultimo\Checkout\Cart)) {
$this->errors = new \WP_Error('no-cart', __('This checkout session has expired or cannot be resumed. Please start over.', 'ultimate-multisite'));

return false;
}

$this->order->set_membership($membership);
$this->order->set_customer($customer);
$this->order->set_payment($payment);
Expand All @@ -3087,7 +3101,7 @@ public function process_checkout() {
$gateway = wu_get_gateway($payment->get_gateway());
} elseif ($this->order->should_collect_payment() === false) {
$gateway = wu_get_gateway('free');
} elseif ($gateway->get_id() === 'free') {
} elseif ($gateway && $gateway->get_id() === 'free') {
$this->errors = new \WP_Error('no-gateway', __('Payment gateway not registered.', 'ultimate-multisite'));

return false;
Expand Down
Loading