From 7feecfbf3493c794560835784384f3f20c8b523c Mon Sep 17 00:00:00 2001 From: Daniel Kerr Date: Wed, 7 Aug 2024 01:20:27 +0800 Subject: [PATCH] https://github.com/opencart/opencart/issues/12661 --- .../admin/view/template/sale/order_info.twig | 1257 ++++++++--------- upload/catalog/controller/api/order.php | 320 +++-- .../catalog/controller/api/payment_method.php | 5 +- .../view/template/checkout/cart_list.twig | 11 + .../opencart/catalog/model/total/coupon.php | 2 +- .../opencart/catalog/model/total/voucher.php | 2 +- upload/system/library/curl.php | 69 + 7 files changed, 875 insertions(+), 791 deletions(-) create mode 100644 upload/system/library/curl.php diff --git a/upload/admin/view/template/sale/order_info.twig b/upload/admin/view/template/sale/order_info.twig index c64af370c3e..51818d138b4 100644 --- a/upload/admin/view/template/sale/order_info.twig +++ b/upload/admin/view/template/sale/order_info.twig @@ -176,93 +176,7 @@ -
-
- -
-
-
- - - -
-
-
- -
-
-
- - -
-
-
- -
-
-
- - -
-
-
- -
-
-
-
{{ text_reward }} -
-
{{ points }}
-
-
- {% if not reward_total %} - - {% else %} - - {% endif %} -
-
- -
-
-
-
{{ text_affiliate }} -
- {% if affiliate_id %} - - {% else %} -
 
- {% endif %} -
-
- -
-
- -
-
-
-
{{ text_commission }} -
- {% if commission %} -
{{ commission }}
- {% else %} -
 
- {% endif %} -
-
- {% if not commission_total %} - - {% else %} - - {% endif %} -
-
- -
-
-
@@ -392,6 +306,94 @@
+
+
+ +
+
+
+ + + +
+
+
+ +
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+ +
+
+
+
{{ text_reward }} +
+
{{ points }}
+
+
+ {% if not reward_total %} + + {% else %} + + {% endif %} +
+
+ +
+
+
+
{{ text_affiliate }} +
+ {% if affiliate_id %} + + {% else %} +
 
+ {% endif %} +
+
+ +
+
+ +
+
+
+
{{ text_commission }} +
+ {% if commission %} +
{{ commission }}
+ {% else %} +
 
+ {% endif %} +
+
+ {% if not commission_total %} + + {% else %} + + {% endif %} +
+
+ +
+
+ + +
@@ -782,29 +784,7 @@
- +
+ + + + + + {% if modules %}

{{ text_next }}

{{ text_next_choice }}

@@ -96,6 +106,7 @@ {% endfor %}
{% endif %} +
diff --git a/upload/extension/opencart/catalog/model/total/coupon.php b/upload/extension/opencart/catalog/model/total/coupon.php index 50d0af7d07a..ba403a29cd1 100644 --- a/upload/extension/opencart/catalog/model/total/coupon.php +++ b/upload/extension/opencart/catalog/model/total/coupon.php @@ -171,6 +171,6 @@ public function confirm(array $order_info, array $order_total): int { public function unconfirm(array $order_info): void { $this->load->model('marketing/coupon'); - $this->model_marketing_coupon->deleteHistoryByOrderId($order_info['order_id']); + $this->model_marketing_coupon->deleteHistoriesByOrderId($order_info['order_id']); } } diff --git a/upload/extension/opencart/catalog/model/total/voucher.php b/upload/extension/opencart/catalog/model/total/voucher.php index 96ffeba47ea..4731d03a859 100644 --- a/upload/extension/opencart/catalog/model/total/voucher.php +++ b/upload/extension/opencart/catalog/model/total/voucher.php @@ -88,6 +88,6 @@ public function confirm(array $order_info, array $order_total): int { public function unconfirm(array $order_info): void { $this->load->model('checkout/voucher'); - $this->model_checkout_voucher->deleteHistoryByOrderId($order_info['order_id']); + $this->model_checkout_voucher->deleteHistoriesByOrderId($order_info['order_id']); } } diff --git a/upload/system/library/curl.php b/upload/system/library/curl.php new file mode 100644 index 00000000000..e82331a39dc --- /dev/null +++ b/upload/system/library/curl.php @@ -0,0 +1,69 @@ +domain = $url; + } + + public function setOption(string $key, array $data = []) { + $this->option[$key] = $data; + } + + + public function send(string $route, $data = []) { + $time = time(); + + // Build hash string + $string = $route . "\n"; + $string .= $this->username . "\n"; + $string .= $this->domain . "\n"; + $string .= $this->path . "\n"; + $string .= $this->store_id . "\n"; + $string .= $this->language . "\n"; + $string .= md5(http_build_query($data)) . "\n"; + $string .= $time . "\n"; + + $signature = base64_encode(hash_hmac('sha1', $string, $this->key, true)); + + // Make remote call + $url = 'http://' . $this->domain . $this->path . 'index.php?route=' . $route; + $url .= '&username=' . urlencode($this->username); + $url .= '&store_id=' . $this->store_id; + $url .= '&language=' . $this->language; + $url .= '&time=' . $time; + $url .= '&signature=' . rawurlencode($signature); + + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); + curl_setopt($curl, CURLOPT_TIMEOUT, 30); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + + $response = curl_exec($curl); + + $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + curl_close($curl); + + if ($status == 200) { + $response_info = json_decode($response, true); + } else { + $response_info = []; + } + + return $response_info; + } +} \ No newline at end of file