diff --git a/src/LaraCart.php b/src/LaraCart.php index dddfa53..9439e0b 100644 --- a/src/LaraCart.php +++ b/src/LaraCart.php @@ -448,6 +448,12 @@ public function taxTotal($format = true) } } + foreach ($this->getFees() as $fee) { + if ($fee->taxable) { + $totalTax += $fee->amount * $this->cart->tax; + } + } + return $this->formatMoney($totalTax, null, null, $format); } @@ -556,9 +562,6 @@ public function feeTotals($format = true) foreach ($this->getFees() as $fee) { $feeTotal += $fee->amount; - if ($fee->taxable) { - $feeTotal += $fee->amount * $this->cart->tax; - } } return $this->formatMoney($feeTotal, null, null, $format); diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index 747ac82..3365f4f 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -83,8 +83,11 @@ public function testTaxableFees() { $this->laracart->addFee('test_2', 1, true); - $this->assertEquals('$1.07', $this->laracart->feeTotals()); - $this->assertEquals('1.07', $this->laracart->feeTotals(false)); + $this->assertEquals('$1.00', $this->laracart->feeTotals()); + $this->assertEquals(1, $this->laracart->feeTotals(false)); + + $this->assertEquals("$0.07", $this->laracart->taxTotal()); + $this->assertEquals("0.07", $this->laracart->taxTotal(false)); } /**