diff --git a/src/Cart.php b/src/Cart.php index 49b2cd3..3ad994a 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -31,6 +31,11 @@ class Cart implements \Serializable */ private StorageInterface $storage; + /** + * @var array $meta + */ + private array $meta; + /** * @var */ @@ -52,6 +57,7 @@ public function __construct(StorageInterface $storage, $dispatcher, $config) $this->conditionsOrder = $this->storage->get('cart:conditionsOrder') ?? config('cart.condition_order.cart'); $this->itemConditionsOrder = $this->storage->get('cart:itemConditionsOrder') ?? config('cart.condition_order.item'); + $this->meta = $this->storage->get('cart:meta') ?? []; } public function clone(StorageInterface $storage, $dispatcher = null, $config = null): Cart @@ -333,6 +339,20 @@ public function setItemConditionsOrder(array $itemConditionsOrder): void $this->items()->each->setItemConditionsOrder($itemConditionsOrder); } + /** + * @param string[] $itemConditionsOrder + */ + public function setMeta(string $key, mixed $data): void + { + $this->meta[$key] = $data; + $this->storage->put('cart:meta', $this->meta); + } + + public function getMeta(string $key, mixed $default): mixed + { + return $this->meta[$key] ?? $default; + } + private function updateItemStorage() { $this->updateConditionPrice();