Skip to content

Can't update order line properties #777

@orangejuice-martin

Description

@orangejuice-martin

Which component is this issue related to?

Umbraco Commerce (Core)

Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)

13.2.4

Bug summary

I want to update the order line properties but I keep getting an exception that the order line is read only. I can change the quantity however.

I did use a CustomProduct that implements the ISnapshot interface to add a custom product to the basket.

Specifics

Code snippet to update a order line

 _commerceApi.Uow.Execute(uow =>
 {
     var order = _commerceApi.GetCurrentOrder(Store.Id)
                             .AsWritable(uow);
     var orderLine = order.WithOrderLine(basketLineId);
     orderLine.SetQuantity(quantity);
     orderLine.SetProperties(properties,
                             SetBehavior.Replace);

     _commerceApi.SaveOrder(order);

     uow.Complete();
 });

The exception is:

Umbraco.Commerce.Common.Validation.ValidationException: 'Can't set order line property with alias 'CutoutWidth' as the property is read only.'

Steps to reproduce

Used a custom product with a custom product adapter.

public class CustomProductPlate : IProductSnapshot
{

    #region properties

    public int Id { get; }

    public string ProductReference { get; }

    public string Sku { get; }

    public Guid StoreId { get; }

    public IEnumerable<ProductPrice> Prices { get; }

    public IDictionary<string, string> Properties { get; }

    public string Name { get; }

    public string Description { get; }

    public string ImageUrl { get; }

    public Guid? TaxClassId { get; }

    public bool IsGiftCard { get; }

    public string ProductVariantReference { get; }

    public IEnumerable<AttributeCombination> Attributes { get; }

    #endregion

    #region constructor

    public CustomProductPlate(int id, Guid key, string name, string description, string sku, string imageUrl, string productVariantReference,
                         bool isGiftCard, Guid storeId, Guid? taxClassId, IEnumerable<ProductPrice> prices,
                         IEnumerable<AttributeCombination> attributes, IDictionary<string, string> properties)
    {
        ProductReference = key.ToString();
        Id = id;
        Name = name;
        Description = description;
        Sku = sku;
        StoreId = storeId;
        Prices = prices;
        ImageUrl = imageUrl;
        TaxClassId = taxClassId;
        IsGiftCard = isGiftCard;
        Properties = properties;
        Attributes = attributes;
        ProductVariantReference = productVariantReference;
    }

#endregion   

}

Expected result / actual result

That the order line properties are updated to the new dictionary values.

Dependencies

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions