Commit 882a91f6b411f70e51562454f5169b8375b7f48f
1 parent
a29e68cc
price display basket
Showing
1 changed file
with
21 additions
and
11 deletions
Show diff stats
src/app/frontend/controllers/MenuController.php
@@ -393,33 +393,43 @@ class MenuController extends \controllers\ControllerBase | @@ -393,33 +393,43 @@ class MenuController extends \controllers\ControllerBase | ||
393 | } | 393 | } |
394 | 394 | ||
395 | public function getCartItemsAction() { | 395 | public function getCartItemsAction() { |
396 | + | ||
396 | $this->view->disable(); | 397 | $this->view->disable(); |
397 | 398 | ||
398 | $in_cart = $this->session->get('in_cart', []); | 399 | $in_cart = $this->session->get('in_cart', []); |
399 | 400 | ||
400 | - | ||
401 | - | ||
402 | $cart_items = $this->common->getCartItems($in_cart, $this->lang_id); | 401 | $cart_items = $this->common->getCartItems($in_cart, $this->lang_id); |
403 | 402 | ||
404 | - | ||
405 | - | ||
406 | if($this->session->get('special_users_id') != null) { | 403 | if($this->session->get('special_users_id') != null) { |
407 | $special_users_id = $this->session->get('special_users_id'); | 404 | $special_users_id = $this->session->get('special_users_id'); |
408 | $special_user = $this->models->getSpecialUsers()->getOneData($special_users_id)[0]; | 405 | $special_user = $this->models->getSpecialUsers()->getOneData($special_users_id)[0]; |
409 | } | 406 | } |
410 | 407 | ||
408 | + // скидка | ||
409 | +// $discount = $this->models->getDiscount()->getActiveData(); | ||
410 | +// if (!empty($discount)) { | ||
411 | +// $discount = $discount[0]; | ||
412 | +// $discount['group_ids'] = str_replace('{', '', $discount['group_ids']); | ||
413 | +// $discount['group_ids'] = str_replace('}', '', $discount['group_ids']); | ||
414 | +// $discount['group_ids'] = explode(',', $discount['group_ids']); | ||
415 | +// } | ||
416 | +// else { | ||
417 | +// $discount['discount'] = 0; | ||
418 | +// } | ||
419 | +// | ||
420 | +// $cart_items['total_price'] = round($cart_items['total_price']*(1-$discount['discount']/100), 1); | ||
421 | + | ||
422 | + | ||
423 | + //discount | ||
411 | $discount = $this->models->getDiscount()->getActiveData(); | 424 | $discount = $this->models->getDiscount()->getActiveData(); |
412 | if (!empty($discount)) { | 425 | if (!empty($discount)) { |
413 | $discount = $discount[0]; | 426 | $discount = $discount[0]; |
414 | - $discount['group_ids'] = str_replace('{', '', $discount['group_ids']); | ||
415 | - $discount['group_ids'] = str_replace('}', '', $discount['group_ids']); | ||
416 | - $discount['group_ids'] = explode(',', $discount['group_ids']); | ||
417 | } | 427 | } |
418 | - else { | ||
419 | - $discount['discount'] = 0; | 428 | + if ($this->common->applyPromoCode($discount, $cart_items['items'])) { |
429 | + $this->common->countOrderSum($cart_items); | ||
430 | + $cart_items['total_price'] = $cart_items['total_sum']; | ||
420 | } | 431 | } |
421 | - | ||
422 | - $cart_items['total_price'] = round($cart_items['total_price']*(1-$discount['discount']/100), 1); | 432 | + // |
423 | 433 | ||
424 | foreach($cart_items['items'] as $k => $item) { | 434 | foreach($cart_items['items'] as $k => $item) { |
425 | 435 |