public ActionResult AddToBasket(AddItemModel model) { // This is an example of using the ExtendedDataCollection to add some custom functionality. // In this case, we are creating a direct reference to the content (Product Detail Page) so // that we can provide a link, thumbnail and description in the cart per this design. In other // designs, there may not be thumbnails or descriptions and the link could be to a completely // different website. var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); var product = this.MerchelloServices.ProductService.GetByKey(model.Product.Key); // In the event the product has options we want to add the "variant" to the basket. // -- If a product that has variants is defined, the FIRST variant will be added to the cart. // -- This was done so that we did not have to throw an error since the Master variant is no // -- longer valid for sale. if (model.OptionChoices != null && model.OptionChoices.Any()) { var variant = this.MerchelloServices.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices); this.Basket.AddItem(variant, variant.Name, 1, extendedData); } else { this.Basket.AddItem(product, product.Name, 1, extendedData); } this.Basket.Save(); return this.RedirectToUmbracoPage(model.BasketPageId); }
public ActionResult RenderAddToBasket(ProductModel model) { var addItemModel = new AddItemModel() { Product = model.ProductData, ContentId = model.Id, BasketPageId = BazaarContentHelper.GetBasketContent().Id, ShowWishList = model.ShowWishList, WishListPageId = BazaarContentHelper.GetWishListContent().Id, Currency = model.Currency }; return RenderAddItem(addItemModel); }
public ActionResult AddToBasket(AddItemModel model) { // This is an example of using the ExtendedDataCollection to add some custom functionality. // In this case, we are creating a direct reference to the content (Product Detail Page) so // that we can provide a link, thumbnail and description in the cart per this design. In other // designs, there may not be thumbnails or descriptions and the link could be to a completely // different website. var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); // NEW IN 1.9.1 // We've added some data modifiers that can handle such things as including taxes in product // pricing. The data modifiers can either get executed when the item is added to the basket or // as a result from a MerchelloHelper query - you just don't want them to execute twice. // Calls directly to the ProductService are not modified // var product = this.MerchelloServices.ProductService.GetByKey(model.Product.Key); // Calls to using the MerchelloHelper WILL be modified // var merchello = new MerchelloHelper(); // // if you want to do this you should tell the basket not to modify the data again when adding the item //this.Basket.EnableDataModifiers = false; // In this case we want to get the product without any data modification var merchello = new MerchelloHelper(false); var product = merchello.Query.Product.GetByKey(model.Product.Key); // In the event the product has options we want to add the "variant" to the basket. // -- If a product that has variants is defined, the FIRST variant will be added to the cart. // -- This was done so that we did not have to throw an error since the Master variant is no // -- longer valid for sale. if (model.OptionChoices != null && model.OptionChoices.Any()) { // NEW in 1.9.1 // ProductDisplay and ProductVariantDisplay classes can be added directly to the Basket // so you don't have to query the service. var variant = product.GetProductVariantDisplayWithAttributes(model.OptionChoices); this.Basket.AddItem(variant, variant.Name, 1, extendedData); } else { this.Basket.AddItem(product, product.Name, 1, extendedData); } this.Basket.Save(); return this.RedirectToUmbracoPage(model.BasketPageId); }
public ActionResult AddToWishList(AddItemModel model) { var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); var product = this.MerchelloServices.ProductService.GetByKey(model.Product.Key); if (model.OptionChoices != null && model.OptionChoices.Any()) { var variant = this.MerchelloServices.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices); _wishList.AddItem(variant, variant.Name, 1, extendedData); } else { _wishList.AddItem(product, product.Name, 1, extendedData); } _wishList.Save(); return this.RedirectToUmbracoPage(model.WishListPageId); }
public ActionResult RenderAddItem(AddItemModel model) { var theme = BazaarContentHelper.GetStoreTheme(); return this.PartialView(PathHelper.GetThemePartialViewPath(theme, "AddToCart"), model); }
public ActionResult RenderAddToBasket(ProductModel model) { var addItemModel = new AddItemModel() { Product = model.ProductData, ContentId = model.Id, BasketPageId = model.BasketPage.Id, ShowWishList = model.ShowWishList, WishListPageId = model.WishListPage.Id, Currency = model.Currency }; return this.PartialView(model.ThemePartialViewPath("AddToCart"), addItemModel); }