Is it possible to add dynamic product properties to a product in your shopping cart similar to dynamic order properties?
I have a product that needs to have 3 dropdown options:
Liquid type (3 options)
Bottle Size (2 options)
Bottle Strength (4 options)
Bottle size is the only option that changes the price, the other two are just for information only, however I need this information attached to a product that has been added to the cart. I only want to create 2 variant options for bottle size. If I was to create a variant for each possible combination, I would need to create 24 variations for each product which will be a nightmare to maintain.
Dynamic Product Properties
Is it possible to add dynamic product properties to a product in your shopping cart similar to dynamic order properties?
I have a product that needs to have 3 dropdown options:
Liquid type (3 options)
Bottle Size (2 options)
Bottle Strength (4 options)
Bottle size is the only option that changes the price, the other two are just for information only, however I need this information attached to a product that has been added to the cart. I only want to create 2 variant options for bottle size. If I was to create a variant for each possible combination, I would need to create 24 variations for each product which will be a nightmare to maintain.
Can anyone point me in the right direction?
Cheers,
Marc
I have looked into this a bit further and thought I could get product definition fields that have not been checked as a variant.
I am using the following code but there seems to be a problem with my linq statement:
var product = SiteContext.Current.CatalogContext.CurrentProduct;
var productdefinition = product.ProductDefinition;
var productdefinitionfields = productdefinition.ProductDefinitionFields.SelectMany(x => x.IsVariantProperty == false);
I am new to uCommerce and Linq so may be completely off track here..
A product in the cart is represented by an OrderLine class. If I'm right than an OrderLine can also have dynamic properties like the order itself.
So i think it's just like that: line["bottle_size"] = 2;
At the time you add your products to the cart you can add the propertys aswell.
Maybe you can try that? Or have i misunderstood what you want to do?
Hi David,
Yes, thats the idea. Will give it a go.
Cheers,
Hi David,
Thanks for being awesome and helping out with the answer.
There's more information available in Dynamic Order Properties: Adding Custom Information to Baskets, Orders, and Order Lines.
Hope this helps.
Hi Soren,
I tried this step while the order is in Basket and it works fine.
But when trying to save the dynamic properties after the checkout process, it doesn't works. Please help me.
Thanks in Advance
Hi Saravana,
Where are you calling save? Is it in a pipeline? Please provide a bit more detail.
If you are trying to modify a basket after checkout, please remember you have to get it from the guid.
Kind regards,
Jesper
Hi Jesper,
Thanks for your reply.
Please review the below coding
The "Payment Auth Code" is the dynamic property which is to be saved after the checkout process, but its not saving.
Im pretty sure you are missing a order.Save()
(don't know why the original message was blank)
Thanks a lot Nickolaj,
As you mentioned i have missed order.Save().
Now its working
Good to see that it's working.
Thanks for being awesome and helping find the answer, Nickolaj!
is working on a reply...