Commit 328f99f8da7c1e4806b6635fa233eb6f4db4fc74
Merge branch 'discount' of gitlab.artweb.com.ua:Alex/semena
Showing
3 changed files
with
18 additions
and
3 deletions
Show diff stats
src/app/frontend/controllers/PageController.php
@@ -1092,10 +1092,25 @@ | @@ -1092,10 +1092,25 @@ | ||
1092 | 'special_user' => $special_user | 1092 | 'special_user' => $special_user |
1093 | ]); | 1093 | ]); |
1094 | } | 1094 | } |
1095 | + | ||
1096 | + $discount = $this->models->getDiscount()->getActiveData(); | ||
1097 | + if (!empty($discount)) { | ||
1098 | + $discount = $discount[0]; | ||
1099 | + $discount['group_ids'] = str_replace('{', '', $discount['group_ids']); | ||
1100 | + $discount['group_ids'] = str_replace('}', '', $discount['group_ids']); | ||
1101 | + $discount['group_ids'] = explode(',', $discount['group_ids']); | ||
1102 | + if ($discount['discount'] > 0 && $discount['discount'] <= 100 && in_array($item_id, $discount['group_ids'])) { | ||
1103 | + $discount = $discount['discount']; | ||
1104 | + } | ||
1105 | + else { | ||
1106 | + $discount = 0; | ||
1107 | + } | ||
1108 | + } | ||
1095 | 1109 | ||
1096 | $this->view->pick('page/changeWithSize'); | 1110 | $this->view->pick('page/changeWithSize'); |
1097 | $this->view->setVars([ | 1111 | $this->view->setVars([ |
1098 | - 'item' => $item['0'] | 1112 | + 'item' => $item['0'], |
1113 | + 'discount' => $discount | ||
1099 | ]); | 1114 | ]); |
1100 | $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); | 1115 | $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
1101 | } | 1116 | } |
src/app/frontend/views/page/changeWithSize.php
@@ -8,7 +8,7 @@ if(isset($special_user)) { | @@ -8,7 +8,7 @@ if(isset($special_user)) { | ||
8 | } | 8 | } |
9 | $data['html'] = '<div class="clearfix buy_compare"> | 9 | $data['html'] = '<div class="clearfix buy_compare"> |
10 | <div class="one_item_price float">'. $t->_("price") . | 10 | <div class="one_item_price float">'. $t->_("price") . |
11 | - ' <span>' . $data['price'] . '</span> грн'; | 11 | + ' <span>' . number_format($data['price']*(1-$discount['discount']/100), 2, '.', ' ') . '</span> грн'; |
12 | 12 | ||
13 | $data['html'] .= '</ul></div><div data-group_id="' . $item['group_id'] .'" class="one_item_buttons float">'; | 13 | $data['html'] .= '</ul></div><div data-group_id="' . $item['group_id'] .'" class="one_item_buttons float">'; |
14 | 14 |
src/app/frontend/views/page/item.php
@@ -453,6 +453,7 @@ | @@ -453,6 +453,7 @@ | ||
453 | $customer_id = $this->session->get('id'); | 453 | $customer_id = $this->session->get('id'); |
454 | ?> | 454 | ?> |
455 | $( document ).ready(function() { | 455 | $( document ).ready(function() { |
456 | + | ||
456 | $('body').on('click','.one_item_buttons a', function(){ | 457 | $('body').on('click','.one_item_buttons a', function(){ |
457 | 458 | ||
458 | <?php if( !empty( $customer_id ) ) : ?> | 459 | <?php if( !empty( $customer_id ) ) : ?> |
@@ -490,7 +491,6 @@ | @@ -490,7 +491,6 @@ | ||
490 | 491 | ||
491 | }); | 492 | }); |
492 | 493 | ||
493 | - | ||
494 | }); | 494 | }); |
495 | 495 | ||
496 | 496 |