public bool SaveProductToWishList(Orders.IPurchasable p, OptionSelectionList selections, int quantity, MerchantTribeApplication app) { WishListItem wi = new WishListItem(); if (p != null) { Orders.PurchasableSnapshot snapshot = p.AsPurchasable(selections, app, true); if (snapshot != null) { wi.ProductId = snapshot.ProductId; wi.Quantity = quantity; wi.SelectionData = snapshot.SelectionData; wi.CustomerId = app.CurrentCustomerId; } } return(WishListItems.Create(wi)); }
// Create or Update public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata) { string data = string.Empty; long id = 0; long.TryParse(FirstParameter(parameters), out id); ApiResponse<WishListItemDTO> response = new ApiResponse<WishListItemDTO>(); WishListItemDTO postedItem = null; try { postedItem = MerchantTribe.Web.Json.ObjectFromJson<WishListItemDTO>(postdata); } catch (Exception ex) { response.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return MerchantTribe.Web.Json.ObjectToJson(response); } WishListItem item = new WishListItem(); item.FromDto(postedItem); if (id < 1) { if (MTApp.CatalogServices.WishListItems.Create(item)) { id = item.Id; } } else { MTApp.CatalogServices.WishListItems.Update(item); } WishListItem resultItem = MTApp.CatalogServices.WishListItems.Find(id); if (resultItem != null) response.Content = resultItem.ToDto(); data = MerchantTribe.Web.Json.ObjectToJson(response); return data; }
public bool SaveProductToWishList(Orders.IPurchasable p, OptionSelectionList selections, int quantity, MerchantTribeApplication app) { WishListItem wi = new WishListItem(); if (p != null) { Orders.PurchasableSnapshot snapshot = p.AsPurchasable(selections, app, true); if (snapshot != null) { wi.ProductId = snapshot.ProductId; wi.Quantity = quantity; wi.SelectionData = snapshot.SelectionData; wi.CustomerId = app.CurrentCustomerId; } } return WishListItems.Create(wi); }
private bool ValidateSelections(Product p, WishListItem item) { bool result = false; if ((p.HasOptions())) { if ((p.HasVariants())) { Variant v = p.Variants.FindBySelectionData(item.SelectionData, p.Options); if ((v != null)) { result = true; } else { return false;//model.ValidationMessage = "<div class=\"flash-message-warning\">The options you've selected aren't available at the moment. Please select different options.</div>"; } } else { result = true; } // Make sure no "labels" are selected if (item.SelectionData.HasLabelsSelected()) { result = false; return false; // model.ValidationMessage = "<div class=\"flash-message-warning\">Please make all selections before adding to cart.</div>"; } } else { result = true; } return result; }