|
|
@@ -826,26 +826,28 @@ class OrderController extends BackendController |
|
|
|
|
|
|
|
foreach ($products as $key => $dataProductOrder) { |
|
|
|
$product = $productManager->findOneProductById($key); |
|
|
|
$quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient']; |
|
|
|
if ($product && $quantity) { |
|
|
|
$productOrder = new ProductOrder; |
|
|
|
$productOrder->id_order = $order->id; |
|
|
|
$productOrder->id_product = $key; |
|
|
|
$productOrder->quantity = $quantity; |
|
|
|
$productOrder->unit = $product->unit; |
|
|
|
$productOrder->step = $product->step; |
|
|
|
if ($dataProductOrder->price) { |
|
|
|
$productOrder->price = $dataProductOrder->price; |
|
|
|
} else { |
|
|
|
$productOrder->price = $productManager->getPrice($product, [ |
|
|
|
'user' => $user, |
|
|
|
'user_producer' => $userProducer, |
|
|
|
'point_sale' => $order->pointSale, |
|
|
|
'quantity' => $productOrder->quantity |
|
|
|
]); |
|
|
|
if(isset(Product::$unitsArray[$dataProductOrder->unit]) && Product::$unitsArray[$dataProductOrder->unit]['coefficient']) { |
|
|
|
$quantity = $dataProductOrder->quantity / Product::$unitsArray[$dataProductOrder->unit]['coefficient']; |
|
|
|
if ($product && $quantity) { |
|
|
|
$productOrder = new ProductOrder; |
|
|
|
$productOrder->id_order = $order->id; |
|
|
|
$productOrder->id_product = $key; |
|
|
|
$productOrder->quantity = $quantity; |
|
|
|
$productOrder->unit = $product->unit; |
|
|
|
$productOrder->step = $product->step; |
|
|
|
if ($dataProductOrder->price) { |
|
|
|
$productOrder->price = $dataProductOrder->price; |
|
|
|
} else { |
|
|
|
$productOrder->price = $productManager->getPrice($product, [ |
|
|
|
'user' => $user, |
|
|
|
'user_producer' => $userProducer, |
|
|
|
'point_sale' => $order->pointSale, |
|
|
|
'quantity' => $productOrder->quantity |
|
|
|
]); |
|
|
|
} |
|
|
|
$productOrder->id_tax_rate = $product->taxRate->id; |
|
|
|
$productOrder->save(); |
|
|
|
} |
|
|
|
$productOrder->id_tax_rate = $product->taxRate->id; |
|
|
|
$productOrder->save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|