Adjusted for global discount

Fixed tests for Laravel 5.7
This commit is contained in:
Patrick Henninger
2018-12-21 15:18:27 +01:00
parent 645d6f78ad
commit 48df3f5d74
4 changed files with 109 additions and 15 deletions

View File

@@ -37,6 +37,13 @@ class Cart
*/
private $instance;
/**
* Defines the discount percentage.
*
* @var float
*/
private $discount;
/**
* Cart constructor.
*
@@ -47,6 +54,7 @@ class Cart
{
$this->session = $session;
$this->events = $events;
$this->discount = 0;
$this->instance(self::DEFAULT_INSTANCE);
}
@@ -340,6 +348,16 @@ class Cart
$this->session->put($this->instance, $content);
}
/**
* Set the global discount percentage for the cart
*
* @param float $discount
*/
public function setDiscount(float $discount)
{
$this->discount = $discount;
}
/**
* Store an the current instance of the cart.
*
@@ -462,6 +480,7 @@ class Cart
}
$cartItem->setTaxRate(config('cart.tax'));
$cartItem->setDiscountRate( $this->discount );
return $cartItem;
}