Is there a way to add properties to an order dynamically.
I want dynamically properties on a order because i'm trying to create a store that sells language courses.
Lets say a customer wants a language course for himself and two colleagues, so before the customer adds to cart i need some information about the course participants (email, name, phone number etc.)
I have solved how to add these dynamic properties to the order. And i can show them fine in my UI. But they are not showing in the Order overview in Umbraco.
One solution is maybe to add 3 properties to the order (ParticipantName1, ParticipantName2 and Participant3 and so on) But what if a new customer the next day wants 10 partipants, i could hard code 10 participant properties, and they add these 10 hardcoded property key names to the order.editor.config.js, but is there a way to do this dynamically?
And what if a customer wants 11 partipants instead.
We’ve done something similar, and our solution was just to create every participant signup as an individual orderline.
So if a customer buys a course for 10 people, we create 10 orderlines, and store the information for the individual participant on the individual orderline, which then easily can be shown in the backoffice.
Don’t know if this is right for your use case, but let me know if I can help with more details.
It sounds a lot like it could be right for my use case.
But how is the code structured to archive multiple orderlines per order?
I have a AddToCart method where i'm creating a order, and adding products to this order. But if i try to add the same product it still counts as one orderline. So can i explicit create an orderline every time i add a product to cart?
Is there a AddOrderline method?
Dynamically add properties to order
Hi.
Is there a way to add properties to an order dynamically.
I want dynamically properties on a order because i'm trying to create a store that sells language courses. Lets say a customer wants a language course for himself and two colleagues, so before the customer adds to cart i need some information about the course participants (email, name, phone number etc.)
I have solved how to add these dynamic properties to the order. And i can show them fine in my UI. But they are not showing in the Order overview in Umbraco.
One solution is maybe to add 3 properties to the order (ParticipantName1, ParticipantName2 and Participant3 and so on) But what if a new customer the next day wants 10 partipants, i could hard code 10 participant properties, and they add these 10 hardcoded property key names to the order.editor.config.js, but is there a way to do this dynamically? And what if a customer wants 11 partipants instead.
Hey Daniel,
Good question.
We do actually fire an event when parsing the order editor config JSON that allows you to manipulate the parsed JSON
There is a good example of this in the Vendr checkout code here https://github.com/vendrhub/vendr-checkout/blob/v2/dev/src/Vendr.Checkout/Web/Events/Notification/Handlers/VendrCheckoutOrderEditorConfigParsingNotificationHandler.cs
In that example we auto hide shipping details but you could inject your dynamic properties
Hope this helps
Matt
Hi Daniel
We’ve done something similar, and our solution was just to create every participant signup as an individual orderline.
So if a customer buys a course for 10 people, we create 10 orderlines, and store the information for the individual participant on the individual orderline, which then easily can be shown in the backoffice.
Don’t know if this is right for your use case, but let me know if I can help with more details.
Hi Michael.
It sounds a lot like it could be right for my use case.
But how is the code structured to archive multiple orderlines per order?
I have a AddToCart method where i'm creating a order, and adding products to this order. But if i try to add the same product it still counts as one orderline. So can i explicit create an orderline every time i add a product to cart? Is there a AddOrderline method?
Hey Daniel,
What you need to look into is “Product Uniqueness Properties” https://vendr.net/docs/core/2.1.0/umbraco-v9/key-concepts/properties/#product-uniqueness-properties
With this, you can configure Vendr to generate distinct order lines when specific properties have unique values.
Hi Matt.
Just tried with Product Uniqueness Properties, And it solved my problem.
Thanks for the fast replies, both of you
Awesome
Glad we could help 👍
is working on a reply...