Copied to clipboard

Flag this post as spam?

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


  • Dave Jonker 22 posts 72 karma points
    May 27, 2024 @ 12:21
    Dave Jonker
    0

    Error in Commerce when adding product

    Hi Everyone,

    I have a question about Commerce. I'm creating a composed "product" as a bundle for my cart. For example:

    • Color: Red
    • Printarea: Front
    • T-shirt A - size XS - Qty: 5
    • T-shirt A - size S - Qty: 10
    • T-shirt A - size M - Qty: 5
    • Printmethod: Digital print etc.

       public IActionResult AddToCart(AddToCartDto postModel) {
         _umbracoCommerceApi.Uow.Execute(uow => {
           var store = CurrentPage.GetStore();
           var order = _cartService.GetOrCreateCurrentOrder(store.Id).AsWritable(uow);
           order.SetProperty("shopCustomerId", postModel.ShopCustomerId);
           var bundleId = DateTime.Now.Ticks.ToString();
           Dictionary<string, string> props = new Dictionary<string, string> {
               { "color", color },
               <<snip>>
               { "expectedDeliveryDate", Convert.ToString(postModel.expectedDeliveryDate) }
           };
           order.AddProduct(postModel.ProductReference, 1, props, bundleId);
           <<snip>>
           _umbracoCommerceApi.SaveOrder(order);
           uow.Complete();
        });
      }
      

    But I keep getting the following error on the AddToCart line: "Can't add a Product to an Order where there is no price for the Order currency"

    What am I doing wrong here? Can anyone help me out here?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies