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 = Services.ProductService.GetByKey(model.ProductKey); // 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 = Services.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices); Basket.AddItem(variant, variant.Name, 1, extendedData); } else { Basket.AddItem(product, product.Name, 1, extendedData); } Basket.Save(); return RedirectToUmbracoPage(GetContentIdByContentName(BasketPage)); }
public ActionResult RenderAddToCart(ProductDisplay product) { var contentId = UmbracoContext.PageId != null ? UmbracoContext.PageId.Value : 0; var model = new AddItemModel() { ProductKey = product.Key, ContentId = contentId }; return PartialView("RosettaAddToCart", model); }
public ActionResult AddToBasket(AddItemModel model) { // Add to Logical Basket // add Umbraco content id to Merchello Product extended properties var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); // get Merchello product var product = Services.ProductService.GetByKey(model.ProductKey); // add a single item of the Product to the logical Basket Basket.AddItem(product, product.Name, 1, extendedData); // Save to Database tables: merchItemCache, merchItemCacheItem Basket.Save(); return RedirectToUmbracoPage(BasketContentId); }
//<summary> //Renders the BuyButton form which is a partial view //</summary> //<param name="product"> //</param> //<returns></returns> public ActionResult Display_BuyButton(AddItemModel product) { return PartialView("BuyButton", product); }
public ActionResult AddToBasket(AddItemModel model) { return RedirectToUmbracoPage(BasketContentId); }