I need to add a the same product to a bundle several times inside a loop with each order line having it's own unique set of properties. I expected each iteration to create a unique order line but it's actually merging lines with the same variant reference, and so we're losing the properties that make each order line unique.
I guess what I need is for properties to be considered part of what makes an order line unique. Is that possible?
Here's the code for info:
foreach (var date in model.Dates)
{
// The pricing varies depending on the duration of the service
var productVariant = product.Variants.FindByAttributes(new Dictionary<string, string>
{
{ Constants.BabySittingService.HoursAttributeAlias, date.NumberOfHours }
});
// Expected this to create a new order line each time, but it's actually merging them when the productVariantReference already exists inside the bundle
order.AddProductToBundle(model.BundleId, model.BundleId, productVariant.Content.GetProductReference(), numberOfChildren,
new Dictionary<string, string>
{
{ Constants.BabySittingService.DatePropertyAlias, date.Date },
{ Constants.BabySittingService.StartPropertyAlias, date.Start }
});
}
Ultimately you need to tell Vendr a specific property on the order line that should be considered "unique" and then Vendr will treat each order line that has a distinct value as unique order lines.
Order lines are being merged inside a bundle
Hi Matt,
I need to add a the same product to a bundle several times inside a loop with each order line having it's own unique set of properties. I expected each iteration to create a unique order line but it's actually merging lines with the same variant reference, and so we're losing the properties that make each order line unique.
I guess what I need is for properties to be considered part of what makes an order line unique. Is that possible?
Here's the code for info:
Hi Philip,
Yup this is possible. You'll want to review the docs on "Product Uniqueness Properties" here https://vendr.net/docs/core/2.1.0/umbraco-v9/key-concepts/properties/#product-uniqueness-properties.
Ultimately you need to tell Vendr a specific property on the order line that should be considered "unique" and then Vendr will treat each order line that has a distinct value as unique order lines.
Hope this helps
Matt
Brilliant! I knew there'd be a way of doing it. Thanks so much for the quick reply 🙏🏻
is working on a reply...