Skip to content

Commit a2dce3c

Browse files
Fixes tax rounding issue
Merge pull request #1 from olimortimer/patch-2
2 parents e110fae + 963b868 commit a2dce3c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/CartItem.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,23 @@ public function __get($attribute)
255255
}
256256

257257
if($attribute === 'priceTax') {
258-
return $this->price + $this->tax;
258+
return $this->numberFormat( ($this->price + $this->tax) );
259259
}
260260

261261
if($attribute === 'subtotal') {
262-
return $this->qty * $this->price;
262+
return $this->numberFormat( ($this->qty * $this->price) );
263263
}
264264

265265
if($attribute === 'total') {
266-
return $this->qty * ($this->priceTax);
266+
return $this->numberFormat( ($this->qty * $this->priceTax) );
267267
}
268268

269269
if($attribute === 'tax') {
270-
return $this->price * ($this->taxRate / 100);
270+
return $this->numberFormat( ($this->price * ($this->taxRate / 100)) );
271271
}
272272

273273
if($attribute === 'taxTotal') {
274-
return $this->tax * $this->qty;
274+
return $this->numberFormat( ($this->tax * $this->qty) );
275275
}
276276

277277
if($attribute === 'model' && isset($this->associatedModel)) {
@@ -373,7 +373,7 @@ public function toJson($options = 0)
373373
* @param string $thousandSeperator
374374
* @return string
375375
*/
376-
private function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator)
376+
private function numberFormat($value, $decimals = null, $decimalPoint = null, $thousandSeperator = null)
377377
{
378378
if (is_null($decimals)){
379379
$decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals');

0 commit comments

Comments
 (0)