private void AddToppingOnMenuItemWithPosition(int menuId, int subMenuId, int toppingId, string toppingPos, ref BxCartItem item) { if (item == null) return; BxDealItem dealItem = item.Product; if (dealItem == null) return; BxMenuItem menuItemToAddToppingOn = null; for (int index = 0; index < dealItem.Items.Count; index++) { BxMenuItem mnuItem = dealItem.Items[index] as BxMenuItem; if (mnuItem == null) continue; if (mnuItem.ID == menuId) { menuItemToAddToppingOn = mnuItem; break; } } //var menuItemToAddToppingOn = item.Product.GetMenuItem(menuId); if (menuItemToAddToppingOn == null) return; if (toppingId != 0) { var isExcluding = toppingId < 0; var topping = new MenuTopping(menuId,subMenuId, Math.Abs(toppingId)); topping.Load(IsDeliveryOrder); if (!string.IsNullOrWhiteSpace(topping.Name) && !menuItemToAddToppingOn.Contains(topping)) { if (isExcluding) { topping.Name = "NO " + topping.Name; topping.UnitPrice = 0; } else { if (toppingPos.ToLower() == "left") { topping.Name = "LEFT " + topping.Name; } else { if (toppingPos.ToLower() == "right") { topping.Name = "RIGHT " + topping.Name; } } } menuItemToAddToppingOn.Items.Add(topping); } } }
public string AddItemWithOptions(int dealId, int menuId, int subMenuId, int optionId) { //Look up cart-item that has the same IDs given BxCartItem cartItem = FindCartItemByIDs(dealId, menuId); if (cartItem == null) { var newItem = new BxCartItem(dealId, menuId, subMenuId, 0, 0); newItem.Load(IsDeliveryOrder); newItem.Quantity = 1; Items.Add(newItem); Message = "An item has been added to your basket!"; cartItem = newItem; } AddItemWithOptions(menuId, optionId, ref cartItem); return cartItem.CartId; }
public void AddItemWithOptions(int menuId, int optionId, ref BxCartItem cartItem) { if (cartItem == null || optionId <= 0) return; var menuItemToAddOptionsOn = cartItem.Product.GetMenuItem(menuId); if (menuItemToAddOptionsOn == null) { AddMenuItemOnToExistedDeal(cartItem.CartId, menuId, 0); menuItemToAddOptionsOn = cartItem.Product.GetMenuItem(menuId); } var optDetail = new MenuOption(menuId, optionId); optDetail.Load(IsDeliveryOrder); // Check the limitation of number of items to be added IsErrorMessage = false; int allowedItems = optDetail.GetAllowedItems(optDetail.ParentId); if ((allowedItems != 0)) { if (menuItemToAddOptionsOn.CountOfMenuOptions(optDetail.ParentId) == allowedItems) { IsErrorMessage = true; Message = "You can add only " + allowedItems + " options to this item"; return; } } if (!menuItemToAddOptionsOn.Contains(optDetail)) { //cartItem.Product.Items.Add(optDetail); menuItemToAddOptionsOn.Items.Add(optDetail); Message = "An item has been added to your basket!"; } }
public string AddItem(int dealId, int menuId, int subMenuId) { // Check to see if there is already item created for the deal BxCartItem existedItem = null; if (dealId > 0 && Items != null && Items.Count > 0) { for (int index = 0; index < Items.Count; index++) { if (Items[index].DealID == dealId) { existedItem = Items[index]; break; } } } // Add the menu item to the deal if (existedItem != null) { AddMenuItemOnToExistedDeal(existedItem.CartId, menuId, subMenuId); return existedItem.CartId; } var newItem = new BxCartItem(dealId, menuId, subMenuId, 0, 0); newItem.Load(IsDeliveryOrder); newItem.Quantity = 1; if (Items == null) Items = new List<BxCartItem>(); Items.Add(newItem); Message = "An item has been added to your basket!"; return newItem.CartId; }