Answer the question
In order to leave comments, you need to log in
How to set a condition for checking the amount in the cart?
The question is. I need a condition, for example, if the basket amount is < 20000r, then false, else true.
How can this be represented in the controller?
public function actionView() {
$session=Yii::$app->session;
$session->open();
//$this -> setMeta('Корзина');
$orders = new Orders();
if ($orders->load(Yii::$app->request->post())){
$orders->qty = $session['cart.qty'];
$orders->sum = $session['cart.sum'];
if($orders->save()) {
$this->saveOrdersItem($session['cart'], $orders->id);
Yii::$app->session->setFlash('success', 'Ваш заказ принят, менеджер свяжется с вами.');
$session->remove('cart');
$session->remove('cart.qty');
$session->remove('cart.sum');
return $this->refresh();
} else Yii::$app->session->setFlash('success', 'Ошибка оформления заказа');
}
return $this->render('view', compact('session', 'orders'));
}
Answer the question
In order to leave comments, you need to log in
In my opinion, this is obvious:
or if you need to customize the logic, then
if($orders->sum < 20000){
//тут если условие выполнено
}else{
//тут если условие не выполнено
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question