Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel Nielsen 17 posts 102 karma points notactivated
    Jun 16, 2022 @ 12:44
    Daniel Nielsen
    0

    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.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 16, 2022 @ 14:02
    Matt Brailsford
    0

    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

  • Michael Nielsen 154 posts 811 karma points
    Jun 16, 2022 @ 14:39
    Michael Nielsen
    1

    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.

  • Daniel Nielsen 17 posts 102 karma points notactivated
    Jun 17, 2022 @ 07:36
    Daniel Nielsen
    0

    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?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 17, 2022 @ 07:42
    Matt Brailsford
    0

    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.

  • Daniel Nielsen 17 posts 102 karma points notactivated
    Jun 17, 2022 @ 09:11
    Daniel Nielsen
    1

    Hi Matt.

    Just tried with Product Uniqueness Properties, And it solved my problem.

    Thanks for the fast replies, both of you

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 20, 2022 @ 07:34
    Matt Brailsford
    0

    Awesome

    Glad we could help 👍

Please Sign in or register to post replies

Write your reply to:

Draft