Skip to content

Commit

Permalink
[backend] order change quantity fix (Close #244)
Browse files Browse the repository at this point in the history
  • Loading branch information
fps01 committed Aug 19, 2015
1 parent 2a5e88c commit 868e286
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion application/modules/shop/controllers/BackendOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,20 @@ public function actionChangeOrderItemQuantity($id)
Yii::$app->response->format = Response::FORMAT_JSON;
/** @var OrderItem $orderItem */
$orderItem = OrderItem::findOne($id);
if (!$orderItem->load(Yii::$app->request->post()) || !$orderItem->save(true, ['quantity'])
$orderItem->load(Yii::$app->request->post());
$orderItem->quantity = $orderItem->product->measure->ceilQuantity($orderItem->quantity);
$orderItem->price_per_pcs = PriceHelper::getProductPrice(
$orderItem->product,
$orderItem->order,
1,
SpecialPriceList::TYPE_CORE
);
if (!$orderItem->save(true, ['quantity', 'total_price', 'discount_amount', 'total_price_without_discount'])
|| !$orderItem->order->calculate(true)
) {
return [
'message' => Yii::t('app', 'Cannot change quantity'),
'error' => $orderItem->errors,
];
}
return [
Expand Down

0 comments on commit 868e286

Please sign in to comment.