diff --git a/src/productList.php b/src/productList.php index f925b4c..f081aff 100644 --- a/src/productList.php +++ b/src/productList.php @@ -117,6 +117,11 @@ public function __set(string $key, $value): self if ($value['quantity'] < 0) { throw new \Exception('The quantity of the cart must not be negative.'); } + + if ($key !== $value['id']) { + $key = $value['id']; + } + $this->data[strtolower($key)] = $value; if ($this->getTax() < 0) {