public IHttpActionResult UpdateLineItem([FromBody] UpdateLineItemRequest request) { TransactionLibrary.UpdateLineItem(request.OrderLineId, request.NewQuantity); TransactionLibrary.ExecuteBasketPipeline(); var orderLine = TransactionLibrary.GetBasket().PurchaseOrder.OrderLines.First(l => l.OrderLineId == request.OrderLineId); var currency = SiteContext.Current.CatalogContext.CurrentCatalog.PriceGroup.Currency; var lineTotal = new Money(orderLine.Total.GetValueOrDefault(), currency); var updatedLine = new LineItem() { OrderLineId = orderLine.OrderLineId, Quantity = orderLine.Quantity, Sku = orderLine.Sku, VariantSku = orderLine.VariantSku, Price = orderLine.Price, ProductName = orderLine.ProductName, Total = orderLine.Total, FormattedTotal = lineTotal.ToString(), UnitDiscount = orderLine.UnitDiscount, VAT = orderLine.VAT, VATRate = orderLine.VATRate }; return(Json(updatedLine)); }
protected void RemoveOrderLineButton_OnClick(object sender, EventArgs e) { var orderlineId = Convert.ToInt32((sender as Button).Attributes["Value"]); TransactionLibrary.UpdateLineItem(orderlineId, 0); UCommerce.Api.TransactionLibrary.ExecuteBasketPipeline(); }
public IHttpActionResult UpdateLineItem(UpdateLineItemDTO model) { TransactionLibrary.UpdateLineItem(model.OrderlineId, model.NewQuantity); TransactionLibrary.ExecuteBasketPipeline(); return(Json(this.GetBasketModel())); }
protected override object Run(UpdateLineItem request) { TransactionLibrary.UpdateLineItem(request.OrderLineId, request.NewQuantity); TransactionLibrary.ExecuteBasketPipeline(); var newLine = TransactionLibrary.GetBasket().PurchaseOrder.OrderLines.FirstOrDefault(l => l.OrderLineId == request.OrderLineId); return(new UpdateLineItemResponse(newLine)); }
public static bool?UpdateCartLine(string lineNumberString, string quantityString) { var basket = TransactionLibrary.GetBasket().PurchaseOrder; int lineNumber = 0; int quantity = 0; if (!Int32.TryParse(lineNumberString, out lineNumber) || !Int32.TryParse(quantityString, out quantity)) { //if we cant parse the input to ints, we cant go on return(false); } var listOfOrderLineIds = basket.OrderLines.Select(x => x.OrderLineId).ToList(); var currentOrderLineId = listOfOrderLineIds[lineNumber]; TransactionLibrary.UpdateLineItem(currentOrderLineId, quantity); TransactionLibrary.ExecuteBasketPipeline(); return(true); }
public ActionResult Index(PurchaseOrderViewModel model) { foreach (var orderLine in model.OrderLines) { var newQuantity = orderLine.Quantity; if (model.RemoveOrderlineId == orderLine.OrderLineId) { newQuantity = 0; } TransactionLibrary.UpdateLineItem(orderLine.OrderLineId, newQuantity); } TransactionLibrary.ExecuteBasketPipeline(); var shop = model.Content.AncestorsOrSelf().FirstOrDefault(x => x.DocumentTypeAlias.Equals("home")); var basket = shop.DescendantsOrSelf().FirstOrDefault(x => x.DocumentTypeAlias.Equals("basket")); return(Redirect(basket.Url)); }
public bool RemoveCartItem(int CartLineItem) { TransactionLibrary.UpdateLineItem(CartLineItem, 0); return(true); }