Skip to content

Commit

Permalink
Merge pull request #90 from aait/master
Browse files Browse the repository at this point in the history
Prevent double status change
  • Loading branch information
markusbrunke authored Aug 11, 2020
2 parents 67ab1da + 6df0288 commit b85b62b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions includes/class-wc-reepay-order-statuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ public function reepay_settled_order_status( $status, $order ) {
*/
public static function set_authorized_status( $order, $note = null, $transaction_id = null )
{
if ( 'authorized' === get_post_meta( $order->get_id(), '_reepay_state', true ) ) {
return;
}

// Reduce stock
$order_stock_reduced = $order->get_meta( '_order_stock_reduced' );
if ( ! $order_stock_reduced ) {
Expand All @@ -361,6 +365,9 @@ public static function set_authorized_status( $order, $note = null, $transaction
$note,
$transaction_id
);


update_post_meta( $order->get_id(), '_reepay_state', 'authorized' );
}

/**
Expand All @@ -379,6 +386,10 @@ public static function set_settled_status( $order, $note = null, $transaction_id
return;
}

if ( 'settled' === get_post_meta( $order->get_id(), '_reepay_state', true ) ) {
return;
}

// Get Payment Gateway
$gateways = WC()->payment_gateways()->get_available_payment_gateways();

Expand All @@ -398,6 +409,8 @@ public static function set_settled_status( $order, $note = null, $transaction_id
if ( $note ) {
$order->add_order_note( $note );
}

update_post_meta( $order->get_id(), '_reepay_state', 'settled' );
}
}

Expand Down

0 comments on commit b85b62b

Please sign in to comment.