| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function registerCartClearJs(): void |
||
| 34 | { |
||
| 35 | $errorMessage = Yii::t('cart', 'Sorry, but now it is impossible to remove this position from cart now.'); |
||
| 36 | |||
| 37 | $this->getView()->registerJs(<<<JS |
||
| 38 | $('.cart-remove, .cart-clear, .cart-remove > .fa').on('click', function(event) { |
||
| 39 | var url = event.target.dataset.action || $(this).parent().data('action'); |
||
| 40 | $.ajax({ |
||
| 41 | url: url, |
||
| 42 | type: 'POST', |
||
| 43 | cache: false, |
||
| 44 | error: function() { |
||
| 45 | hipanel.notify.error('$errorMessage'); |
||
| 46 | } |
||
| 47 | }); |
||
| 48 | hipanel.updateCart(function() { |
||
| 49 | $('.dropdown.notifications-cart a.dropdown-toggle').attr('aria-expanded', true); |
||
| 50 | $("li.dropdown.notifications-menu.notifications-cart").addClass('open'); |
||
| 51 | }); |
||
| 52 | }); |
||
| 53 | JS |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |