diff --git a/Model/Api/CreateOrder.php b/Model/Api/CreateOrder.php index 1001e0dbd..097486c92 100644 --- a/Model/Api/CreateOrder.php +++ b/Model/Api/CreateOrder.php @@ -287,7 +287,7 @@ public function execute( $this->sendResponse(422, [ 'status' => 'failure', 'error' => [[ - 'code' => 6009, + 'code' => ($e->getMessage() && $this->isCustomOutOfStockMsg($e->getMessage())) ? self::E_BOLT_ITEM_OUT_OF_INVENTORY : 6009, 'data' => [[ 'reason' => 'Unprocessable Entity: ' . $e->getMessage(), ]] @@ -839,4 +839,13 @@ protected function getTotalAmountFromTransaction($transaction) { return $transaction->order->cart->total_amount->amount; } + + /** + * @param $msg + * @return bool + */ + protected function isCustomOutOfStockMsg($msg) + { + return strpos(strtolower($msg), 'out of stock') !== false; + } }