'order', | 'order', | ||||
function ($product) use ($document, $userProducer, $pointSale, $productModule) { | function ($product) use ($document, $userProducer, $pointSale, $productModule) { | ||||
return array_merge($product->getAttributes(), [ | return array_merge($product->getAttributes(), [ | ||||
'unit_coefficient' => $productModule->getSolver()->getUnitCoefficient($product->unit), | |||||
'unit_coefficient' => $productModule->getSolver()->getUnitCoefficient($product), | |||||
'prices' => $productModule->getPriceArray($product, $userProducer->user, $pointSale), | 'prices' => $productModule->getPriceArray($product, $userProducer->user, $pointSale), | ||||
'wording_unit' => $product->wording_unit, | 'wording_unit' => $product->wording_unit, | ||||
'tax_rate' => $product->taxRate->value | 'tax_rate' => $product->taxRate->value |
$newProductSubscription = new ProductSubscription; | $newProductSubscription = new ProductSubscription; | ||||
$newProductSubscription->id_subscription = $subscription->id; | $newProductSubscription->id_subscription = $subscription->id; | ||||
$newProductSubscription->id_product = $idProduct; | $newProductSubscription->id_product = $idProduct; | ||||
$newProductSubscription->quantity = $quantity / $productModule->getSolver()->getUnitCoefficient($product->unit); | |||||
$newProductSubscription->quantity = $quantity / $productModule->getSolver()->getUnitCoefficient($product); | |||||
$newProductSubscription->save(); | $newProductSubscription->save(); | ||||
} | } |
$indexProduct = 0; | $indexProduct = 0; | ||||
foreach ($productsArray as &$product) { | foreach ($productsArray as &$product) { | ||||
$quantity = 0; | $quantity = 0; | ||||
$coefficientUnit = $productModule->getSolver()->getUnitCoefficient($product->unit); | |||||
$coefficientUnit = $productModule->getSolver()->getUnitCoefficient($product); | |||||
if (isset($arrayProductsSubscription) && count($arrayProductsSubscription)) { | if (isset($arrayProductsSubscription) && count($arrayProductsSubscription)) { | ||||
foreach ($arrayProductsSubscription as $productSubscription) { | foreach ($arrayProductsSubscription as $productSubscription) { | ||||
if ($product->id == $productSubscription->id_product) { | if ($product->id == $productSubscription->id_product) { | ||||
$coefficientUnit = $productModule->getSolver()->getUnitCoefficient($productSubscription->product->unit); | |||||
$coefficientUnit = $productModule->getSolver()->getUnitCoefficient($productSubscription->product); | |||||
$quantity = $productSubscription->quantity * $coefficientUnit; | $quantity = $productSubscription->quantity * $coefficientUnit; | ||||
} | } | ||||
} | } |