Updated readme

minor modifications
This commit is contained in:
Patrick Henninger
2018-12-21 18:37:36 +01:00
parent 8ac18c1759
commit 892c76cc61
3 changed files with 148 additions and 8 deletions

View File

@@ -45,6 +45,13 @@ class Cart
*/
private $discount = 0;
/**
* Defines the discount percentage.
*
* @var float
*/
private $taxRate = 0;
/**
* Cart constructor.
*
@@ -55,6 +62,7 @@ class Cart
{
$this->session = $session;
$this->events = $events;
$this->taxRate = config('cart.tax');
$this->instance(self::DEFAULT_INSTANCE);
}
@@ -392,6 +400,22 @@ class Cart
$this->session->put($this->instance, $content);
}
/**
* Set the global tax rate for the cart.
* This will set the tax rate for all items.
*
* @param float $discount
*/
public function setGlobalTax(float $taxRate)
{
$this->taxRate = $taxRate;
if ($this->content && $this->content->count()) {
$this->content->each(function ($item, $key) {
$item->setTaxRate($this->taxRate);
});
}
}
/**
* Set the discount rate for the cart item with the given rowId.
*
@@ -549,7 +573,7 @@ class Cart
$cartItem->setQuantity($qty);
}
$cartItem->setTaxRate(config('cart.tax'));
$cartItem->setTaxRate($this->taxRate);
$cartItem->setDiscountRate( $this->discount );
return $cartItem;