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

fix discount calculation

This commit is contained in:
Круглов Дмитрий 2019-06-07 16:51:18 +03:00
parent 3a0ee18ceb
commit 36d973dbae

View File

@ -104,12 +104,12 @@ class WC_Retailcrm_Order_Item extends WC_Retailcrm_Abstracts_Data
*/
private function calculate_discount(WC_Order_Item_Product $item, $price)
{
$product_price = max(0, round($item->get_total() ? $item->get_total() / $item->get_quantity() : 0));
$product_price = $item->get_total() ? $item->get_total() / $item->get_quantity() : 0;
$product_tax = $item->get_total_tax() ? $item->get_total_tax() / $item->get_quantity() : 0;
$price_item = $product_price + $product_tax;
$discount_price = max(0, round($price)) - $price_item;
$discount_price = $price - $price_item;
return $discount_price;
return round($discount_price, 2);
}
/**