Copied to clipboard

Flag this post as spam?

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

  • Neil Hodges 286 posts 861 karma points
    Aug 06, 2020 @ 10:53
    Neil Hodges

    Can I add custom properties to a Product / Orderline?


    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

    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:

        public ActionResult AddToCart(AddToCartDto postModel)
                using (var uow = _unitOfWorkProvider.Create())
                    var store = CurrentPage.GetStore();
                    var order = _sessionManager.GetOrCreateCurrentOrder(store.Id)
                        .AddProduct(postModel.ProductReference, postModel.Quantity);
                    //add product properties to product <-----
                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?

  • Matt Brailsford 2765 posts 14046 karma points MVP 7x c-trib
    Aug 06, 2020 @ 12:04
    Matt Brailsford

    Hi Neil,

    There is another AddProduct method that also supports A dictionary of properties to add to the order line.

    Hope this helps


  • Neil Hodges 286 posts 861 karma points
    Aug 06, 2020 @ 12:49
    Neil Hodges

    Brilliant, thanks Matt!

Please Sign in or register to post replies

Write your reply to: