Skip to content

Commit

Permalink
Fixed order processing creating duplicate orders (#364)
Browse files Browse the repository at this point in the history
 - simplified some logic with finding or creating an order object
  • Loading branch information
mak001 authored Nov 19, 2018
1 parent 6d91309 commit 9f56b5a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Controller/FoxyStripeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ public function handleDataFeed($encrypted, $decrypted)
foreach ($orders->transactions->transaction as $transaction) {
// if FoxyCart order id, then parse order
if (isset($transaction->id)) {
($order = Order::get()->filter('Order_ID', (int)$transaction->id)->First()) ?
$order = Order::get()->filter('Order_ID', (int)$transaction->id)->First() :
$order = Order::get()->filter('Order_ID', (int)$transaction->id)->First();
if (!$order) {
$order = Order::create();
}

// save base order info
$order->Order_ID = (int)$transaction->id;
$order->Response = urlencode($encrypted);
// first write needed otherwise it creates a duplicates
$order->write();
$this->parseOrder($orders, $order);
$order->write();
}
Expand Down

0 comments on commit 9f56b5a

Please sign in to comment.