From f7733b4113a385d63394f081f671efb49da1cf02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Tue, 27 Jan 2026 18:36:21 +0100 Subject: [PATCH] Add VAT number handling in order processing and invoice templates --- .DS_Store | Bin 12292 -> 12292 bytes api/v2/get/software_update.php | 10 ++++++++ api/v2/post/placeorder.php | 8 +++--- assets/.DS_Store | Bin 6148 -> 6148 bytes assets/functions.php | 1 + assets/mail/email_template_invoice.php | 30 ++++++++++++++++++++-- assets/mail/pdf_template_invoice.php | 23 +++++++++++++++++ assets/softwaretool.js | 10 +++++++- settings/translations/translations_DE.php | 1 + settings/translations/translations_ES.php | 1 + settings/translations/translations_NL.php | 1 - settings/translations/translations_PL.php | 1 + settings/translations/translations_PT.php | 1 + settings/translations/translations_US.php | 3 +-- 14 files changed, 81 insertions(+), 9 deletions(-) diff --git a/.DS_Store b/.DS_Store index 8f764648eda816b2498ef5584f36f7e42e03a7c9..9d4c452e8d05565dc11a62679d1101247abf067b 100644 GIT binary patch delta 121 zcmZokXi1ph&uF}0m_bM4|UM{B0xS37kGt1@&D!Uk=LW+z46_78p diff --git a/api/v2/get/software_update.php b/api/v2/get/software_update.php index 98f7cb9..a7191c3 100644 --- a/api/v2/get/software_update.php +++ b/api/v2/get/software_update.php @@ -468,6 +468,16 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){ ]; } + // Sort output: is_current = true first, then by price low to high + usort($output, function($a, $b) { + // First priority: is_current (true comes before false) + if ($a['is_current'] !== $b['is_current']) { + return $b['is_current'] - $a['is_current']; + } + // Second priority: price (low to high) + return floatval($a['price']) - floatval($b['price']); + }); + $messages = $output; if (debug && !empty($output)) { diff --git a/api/v2/post/placeorder.php b/api/v2/post/placeorder.php index b6e7b37..306af85 100644 --- a/api/v2/post/placeorder.php +++ b/api/v2/post/placeorder.php @@ -46,7 +46,8 @@ if (isset($post_content['cart']) && isset($post_content['checkout_input']) && is 'address_state' => $post_content['customer_details']['address_state'] ?? '', 'address_zip' => $post_content['customer_details']['address_zip'] ?? '', 'address_country' => $post_content['customer_details']['address_country'] ?? '', - 'address_phone' => $post_content['customer_details']['address_phone'] ?? '' + 'address_phone' => $post_content['customer_details']['address_phone'] ?? '', + 'vat_number' => $post_content['customer_details']['vat_number'] ?? '' ]; //Initialize calculator @@ -75,7 +76,7 @@ if (isset($post_content['cart']) && isset($post_content['checkout_input']) && is $txn_id = strtoupper(uniqid('SC') . substr(md5(mt_rand()), 0, 5)); // Insert transaction header - $stmt = $pdo->prepare('INSERT INTO transactions (txn_id, payment_amount, payment_status, payer_email, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, address_phone, account_id, payment_method, shipping_method, shipping_amount, discount_amount, discount_code, tax_amount,accounthierarchy) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'); + $stmt = $pdo->prepare('INSERT INTO transactions (txn_id, payment_amount, payment_status, payer_email, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, address_phone, account_id, payment_method, shipping_method, shipping_amount, discount_amount, discount_code, tax_amount,accounthierarchy, vat_number) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'); $stmt->execute([ $txn_id, $total, @@ -96,7 +97,8 @@ if (isset($post_content['cart']) && isset($post_content['checkout_input']) && is $discounttotal, $checkout_input['discount_code'], $taxtotal, - $partner_product + $partner_product, + $customer_details['vat_number'] ]); // Get order ID $transaction_id = $pdo->lastInsertId(); diff --git a/assets/.DS_Store b/assets/.DS_Store index 7502f1f324f78f13bfed6b98ca295d7072285086..1ba4cf5a23caa3cca1ed969ea790723f77e30419 100644 GIT binary patch delta 31 ncmZoMXfc@J&&ahgU^g=(*JK_Rw3OoHr2PCG#?3Y?>zFsQ IbNuB80FWLJ3jhEB diff --git a/assets/functions.php b/assets/functions.php index 400aa0a..2d8d875 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -4559,6 +4559,7 @@ function transformOrderData(array $orderData): array { 'country' => $firstRow['address_country'], 'phone' => $firstRow['address_phone'], 'language' => $firstRow['user_language'], + 'vat_number' => $firstRow['vat_number'] ], 'products' => [], 'invoice' => [ diff --git a/assets/mail/email_template_invoice.php b/assets/mail/email_template_invoice.php index f45d166..429edea 100644 --- a/assets/mail/email_template_invoice.php +++ b/assets/mail/email_template_invoice.php @@ -1,4 +1,5 @@ @@ -30,11 +31,28 @@ $message = ' 5061 JR OISTERWIJK
Nederland - - + + contact-details
+ Ralf Adams
+ +31 13 8221480
+ ralfadams@totalsafetysolutions.nl + + + + + + + +
+ Customer
+ '.$invoice_data['customer']['name'].'
+ '.$invoice_data['customer']['street'].'
+ '.$invoice_data['customer']['zip'].', '.$invoice_data['customer']['city'].'
+ '.$invoice_data['customer']['country'].' +
@@ -49,6 +67,10 @@ $message = ' + + + +
Invoice Number: ' . htmlspecialchars($order_id) . '
Your Vat Number:' . htmlspecialchars($invoice_data['customer']['vat_number'] ?? '') . '
@@ -61,6 +83,10 @@ $message = ' Order number: ' . htmlspecialchars($order_id) . ' + + Payment Methodr: + ' . (${$payment_method} ?? $invoice_data['header']['payment_method'] ). ' + diff --git a/assets/mail/pdf_template_invoice.php b/assets/mail/pdf_template_invoice.php index f30e7e9..29aea68 100644 --- a/assets/mail/pdf_template_invoice.php +++ b/assets/mail/pdf_template_invoice.php @@ -1,4 +1,5 @@ @@ -217,6 +218,20 @@ $pdf = '

Nederland

+

contact-details

+

Ralf Adams

+

+31 13 8221480

+

ralfadams@totalsafetysolutions.nl

+
+ + +
+
+

Customer

+

'.$invoice_data['customer']['name'].'

+

'.$invoice_data['customer']['street'].'

+

'.$invoice_data['customer']['zip'].', '.$invoice_data['customer']['city'].'

+

'.$invoice_data['customer']['country'].'

@@ -230,6 +245,10 @@ $pdf = '
Invoice Number
: ' . htmlspecialchars($order_id) . '
+
+
Your Vat Number
+
: ' . htmlspecialchars($invoice_data['customer']['vat_number'] ?? '') . '
+
@@ -240,6 +259,10 @@ $pdf = '
Order number
: ' . htmlspecialchars($order_id) . '
+
+
Payment Method
+
: ' . (${$payment_method} ?? $invoice_data['header']['payment_method'] ). '
+
diff --git a/assets/softwaretool.js b/assets/softwaretool.js index e730632..93707de 100644 --- a/assets/softwaretool.js +++ b/assets/softwaretool.js @@ -1280,6 +1280,11 @@ function showPaymentModal(option) { +
+ + +
+