Closed LarryBarker closed 11 months ago
@iamgergo I just upgraded to v0.9 and am having the same issue with the exception I can pass an instance of Variant
to addItem
. Still have the error about null price.
@iamgergo Related to another ticket I commented on about array to string conversion error, addItem
is now failing if the item is added with an empty array of properties:
$item = Cart::addItem($variant, 1, []);
This will insert an item into the database with []
as the properties. Later, the InteractsWithItems
trait will throw an error here:
return $this->items->first(static function (Item $item) use ($attributes): bool {
return empty(array_diff(
Arr::dot($attributes),
Arr::dot($item->withoutRelations()->toArray())
));
});
This is because of how array_diff
handles empty arrays for some reason.
Description:
Following the docs trying to add an item to the cart and I get this error back:
Column 'price' cannot be null
Also note I initially tried adding the variant to the cart which failed because
addItem
expects an instance ofProduct
to be passed. This is strange to me but nevertheless I can work around it.I'm not exactly sure how or where to pass the price?
Also, I cannot seem to find where the logic for
addItem
actually lives?