Fix a critical bug when working with taxes
This commit is contained in:
parent
91a7c02e25
commit
fdbac7a2ec
@ -1,3 +1,6 @@
|
|||||||
|
## 2022-09-02 4.4.8
|
||||||
|
* Fix a critical bug when working with taxes
|
||||||
|
|
||||||
## 2022-08-10 4.4.7
|
## 2022-08-10 4.4.7
|
||||||
* Add support for payment method on delivery
|
* Add support for payment method on delivery
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wc_tax_enabled()) {
|
if (wc_tax_enabled()) {
|
||||||
$rate = getShippingRates();
|
$rate = getShippingRate();
|
||||||
|
|
||||||
$shipping->set_total($this->getDeliveryCost($order, $rate));
|
$shipping->set_total($this->getDeliveryCost($order, $rate));
|
||||||
} else {
|
} else {
|
||||||
@ -882,7 +882,7 @@ if (!class_exists('WC_Retailcrm_History')) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wc_tax_enabled()) {
|
if (wc_tax_enabled()) {
|
||||||
$rate = getShippingRates();
|
$rate = getShippingRate();
|
||||||
|
|
||||||
$shipping->set_total($this->getDeliveryCost($order, $rate));
|
$shipping->set_total($this->getDeliveryCost($order, $rate));
|
||||||
} else {
|
} else {
|
||||||
|
@ -380,9 +380,13 @@ if (!class_exists('WC_Retailcrm_Orders')) :
|
|||||||
: $shipping['total'];
|
: $shipping['total'];
|
||||||
|
|
||||||
if (wc_tax_enabled()) {
|
if (wc_tax_enabled()) {
|
||||||
$rate = getShippingRates();
|
$shippingTaxClass = get_option('woocommerce_shipping_tax_class');
|
||||||
|
|
||||||
if (!empty($rate)) {
|
$rate = $shippingTaxClass == 'inherit'
|
||||||
|
? $this->getOrderItemRate($order)
|
||||||
|
: getShippingRate();
|
||||||
|
|
||||||
|
if ($rate !== null) {
|
||||||
$orderData['delivery']['vatRate'] = $rate;
|
$orderData['delivery']['vatRate'] = $rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,6 +506,20 @@ if (!class_exists('WC_Retailcrm_Orders')) :
|
|||||||
return $this->payment;
|
return $this->payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function getOrderItemRate($order)
|
||||||
|
{
|
||||||
|
$orderItemTax = $order->get_taxes();
|
||||||
|
|
||||||
|
if (is_array($orderItemTax)) {
|
||||||
|
$orderItemTax = array_shift($orderItemTax);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $orderItemTax instanceof WC_Order_Item_Tax ? $orderItemTax->get_rate_percent() : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if provided order is for corporate customer
|
* Returns true if provided order is for corporate customer
|
||||||
*
|
*
|
||||||
|
@ -155,8 +155,12 @@ function validateUrl(string $url)
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function getShippingRates()
|
function getShippingRate()
|
||||||
{
|
{
|
||||||
|
if (!isset(WC()->cart)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$shippingRates = WC_Tax::get_shipping_tax_rates();
|
$shippingRates = WC_Tax::get_shipping_tax_rates();
|
||||||
|
|
||||||
// Only one tax can be selected for shipping
|
// Only one tax can be selected for shipping
|
||||||
|
@ -4,8 +4,8 @@ Donate link: https://www.simla.com
|
|||||||
Tags: Интеграция, Simla.com, simla
|
Tags: Интеграция, Simla.com, simla
|
||||||
Requires PHP: 5.6
|
Requires PHP: 5.6
|
||||||
Requires at least: 5.3
|
Requires at least: 5.3
|
||||||
Tested up to: 5.9
|
Tested up to: 6.0
|
||||||
Stable tag: 4.4.7
|
Stable tag: 4.4.8
|
||||||
License: GPLv1 or later
|
License: GPLv1 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-1.0.html
|
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 ==
|
== Changelog ==
|
||||||
|
= 4.4.8 =
|
||||||
|
* Fix a critical bug when working with taxes
|
||||||
|
|
||||||
= 4.4.7 =
|
= 4.4.7 =
|
||||||
* Add support for payment method on delivery
|
* Add support for payment method on delivery
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* Description: Integration plugin for WooCommerce & Simla.com
|
* Description: Integration plugin for WooCommerce & Simla.com
|
||||||
* Author: RetailDriver LLC
|
* Author: RetailDriver LLC
|
||||||
* Author URI: http://retailcrm.pro/
|
* Author URI: http://retailcrm.pro/
|
||||||
* Version: 4.4.7
|
* Version: 4.4.8
|
||||||
* Tested up to: 5.9
|
* Tested up to: 6.0
|
||||||
* WC requires at least: 5.4
|
* WC requires at least: 5.4
|
||||||
* WC tested up to: 6.7
|
* WC tested up to: 6.7
|
||||||
* Text Domain: retailcrm
|
* Text Domain: retailcrm
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||||
*
|
*
|
||||||
* @version 4.4.7
|
* @version 4.4.8
|
||||||
*
|
*
|
||||||
* @package RetailCRM
|
* @package RetailCRM
|
||||||
*/
|
*/
|
||||||
|
@ -423,7 +423,7 @@ class WC_Retailcrm_Orders_Test extends WC_Retailcrm_Test_Case_Helper
|
|||||||
|
|
||||||
public function test_get_shipping_rates()
|
public function test_get_shipping_rates()
|
||||||
{
|
{
|
||||||
$rate = getShippingRates();
|
$rate = getShippingRate();
|
||||||
|
|
||||||
$this->assertEquals(null, $rate);
|
$this->assertEquals(null, $rate);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user