diff --git a/CHANGELOG.md b/CHANGELOG.md index 115a63b..4932db5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index 689f7fb..ae6e65b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.5.2 \ No newline at end of file +4.5.3 \ No newline at end of file diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index e25eecc..312cdd1 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -1066,15 +1066,15 @@ 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'); + $itemRate = getShippingRate(); + + if (empty($itemRate) || get_option('woocommerce_shipping_tax_class') == 'inherit') { + $wcOrder = wc_get_order($wcOrderItem->get_order_id()); + $itemRate = getOrderItemRate($wcOrder); + } - $wcOrder = wc_get_order($wcOrderItem->get_order_id()); - $itemRate = $shippingTaxClass == 'inherit' - ? getOrderItemRate($wcOrder) - : getShippingRate(); $itemPrice = calculatePriceExcludingTax($crmProduct['summ'], $itemRate); $wcOrderItem->set_total($itemPrice); diff --git a/src/include/functions.php b/src/include/functions.php index 663d273..df7ba5a 100644 --- a/src/include/functions.php +++ b/src/include/functions.php @@ -176,9 +176,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()); } /** diff --git a/src/readme.txt b/src/readme.txt index 4aef4a0..8ab01a3 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -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 diff --git a/src/retailcrm.php b/src/retailcrm.php index 62799a0..adcd1fc 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -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 diff --git a/src/uninstall.php b/src/uninstall.php index d24f6ea..585f4cb 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.5.2 + * @version 4.5.3 * * @package RetailCRM */