public class AddToBasket { public int? CatalogId { get; set; } public int Quantity { get; set; } public string Sku { get; set; } public string VariantSku { get; set; } public bool AddToExistingLine { get; set; } public string Name { get; set; } }
public class AddToBasketResponse : IHasResponseStatus { public ResponseStatus ResponseStatus { get; set; } }
public class AddToBasketService : ServiceBase<AddToBasket> { protected override object Run(AddToBasket request) { TransactionLibrary.AddToBasket(request.Quantity, request.Sku, request.VariantSku, request.AddToExistingLine, true, request.CatalogId); TransactionLibrary.GetBasket().PurchaseOrder["Name"] = request.Name; TransactionLibrary.GetBasket().PurchaseOrder.Save(); return new AddToBasketResponse(); } }
Adding dynamic properties to each orderline through Javascript
I have created a new service as shown http://our.umbraco.org/projects/website-utilities/ucommerce/ucommerce-support/40250-Adding-dynamic-properties-via-javascript ; but I want to add a property on each orderline. I am not able to get hold of the current orderline object after creation with in this service class. Can you help?
Following is the code
public class AddToBasket
{
public int? CatalogId { get; set; }
public int Quantity { get; set; }
public string Sku { get; set; }
public string VariantSku { get; set; }
public bool AddToExistingLine { get; set; }
public string Name { get; set; }
}
public class AddToBasketResponse : IHasResponseStatus
{
public ResponseStatus ResponseStatus { get; set; }
}
public class AddToBasketService : ServiceBase<AddToBasket>
{
protected override object Run(AddToBasket request)
{
TransactionLibrary.AddToBasket(request.Quantity, request.Sku, request.VariantSku, request.AddToExistingLine, true, request.CatalogId);
TransactionLibrary.GetBasket().PurchaseOrder["Name"] = request.Name;
TransactionLibrary.GetBasket().PurchaseOrder.Save();
return new AddToBasketResponse();
}
}
You can get the internal implementation of AddToBasket by:
ObjectFactory.Instance.Resolve<TransactionLibraryInternal>(); that will return the orderLine in addToBasket.
Thanks Morten - I will give it a try.
Any luck getting this resolved?
Sorry for writing back so late been very busy on another project.
Yes it has been resolved using your code :)
Thanks
Awsome sauce :)
is working on a reply...