コード例 #1
0
        public IHttpActionResult Add(AddToBasketDTO model)
        {
            string variantSku = null;
            var    product    = CatalogLibrary.GetProduct(model.Sku);

            if (model.Variants == null || !model.Variants.Any())
            {
                var variant = product.Variants.FirstOrDefault();

                if (variant != null)
                {
                    variantSku = variant.VariantSku;
                }
            }
            else
            {
                var variants = product.Variants.AsEnumerable();

                foreach (var v in model.Variants)
                {
                    variants = variants.Where(pv => pv.ProductProperties.Any(pp => pp.Value == v.Value));
                }

                var variant = variants.FirstOrDefault();
                if (variant != null)
                {
                    variantSku = variant.VariantSku;
                }
            }

            TransactionLibrary.AddToBasket(model.Quantity, model.Sku, variantSku);
            return(Json(this.GetBasketModel()));
        }
        public ActionResult Index(AddToBasketViewModel model)
        {
            string variant = GetVariantFromPostData(model.Sku, "variation-");

            TransactionLibrary.AddToBasket(1, model.Sku, variant);

            return(RenderView(true));
        }
コード例 #3
0
        public void btnAddToBasket_Click(object sender, EventArgs e)
        {
            var variant = GetVariantFromPostData(SiteContext.Current.CatalogContext.CurrentProduct, "variation-");

            if (variant == null)
            {
                Response.Redirect(Request.RawUrl);
            }

            TransactionLibrary.AddToBasket(1, variant.Sku, variant.VariantSku);
            Response.Redirect(Request.RawUrl);
        }
コード例 #4
0
 public void AddToCart(String Sku)
 {
     TransactionLibrary.AddToBasket(1, Sku);
 }
コード例 #5
0
 public IHttpActionResult AddToBasket([FromBody] AddToBasketRequet request)
 {
     TransactionLibrary.AddToBasket(request.Quantity, request.Sku, request.VariantSku, addToExistingLine: true, executeBasketPipeline: true);
     return(Ok());
 }
コード例 #6
0
 protected override object Run(AddToBasket request)
 {
     TransactionLibrary.AddToBasket(request.Quantity, request.Sku, request.VariantSku, addToExistingLine: true, executeBasketPipeline: true);
     return(new AddToBasketResponse());
 }
コード例 #7
0
ファイル: Product.aspx.cs プロジェクト: ayush126gupta/tavant
 protected void AddToBasketButton_OnClick(object sender, EventArgs e)
 {
     string    sku        = HiddenSku.Value;
     string    variantSku = Request.Form["VariantSku"];
     OrderLine orderline  = TransactionLibrary.AddToBasket(1, sku, variantSku);
 }
コード例 #8
0
 public AddToBasketResponse Post(AddToBasket request)
 {
     TransactionLibrary.AddToBasket(request.Quantity, request.Sku, request.VariantSku, addToExistingLine: true, executeBasketPipeline: true);
     return(new AddToBasketResponse());
 }