Closed KingPatje closed 1 year ago
If the product has variants, you need to supply a variant before you can add the product to the cart.
correct, but a customer should never see an exception, validation rules should handle this.
True, I'll re-open to fix that.
Released as part of v5.0.2.
Description
When you press add to cart without selecting a Variant, you will get the following error:
DoubleThreeDigital\SimpleCommerce\Products\Product::variant(): Argument #1 ($optionKey) must be of type string, null given, called in D:\webdev\scommerce\vendor\doublethreedigital\simple-commerce\src\Http\Controllers\CartItemController.php on line 115
This is because in DoubleThreeDigital\SimpleCommerce\Http\Requests\CartItem\StoreRequest.php the validation rule says the variant may be nullable and if its not null it must be a string.
The Product::variant expects a string, so a null value isn't working. I tried making the variant required in the validation rules like this:
However, this gives a new error, where i lose track.