mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 15:41:24 +00:00
Update CartItem.php
This commit is contained in:
@@ -98,7 +98,7 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
* @param float $weight
|
* @param float $weight
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*/
|
*/
|
||||||
public function __construct($id, string $name, Money $price, int $qty, int $weight = 0, array $options = [])
|
public function __construct($id, string $name, Money $price, int $qty = 1, int $weight = 0, ?CartItemOptions $options = null)
|
||||||
{
|
{
|
||||||
if (!is_string($id) && !is_int($id)) {
|
if (!is_string($id) && !is_int($id)) {
|
||||||
throw new \InvalidArgumentException('Please supply a valid identifier.');
|
throw new \InvalidArgumentException('Please supply a valid identifier.');
|
||||||
@@ -109,7 +109,7 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
$this->price = $price;
|
$this->price = $price;
|
||||||
$this->qty = $qty;
|
$this->qty = $qty;
|
||||||
$this->weight = $weight;
|
$this->weight = $weight;
|
||||||
$this->options = new CartItemOptions($options);
|
$this->options = $options ?: new CartItemOptions([]);
|
||||||
$this->rowId = $this->generateRowId($id, $options);
|
$this->rowId = $this->generateRowId($id, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user