-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional parameters passed in addItem are not being saved #4
Comments
Actually you need to extend the |
0.3 is coming on this Sunday (March 18), this fix will be released with that. |
@danishjamil Does your |
@fulopattila122 Is it possible for you bump the "Product Options & Variants" feature to 0.4. |
I'm asking because I see at least two ways to do this: 1. Passing Attributes Manuallyjust pass the extra attributes all the time manually: Cart::addItem($product, 1, [ 'attrs' => ['width' => 123, 'height' => 12]]); In this case any key/value under 2. Auto Merging Extra AttributesUsing this approach you could configure the extra attributes of Buyables that the cart keeps adding to cart items. //...
'cart' => [
'items' => [
'auto_copy_attributes' => ['width', 'height']
]
]
//... This way you could just pass you product: Cart::addItem($product); and the attributes specified in config would be automatically copied from the product to the cart item. I think both makes sense and can be used arbitrarily, even together. |
@fulopattila122 I would rather keep it at the model and/or at the Because its not necessary that every Buyable Model (product) will have the attributes defined in the config file e.g. Digital Goods. |
@danishjamil I've implemented both variants, so you can freely choose to use either/both/none solutions. Usage has been described in readme: https://github.com/vanilophp/cart/#setting-custom-item-attributes |
Environment: Laravel 5.5.39
Standalone: vanila/cart: 0.2
Code:
$product = \App\Models\Banner::find(1);
\Cart::addItem($product, 1, ['width' => 123, 'height' => 12]);
There is no column in the cart_item table to store the additional parameters.
The text was updated successfully, but these errors were encountered: