Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I'm needing to add a few properties along with a product. They have no price associated with them and aren't nodes in Umbraco with a price, so don't think I can add them as a bundle.
Reading this, i can add properties to an Order https://vendr.net/docs/core/1-2-0/key-concepts/properties/#order-line-system-properties
But not sure how to programmatically add properties to a product/order line?
These product properties are configured on the front end and just needed adding to the product in the basket as reference.
I have so far:
[HttpPost] public ActionResult AddToCart(AddToCartDto postModel) { try { using (var uow = _unitOfWorkProvider.Create()) { var store = CurrentPage.GetStore(); var order = _sessionManager.GetOrCreateCurrentOrder(store.Id) .AsWritable(uow) .AddProduct(postModel.ProductReference, postModel.Quantity); //add product properties to product <----- _orderService.SaveOrder(order); uow.Complete(); } } catch(ValidationException) { ModelState.AddModelError("productReference", "Failed to add product to cart"); return CurrentUmbracoPage(); } TempData["addedProductReference"] = postModel.ProductReference; return RedirectToCurrentUmbracoPage(); }
In TC I think we could add them as hidden inputs, is this still the case in Vendr? Or best to add it via ActionResult form post?
Hi Neil,
There is another AddProduct method that also supports A dictionary of properties to add to the order line.
https://vendr.net/docs/core/1-2-0/reference/vendr-core/orderextensions/#addproduct-3-of-8
Hope this helps
/Matt
Brilliant, thanks Matt!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Can I add custom properties to a Product / Orderline?
Hi
I'm needing to add a few properties along with a product. They have no price associated with them and aren't nodes in Umbraco with a price, so don't think I can add them as a bundle.
Reading this, i can add properties to an Order https://vendr.net/docs/core/1-2-0/key-concepts/properties/#order-line-system-properties
But not sure how to programmatically add properties to a product/order line?
These product properties are configured on the front end and just needed adding to the product in the basket as reference.
I have so far:
In TC I think we could add them as hidden inputs, is this still the case in Vendr? Or best to add it via ActionResult form post?
Hi Neil,
There is another AddProduct method that also supports A dictionary of properties to add to the order line.
https://vendr.net/docs/core/1-2-0/reference/vendr-core/orderextensions/#addproduct-3-of-8
Hope this helps
/Matt
Brilliant, thanks Matt!
is working on a reply...