Prevent negative subtotal

Manual merge of 33fc42dae1
This commit is contained in:
Patrick
2020-08-29 15:47:33 +02:00
committed by GitHub
parent 19b7bdfe1f
commit ae0a976785

View File

@@ -412,7 +412,7 @@ class CartItem implements Arrayable, Jsonable
case 'priceTotal':
return round($this->priceNet * $this->qty, $decimals);
case 'subtotal':
return round($this->priceTotal - $this->discountTotal, $decimals);
return max(round($this->priceTotal - $this->discountTotal, $decimals), 0);
case 'priceTarget':
return round(($this->priceTotal - $this->discountTotal) / $this->qty, $decimals);
case 'taxTotal':
@@ -435,7 +435,7 @@ class CartItem implements Arrayable, Jsonable
case 'priceTotal':
return round($this->price * $this->qty, $decimals);
case 'subtotal':
return round($this->priceTotal - $this->discountTotal, $decimals);
return max(round($this->priceTotal - $this->discountTotal, $decimals), 0);
case 'priceTarget':
return round(($this->priceTotal - $this->discountTotal) / $this->qty, $decimals);
case 'taxTotal':