1
0
mirror of synced 2025-01-18 17:01:41 +03:00

ref #87089 Fix bug with products tax (#295)

This commit is contained in:
Uryvskiy Dima 2022-12-28 10:36:03 +03:00 committed by GitHub
parent 4edd42604b
commit d929a1fd5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 16 deletions

View File

@ -1,3 +1,6 @@
## 2022-12-26 4.5.3
* Fix bug with products tax
## 2022-11-09 4.5.2
* Add validator for CRM URL

View File

@ -1 +1 @@
4.5.2
4.5.3

View File

@ -1066,18 +1066,16 @@ if (!class_exists('WC_Retailcrm_History')) :
$wcOrderItem->save();
}
// Be aware that discounts may be added.
if (!empty($crmProduct['summ'])) {
if (wc_tax_enabled()) {
$shippingTaxClass = get_option('woocommerce_shipping_tax_class');
$wcOrder = wc_get_order($wcOrderItem->get_order_id());
$itemRate = $shippingTaxClass == 'inherit'
? getOrderItemRate($wcOrder)
: getShippingRate();
$itemPrice = calculatePriceExcludingTax($crmProduct['summ'], $itemRate);
$itemRate = getOrderItemRate($wcOrder);
$wcOrderItem->set_total($itemPrice);
if ($itemRate === null) {
$itemRate = getShippingRate();
}
$wcOrderItem->set_total(calculatePriceExcludingTax($crmProduct['summ'], $itemRate));
} else {
$wcOrderItem->set_total($crmProduct['summ']);
}

View File

@ -138,7 +138,10 @@ function is_wplogin()
}
/**
* Get shipping rate.
* If a tax class with a standart rate is selected, woocommerce_shipping_tax_class = ''
* If a tax class with a zero rate is selected, woocommerce_shipping_tax_class = zero-rate
* If a tax class with a reduced rate is selected, woocommerce_shipping_tax_class = reduced-rate
* If the tax is calculated based on the items in the cart, woocommerce_shipping_tax_class = inherit
*
* @return mixed
*/
@ -176,9 +179,7 @@ function getOrderItemRate($wcOrder)
function calculatePriceExcludingTax($priceIncludingTax, $rate)
{
$decimalPlaces = wc_get_price_decimals();
return round($priceIncludingTax / (1 + $rate / 100), $decimalPlaces);
return round($priceIncludingTax / (1 + $rate / 100), wc_get_price_decimals());
}
/**

View File

@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.0
Requires at least: 5.3
Tested up to: 6.0
Stable tag: 4.5.2
Stable tag: 4.5.3
License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html
@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i
== Changelog ==
= 4.5.3 =
* Fix bug with products tax
= 4.5.2 =
* Add validator for CRM URL

View File

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/
* Version: 4.5.2
* Version: 4.5.3
* Tested up to: 6.0
* WC requires at least: 5.4
* WC tested up to: 6.9

View File

@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.5.2
* @version 4.5.3
*
* @package RetailCRM
*/