Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/12661
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Apr 8, 2024
1 parent d71d291 commit 8a028f5
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 38 deletions.
2 changes: 1 addition & 1 deletion upload/admin/view/template/customer/customer.twig
Expand Up @@ -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;
Expand Down
24 changes: 14 additions & 10 deletions upload/admin/view/template/sale/order_info.twig
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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');
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions upload/catalog/controller/api/localisation/store.php
Expand Up @@ -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');
}

Expand Down
37 changes: 31 additions & 6 deletions upload/catalog/controller/api/sale/affiliate.php
Expand Up @@ -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));
}
}
3 changes: 0 additions & 3 deletions upload/catalog/controller/api/sale/cart.php
Expand Up @@ -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');
}

Expand Down
5 changes: 5 additions & 0 deletions upload/catalog/controller/api/sale/coupon.php
Expand Up @@ -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');

Expand Down
6 changes: 3 additions & 3 deletions upload/catalog/controller/api/sale/payment_address.php
Expand Up @@ -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);
}
}

Expand Down
27 changes: 19 additions & 8 deletions upload/catalog/controller/api/sale/reward.php
Expand Up @@ -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
*
Expand Down
6 changes: 3 additions & 3 deletions upload/catalog/controller/api/sale/shipping_address.php
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/view/stylesheet/stylesheet.css
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/view/stylesheet/stylesheet.scss
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8a028f5

Please sign in to comment.