Skip to content

Commit 9ee7d5b

Browse files
author
Leonix
committed
Shop-Script v.11.2.1
* Fixed incorrect transfer of the order amount, containing taxes, to a payment gateway, which occurred in the update to version 11.2.0.
1 parent d56fd61 commit 9ee7d5b

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

lib/classes/shopHelper.class.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,19 +2071,6 @@ public static function getWaOrder($order, $options = array())
20712071

20722072
}
20732073

2074-
$tax_included = null;
2075-
foreach ($order['items'] as $item_id => $item) {
2076-
if (isset($item['tax_included'])) {
2077-
if ($tax_included !== null) {
2078-
if ($tax_included != !!$item['tax_included']) {
2079-
$tax_included = 0;
2080-
}
2081-
} else {
2082-
$tax_included = !!$item['tax_included'];
2083-
}
2084-
}
2085-
}
2086-
20872074
$item_options = array(
20882075
'order_currency' => ifset($order['currency'], $default_currency),
20892076
'shipping_address' => $shipping_address,
@@ -2163,10 +2150,6 @@ public static function getWaOrder($order, $options = array())
21632150
$order_data['dimensions_unit'] = $options['dimensions'];
21642151
}
21652152

2166-
if (in_array($tax_included, array(true, false), true)) {
2167-
$order_data['tax_included'] = $tax_included;
2168-
}
2169-
21702153
if (isset($order['params']['shipping_tax_percent'])) {
21712154
$order_data['shipping_tax_rate'] = $order['params']['shipping_tax_percent'];
21722155
}
@@ -2187,17 +2170,20 @@ public static function getWaOrder($order, $options = array())
21872170
$order_data['discount'] = 0;
21882171
}
21892172

2173+
// order.total always includes all taxes
2174+
$order_data['tax_included'] = true;
21902175
$order_data['total'] = $order_data['shipping'];
2176+
if (empty($order_data['shipping_tax_included']) && !empty($order_data['shipping_tax_rate'])) {
2177+
$order_data['total'] *= 1 + $order_data['shipping_tax_rate']/100;
2178+
}
21912179
foreach ($order_data['items'] as $item) {
2192-
$item_subtotal = $item['price'] * $item['quantity'];
2180+
$item_subtotal = $item['price'] * $item['quantity'] - ifset($item, 'total_discount', 0);
21932181
if (isset($item['tax_included']) && empty($item['tax_included']) && !empty($item['tax_rate'])) {
21942182
$item_subtotal *= 1 + $item['tax_rate']/100;
21952183
}
21962184
$order_data['total'] += $item_subtotal;
21972185
}
21982186

2199-
$order_data['total'] -= $order_data['discount'];
2200-
22012187
$total = self::workupValue($order['total'], 'price', $options['currency'], $order['currency']);
22022188

22032189
if ($total !== $order_data['total']) {

lib/config/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
'pages' => true,
1414
'mobile' => true,
1515
'my_account' => true,
16-
'version' => '11.2.0',
17-
'critical' => '11.2.0',
16+
'version' => '11.2.1',
17+
'critical' => '11.2.1',
1818
'vendor' => 'webasyst',
1919
'csrf' => true,
2020
'payment_plugins' => array(

0 commit comments

Comments
 (0)