From a6f6e0887f9617f35c87678575c3a1fbf1414eab Mon Sep 17 00:00:00 2001 From: Patrick Date: Sat, 5 Feb 2022 19:42:15 +0100 Subject: [PATCH] Update CartItem.php --- src/CartItem.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CartItem.php b/src/CartItem.php index b792912..d9a0287 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -237,9 +237,8 @@ class CartItem implements Arrayable, Jsonable */ public static function fromArray(array $attributes) : self { - $options = Arr::get($attributes, 'options', []); - - return new self($attributes['id'], $attributes['name'], $attributes['price'], $attributes['weight'], $options); + $options = new CartItemOptions(Arr::get($attributes, 'options', [])); + return new self($attributes['id'], $attributes['name'], $attributes['price'], $attributes['qty'], $attributes['weight'], $options); } /** @@ -247,9 +246,10 @@ class CartItem implements Arrayable, Jsonable * * @param int|string $id */ - public static function fromAttributes(int|string $id, string $name, Money $price, int $qty, int $weight, array $options = []) : self + public static function fromAttributes(int|string $id, string $name, Money $price, int $qty, int $weight, ?CartItemOptions $options = null) : self { - return new self($id, $name, $price, $weight, $options); + $options = $options ?: new CartItemOptions([]); + return new self($id, $name, $price, $qty, $weight, $options); } /**