Skip to content

Commit

Permalink
Merge pull request #162 from buckaroo-it/BP-3509-Status-changed-from-…
Browse files Browse the repository at this point in the history
…in-backorder-not-payed-to-payed

BP-3509-Status-changed-from-in-backorder-not-payed-to-payed
  • Loading branch information
vegimcarkaxhija authored May 16, 2024
2 parents 5885020 + 7601ef4 commit d133577
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions buckaroo3.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,23 @@ public static function resolveStatusCode($status_code, $id_order = null)

private static function isOrderBackOrder($orderId)
{
if (!Configuration::get('PS_STOCK_MANAGEMENT')) {
return false; // If stock management is disabled, no order is a backorder
}

$order = new Order($orderId);
$orderDetails = $order->getOrderDetailList();
/** @var OrderDetail $detail */

foreach ($orderDetails as $detail) {
$orderDetail = new OrderDetail($detail['id_order_detail']);
if (
Configuration::get('PS_STOCK_MANAGEMENT') &&
($orderDetail->getStockState() || $orderDetail->product_quantity_in_stock < 0)
) {

// If any product is in stock, the order is not a backorder
if ($orderDetail->product_quantity_in_stock < 0) {
return true;
}
}

// If all products are out of stock, the order is a backorder
return false;
}

Expand Down

0 comments on commit d133577

Please sign in to comment.