|
|
|
|
|
|
|
|
|
|
|
|
|
|
$unit = (!is_null($order) && isset($unitsArray[$product->id])) ? $unitsArray[$product->id] : $product->unit ; |
|
|
$unit = (!is_null($order) && isset($unitsArray[$product->id])) ? $unitsArray[$product->id] : $product->unit ; |
|
|
$coefficient = Product::$unitsArray[$unit]['coefficient'] ; |
|
|
$coefficient = Product::$unitsArray[$unit]['coefficient'] ; |
|
|
$quantity = ((int) $posts['products'][$product->id]) / $coefficient ; |
|
|
|
|
|
|
|
|
$quantity = ((float) $posts['products'][$product->id]) / $coefficient ; |
|
|
if ($availableProducts[$product->id]['quantity_max'] && $quantity > $availableProducts[$product->id]['quantity_remaining']) { |
|
|
if ($availableProducts[$product->id]['quantity_max'] && $quantity > $availableProducts[$product->id]['quantity_remaining']) { |
|
|
$quantity = $availableProducts[$product->id]['quantity_remaining']; |
|
|
|
|
|
|
|
|
$quantity = $availableProducts[$product->id]['quantity_remaining'] ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$productOrder->quantity = $quantity; |
|
|
$productOrder->quantity = $quantity; |