diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 312cdd1..767dfcb 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -1068,16 +1068,14 @@ if (!class_exists('WC_Retailcrm_History')) : if (!empty($crmProduct['summ'])) { if (wc_tax_enabled()) { - $itemRate = getShippingRate(); + $wcOrder = wc_get_order($wcOrderItem->get_order_id()); + $itemRate = getOrderItemRate($wcOrder); - if (empty($itemRate) || get_option('woocommerce_shipping_tax_class') == 'inherit') { - $wcOrder = wc_get_order($wcOrderItem->get_order_id()); - $itemRate = getOrderItemRate($wcOrder); + if ($itemRate === null) { + $itemRate = getShippingRate(); } - $itemPrice = calculatePriceExcludingTax($crmProduct['summ'], $itemRate); - - $wcOrderItem->set_total($itemPrice); + $wcOrderItem->set_total(calculatePriceExcludingTax($crmProduct['summ'], $itemRate)); } else { $wcOrderItem->set_total($crmProduct['summ']); } diff --git a/src/include/functions.php b/src/include/functions.php index df7ba5a..893e2d7 100644 --- a/src/include/functions.php +++ b/src/include/functions.php @@ -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 */