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 Aug 9, 2024
1 parent 7feecfb commit c10a094
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 98 deletions.
118 changes: 59 additions & 59 deletions upload/admin/controller/sale/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,65 +825,6 @@ public function info(): void {

$data['currencies'] = $this->model_localisation_currency->getCurrencies();

// Coupon, Voucher, Reward
$data['total_coupon'] = '';
$data['total_voucher'] = '';
$data['total_reward'] = 0;

if ($order_id) {
$order_totals = $this->model_sale_order->getTotals($order_id);

foreach ($order_totals as $order_total) {
// If coupon, voucher or reward points
$start = strpos($order_total['title'], '(');
$end = strrpos($order_total['title'], ')');

if ($start !== false && $end !== false) {
$data['total_' . $order_total['code']] = substr($order_total['title'], $start + 1, $end - ($start + 1));
}
}
}

// Reward Points
if (!empty($order_info)) {
$data['points'] = $this->model_sale_order->getRewardTotal($order_id);
} else {
$data['points'] = 0;
}

// Reward Points
if (!empty($order_info)) {
$data['reward_total'] = $this->model_customer_customer->getTotalRewardsByOrderId($order_id);
} else {
$data['reward_total'] = 0;
}

// Affiliate
if (!empty($order_info)) {
$data['affiliate_id'] = $order_info['affiliate_id'];
} else {
$data['affiliate_id'] = 0;
}

if (!empty($order_info)) {
$data['affiliate'] = $order_info['affiliate'];
} else {
$data['affiliate'] = '';
}

// Commission
if (!empty($order_info) && (float)$order_info['commission']) {
$data['commission'] = $this->currency->format($order_info['commission'], $this->config->get('config_currency'));
} else {
$data['commission'] = '';
}

if (!empty($order_info)) {
$data['commission_total'] = $this->model_customer_customer->getTotalTransactionsByOrderId($order_id);
} else {
$data['commission_total'] = '';
}

// Addresses
if (!empty($order_info)) {
$this->load->model('customer/customer');
Expand Down Expand Up @@ -1082,6 +1023,65 @@ public function info(): void {
$data['shipping_code'] = '';
}

// Coupon, Voucher, Reward
$data['total_coupon'] = '';
$data['total_voucher'] = '';
$data['total_reward'] = 0;

if ($order_id) {
$order_totals = $this->model_sale_order->getTotals($order_id);

foreach ($order_totals as $order_total) {
// If coupon, voucher or reward points
$start = strpos($order_total['title'], '(');
$end = strrpos($order_total['title'], ')');

if ($start !== false && $end !== false) {
$data['total_' . $order_total['code']] = substr($order_total['title'], $start + 1, $end - ($start + 1));
}
}
}

// Reward Points
if (!empty($order_info)) {
$data['points'] = $this->model_sale_order->getRewardTotal($order_id);
} else {
$data['points'] = 0;
}

// Reward Points
if (!empty($order_info)) {
$data['reward_total'] = $this->model_customer_customer->getTotalRewardsByOrderId($order_id);
} else {
$data['reward_total'] = 0;
}

// Affiliate
if (!empty($order_info)) {
$data['affiliate_id'] = $order_info['affiliate_id'];
} else {
$data['affiliate_id'] = 0;
}

if (!empty($order_info)) {
$data['affiliate'] = $order_info['affiliate'];
} else {
$data['affiliate'] = '';
}

// Commission
if (!empty($order_info) && (float)$order_info['commission']) {
$data['commission'] = $this->currency->format($order_info['commission'], $this->config->get('config_currency'));
} else {
$data['commission'] = '';
}

if (!empty($order_info)) {
$data['commission_total'] = $this->model_customer_customer->getTotalTransactionsByOrderId($order_id);
} else {
$data['commission_total'] = '';
}

// Comment
if (!empty($order_info)) {
$data['comment'] = nl2br($order_info['comment']);
Expand Down
59 changes: 24 additions & 35 deletions upload/admin/view/template/sale/order_info.twig
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@
<button type="button" data-bs-toggle="modal" data-bs-target="#modal-payment-address" class="btn btn-outline-primary float-end"><i class="fa-solid fa-cog"></i></button>
</div>
</div>

<div id="shipping-address" class="col{% if not shipping_method %} d-none{% endif %}">
<div class="input-group mb-3">
<div class="form-control border rounded-start">
Expand Down Expand Up @@ -266,7 +265,6 @@
<button type="button" data-bs-toggle="modal" data-bs-target="#modal-shipping-address" class="btn btn-outline-primary float-end"><i class="fa-solid fa-cog"></i></button>
</div>
</div>

</div>
<div class="row">

Expand Down Expand Up @@ -440,7 +438,6 @@
{% endfor %}
</ul>
<div class="tab-content">

<div id="tab-history" class="tab-pane active">
<fieldset>
<legend>{{ text_history }}</legend>
Expand Down Expand Up @@ -491,7 +488,6 @@
<input type="hidden" name="order_id" value="{{ order_id }}" id="input-order-id"/>
</form>
</div>

<div id="tab-additional" class="tab-pane">
<div class="table-responsive">
<table class="table table-bordered">
Expand Down Expand Up @@ -541,7 +537,6 @@
</div>
<div class="modal-body">
<form id="form-customer">

<div class="mb-3">
<label for="input-customer" class="form-label">{{ entry_customer }}</label>
<div class="input-group">
Expand All @@ -551,7 +546,6 @@
<input type="hidden" name="customer_id" value="{{ customer_id }}" id="input-customer-id"/>
<ul id="autocomplete-customer" class="dropdown-menu"></ul>
</div>

<div class="mb-3">
<label for="input-customer-group" class="form-label">{{ entry_customer_group }}</label>
<select name="customer_group_id" id="input-customer-group" class="form-select">
Expand All @@ -560,27 +554,23 @@
{% endfor %}
</select>
</div>

<div class="mb-3 required">
<label for="input-firstname" class="form-label">{{ entry_firstname }}</label>
<input type="text" name="firstname" value="{{ firstname }}" placeholder="{{ entry_firstname }}" id="input-firstname" class="form-control"/>
<div id="error-firstname" class="invalid-feedback"></div>
</div>

<div class="mb-3 required">
<label for="input-lastname" class="form-label">{{ entry_lastname }}</label>
<input type="text" name="lastname" value="{{ lastname }}" placeholder="{{ entry_lastname }}" id="input-lastname" class="form-control"/>
<div id="error-lastname" class="invalid-feedback"></div>
</div>

<div class="mb-3 required">
<label for="input-email" class="form-label">{{ entry_email }}</label>
<div class="input-group">
<input type="text" name="email" value="{{ email }}" placeholder="{{ entry_email }}" id="input-email" class="form-control"/> <a href="mailto:{{ email }}" class="btn btn-outline-secondary"><i class="fa-solid fa-envelope"></i></a>
</div>
<div id="error-email" class="invalid-feedback"></div>
</div>

<div class="mb-3{% if config_telephone_required %} required{% endif %}">
<label for="input-telephone" class="form-label">{{ entry_telephone }}</label>
<input type="text" name="telephone" value="{{ telephone }}" placeholder="{{ entry_telephone }}" id="input-telephone" class="form-control"/>
Expand Down Expand Up @@ -784,8 +774,6 @@
</div>
</div>



<div id="modal-payment-address" class="modal">
<div class="modal-dialog">
<div class="modal-content">
Expand Down Expand Up @@ -950,27 +938,6 @@
</div>
</div>
</div>

<div id="modal-payment" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-credit-card"></i> {{ text_payment_method }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<form id="form-payment-method">
<p>{{ text_payment }}</p>
<div id="payment-methods"></div>
<div class="text-end">
<button type="submit" id="button-payment-method" class="btn btn-primary">{{ button_continue }}</button>
</div>
</form>
</div>
</div>
</div>
</div>

<div id="modal-shipping-address" class="modal">
<div class="modal-dialog">
<div class="modal-content">
Expand Down Expand Up @@ -1167,6 +1134,26 @@
</div>
</div>

<div id="modal-payment" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-credit-card"></i> {{ text_payment_method }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">

<form id="form-payment-method">
<p>{{ text_payment }}</p>
<div id="payment-methods"></div>
<div class="text-end">
<button type="submit" id="button-payment-method" class="btn btn-primary">{{ button_continue }}</button>
</div>
</form>
</div>
</div>
</div>
</div>

<div id="modal-affiliate" class="modal">
<div class="modal-dialog">
Expand All @@ -1192,7 +1179,6 @@
</div>
</div>


<div id="modal-comment" class="modal">
<div class="modal-dialog">
<div class="modal-content">
Expand Down Expand Up @@ -2358,7 +2344,6 @@ $('#order-vouchers').on('submit', 'form', function(e) {
});
});
// Coupon
$('#form-coupon').on('submit', function(e) {
e.preventDefault();
Expand Down Expand Up @@ -2802,6 +2787,10 @@ $('#button-confirm').on('click', function() {
for (i in json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'][i] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['error']['customer']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error']['customer'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
}
if (json['success']) {
Expand Down
8 changes: 4 additions & 4 deletions upload/catalog/controller/api/payment_method.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ public function index(): void {
$json['error'] = $this->language->get('error_product');
}

if ($this->config->get('config_checkout_payment_address') && !isset($this->session->data['payment_address'])) {
$json['error'] = $this->language->get('error_payment_address');
}

if ($this->cart->hasShipping()) {
if (!isset($this->session->data['shipping_address'])) {
$json['error'] = $this->language->get('error_shipping_address');
Expand All @@ -36,6 +32,10 @@ public function index(): void {
}
}

if ($this->config->get('config_checkout_payment_address') && !isset($this->session->data['payment_address'])) {
$json['error'] = $this->language->get('error_payment_address');
}

if (!$json) {
$payment_address = [];

Expand Down
16 changes: 16 additions & 0 deletions upload/catalog/controller/api/shipping_method.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function index(): void {
$this->response->setOutput(json_encode($json));
}

public function getMethods(): void {

}

/**
* Save
*
Expand All @@ -58,8 +62,20 @@ public function save(): void {
}

if (isset($this->request->post['shipping_method'])) {


if (!isset($this->request->post['shipping_method']['code'])) {


}


$shipping = explode('.', $this->request->post['shipping_method']);





if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
$json['error'] = $this->language->get('error_shipping_method');
}
Expand Down

0 comments on commit c10a094

Please sign in to comment.