diff --git a/upload/admin/view/template/customer/customer.twig b/upload/admin/view/template/customer/customer.twig index d21021c68b8..64bdcdf6d4a 100644 --- a/upload/admin/view/template/customer/customer.twig +++ b/upload/admin/view/template/customer/customer.twig @@ -170,7 +170,7 @@ $('#input-email').autocomplete({ } }); -$('#customer').on('click', 'a[data-oc-toggle=\'unlock\']', function(e) { +$('#customer').on('click', '[data-oc-toggle=\'unlock\']', function(e) { e.preventDefault(); var element = this; diff --git a/upload/admin/view/template/sale/order_info.twig b/upload/admin/view/template/sale/order_info.twig index 08755b4ad4b..fe4bed2ae43 100644 --- a/upload/admin/view/template/sale/order_info.twig +++ b/upload/admin/view/template/sale/order_info.twig @@ -1334,7 +1334,7 @@ $('#form-customer').on('submit', function(e) { e.preventDefault(); $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/customer&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/customer', type: 'post', data: $('#form-customer').serialize(), dataType: 'json', @@ -1600,7 +1600,7 @@ $('#form-product-add').on('submit', function(e) { e.preventDefault(); $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/cart.add&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/cart.add', type: 'post', data: $('#form-product-add').serialize(), dataType: 'json', @@ -1612,6 +1612,8 @@ $('#form-product-add').on('submit', function(e) { $('#button-product-add').button('reset'); }, success: function(json) { + console.log(json); + $('.alert-dismissible').remove(); $('.is-invalid').removeClass('is-invalid'); $('.invalid-feedback').removeClass('d-block'); @@ -1661,6 +1663,8 @@ $('#order-products').on('submit', 'form', function(e) { $(e.target).button('reset'); }, success: function(json) { + console.log(json); + $('.alert-dismissible').remove(); // Check for errors @@ -2372,7 +2376,7 @@ $('#form-shipping-address').on('submit', function(e) { e.preventDefault(); $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/shipping_address&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/shipping_address', type: 'post', data: $('#form-shipping-address').serialize(), dataType: 'json', @@ -2491,7 +2495,7 @@ $('#button-shipping-methods').on('click', function() { var element = this; $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/shipping_method&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/shipping_method', dataType: 'json', beforeSend: function() { $(element).button('loading'); @@ -2550,7 +2554,7 @@ $('#form-shipping-method').on('submit', function(e) { var element = this; $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/shipping_method.save&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/shipping_method.save', type: 'post', data: $('#form-shipping-method').serialize(), dataType: 'json', @@ -2590,7 +2594,7 @@ $('#button-payment-methods').on('click', function() { var element = this; $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/payment_method&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/payment_method', dataType: 'json', beforeSend: function() { $(element).button('loading'); @@ -2649,7 +2653,7 @@ $('#form-payment-method').on('submit', function(e) { var element = this; $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/payment_method.save&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/payment_method.save', type: 'post', data: $('#form-payment-method').serialize(), dataType: 'json', @@ -2688,7 +2692,7 @@ $('#form-comment').on('submit', function(e) { var element = this; $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/order.comment&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/order.comment', type: 'post', data: $('#form-comment').serialize(), dataType: 'json', @@ -2722,7 +2726,7 @@ $('#form-comment').on('submit', function(e) { // Refresh all products, vouchers and totals $('#button-refresh').on('click', function() { $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/cart&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/cart', dataType: 'json', beforeSend: function() { $('#button-refresh').button('loading'); @@ -2847,7 +2851,7 @@ $('#button-confirm').on('click', function() { var element = this; $.ajax({ - url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/order.confirm&store_id=' + $('#input-store').val() + '&language=' + $('#input-language').val(), + url: 'index.php?route=sale/order.call&user_token={{ user_token }}&action=sale/order.confirm', dataType: 'json', beforeSend: function() { $(element).button('loading'); diff --git a/upload/catalog/controller/api/localisation/store.php b/upload/catalog/controller/api/localisation/store.php index ec0945ccaf0..0e92575387c 100644 --- a/upload/catalog/controller/api/localisation/store.php +++ b/upload/catalog/controller/api/localisation/store.php @@ -22,9 +22,9 @@ public function index(): void { $this->load->model('setting/store'); - $language_info = $this->model_localisation_store->getStoreByCode($store); + $store_info = $this->model_setting_store->getStoreByCode($store); - if (!$language_info) { + if (!$store_info) { $json['error'] = $this->language->get('error_store'); } diff --git a/upload/catalog/controller/api/sale/affiliate.php b/upload/catalog/controller/api/sale/affiliate.php index 22289248529..6d6af25c7a1 100644 --- a/upload/catalog/controller/api/sale/affiliate.php +++ b/upload/catalog/controller/api/sale/affiliate.php @@ -31,18 +31,43 @@ public function index(): void { } if (!$json) { - if ($affiliate_id) { - $json['success'] = $this->language->get('text_success'); + $json['success'] = $this->language->get('text_success'); - $this->session->data['affiliate_id'] = $affiliate_id; - } else { - $json['success'] = $this->language->get('text_remove'); + $this->session->data['affiliate_id'] = $affiliate_id; - unset($this->session->data['affiliate_id']); + // If order already created then update + if (isset($this->session->data['order_id'])) { + $subtotal = $this->cart->getSubTotal(); + + $order_data = [ + 'affiliate_id' => $affiliate_info['customer_id'], + 'commission' => ($subtotal / 100) * $affiliate_info['commission'], + 'tracking' => $affiliate_info['tracking'] + ]; + + $this->load->model('checkout/order'); + + $this->model_checkout_order->editOrder($this->session->data['order_id'], $order_data); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } + + /** + * Remove + * + * @return void + */ + public function remove(): void { + $this->load->language('api/sale/affiliate'); + + $json['success'] = $this->language->get('text_remove'); + + unset($this->session->data['affiliate_id']); + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } } diff --git a/upload/catalog/controller/api/sale/cart.php b/upload/catalog/controller/api/sale/cart.php index 4562efc7634..4355fdf349d 100644 --- a/upload/catalog/controller/api/sale/cart.php +++ b/upload/catalog/controller/api/sale/cart.php @@ -178,9 +178,6 @@ public function add(): void { if (!$json) { $this->cart->add($product_id, $quantity, $option, $subscription_plan_id); - //print_r($this->cart->getProducts()); - - $json['success'] = $this->language->get('text_success'); } diff --git a/upload/catalog/controller/api/sale/coupon.php b/upload/catalog/controller/api/sale/coupon.php index b9bd02b9197..4ae6df7c7de 100644 --- a/upload/catalog/controller/api/sale/coupon.php +++ b/upload/catalog/controller/api/sale/coupon.php @@ -40,6 +40,11 @@ public function index(): void { $this->response->setOutput(json_encode($json)); } + /** + * Remove + * + * @return void + */ public function remove(): void { $this->load->language('api/sale/coupon'); diff --git a/upload/catalog/controller/api/sale/payment_address.php b/upload/catalog/controller/api/sale/payment_address.php index 56917b27ba6..c6aa27c97fe 100644 --- a/upload/catalog/controller/api/sale/payment_address.php +++ b/upload/catalog/controller/api/sale/payment_address.php @@ -129,15 +129,15 @@ public function index(): void { // If order already created then update if (isset($this->session->data['order_id'])) { - $address_data = []; + $order_data = []; foreach ($this->session->data['payment_address'] as $key => $value) { - $address_data['payment_' . $key] = $value; + $order_data['payment_' . $key] = $value; } $this->load->model('checkout/order'); - $this->model_checkout_order->editOrder($this->session->data['order_id'], $address_data); + $this->model_checkout_order->editOrder($this->session->data['order_id'], $order_data); } } diff --git a/upload/catalog/controller/api/sale/reward.php b/upload/catalog/controller/api/sale/reward.php index 0b51ea7b53b..43a548c76ed 100644 --- a/upload/catalog/controller/api/sale/reward.php +++ b/upload/catalog/controller/api/sale/reward.php @@ -41,21 +41,32 @@ public function index(): void { } if (!$json) { - if ($reward) { - $json['success'] = $this->language->get('text_success'); + $json['success'] = $this->language->get('text_success'); - $this->session->data['reward'] = $reward; - } else { - $json['success'] = $this->language->get('text_remove'); - - unset($this->session->data['reward']); - } + $this->session->data['reward'] = $reward; } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } + /** + * Remove + * + * @return void + */ + function remove() { + $this->load->language('api/sale/reward'); + + $json['success'] = $this->language->get('text_remove'); + + unset($this->session->data['reward']); + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } + + /** * Maximum * diff --git a/upload/catalog/controller/api/sale/shipping_address.php b/upload/catalog/controller/api/sale/shipping_address.php index 0c8802d0cf0..748211a4c5a 100644 --- a/upload/catalog/controller/api/sale/shipping_address.php +++ b/upload/catalog/controller/api/sale/shipping_address.php @@ -133,15 +133,15 @@ public function index(): void { // If order already created then update if (isset($this->session->data['order_id'])) { - $address_data = []; + $order_data = []; foreach ($this->session->data['shipping_address'] as $key => $value) { - $address_data['shipping_' . $key] = $value; + $order_data['shipping_' . $key] = $value; } $this->load->model('checkout/order'); - $this->model_checkout_order->editOrder($this->session->data['order_id'], $address_data); + $this->model_checkout_order->editOrder($this->session->data['order_id'], $order_data); } } diff --git a/upload/catalog/view/stylesheet/stylesheet.css b/upload/catalog/view/stylesheet/stylesheet.css index 766cb2713f8..60c90303f1e 100644 --- a/upload/catalog/view/stylesheet/stylesheet.css +++ b/upload/catalog/view/stylesheet/stylesheet.css @@ -71,7 +71,7 @@ div.required .col-form-label:before, div.required .form-label:before { } } #alert { - padding-top: 15px; + padding-top: 30px; z-index: 9999; pointer-events: all; } diff --git a/upload/catalog/view/stylesheet/stylesheet.scss b/upload/catalog/view/stylesheet/stylesheet.scss index b0c2af5de52..a1a4f01e7e8 100644 --- a/upload/catalog/view/stylesheet/stylesheet.scss +++ b/upload/catalog/view/stylesheet/stylesheet.scss @@ -89,7 +89,7 @@ div.required .col-form-label:before, div.required .form-label:before { } #alert { - padding-top: 15px; + padding-top: 30px; z-index: 9999; pointer-events: all; }