Esempio n. 1
0
        public void ForwardToCheckout(CartViewModel model)
        {
            if (Request["paypalexpress"] != null && Request["paypalexpress"] == "true")
            {
                ForwardToPayPalExpress(model);
            }

            OrderTaskContext c = new OrderTaskContext(MTApp);
            c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
            c.Order = model.CurrentOrder;
            if (Workflow.RunByName(c, WorkflowNames.CheckoutSelected))
            {
                Response.Redirect(MTApp.StoreUrl(true, false) + "checkout");
            }
            else
            {
                bool customerMessageFound = false;
                foreach (WorkflowMessage msg in c.Errors)
                {
                    EventLog.LogEvent(msg.Name, msg.Description, EventLogSeverity.Error);
                    if (msg.CustomerVisible)
                    {
                        customerMessageFound = true;
                        this.FlashFailure(msg.Description);
                    }
                }
                if (!customerMessageFound)
                {
                    EventLog.LogEvent("Checkout Selected Workflow", "Checkout failed but no errors were recorded.", EventLogSeverity.Error);
                    this.FlashFailure("Checkout Failed. If problem continues, please contact customer support.");
                }
            }
        }
Esempio n. 2
0
 private void LoadButtonImages(CartViewModel model)
 {
     ThemeManager tm = MTApp.ThemeManager();
     model.KeepShoppingButtonUrl = tm.ButtonUrl("keepshopping", Request.IsSecureConnection);
     model.CheckoutButtonUrl = tm.ButtonUrl("securecheckout", Request.IsSecureConnection);
     model.AddCouponButtonUrl = tm.ButtonUrl("new", Request.IsSecureConnection);
     model.DeleteButtonUrl = tm.ButtonUrl("x", Request.IsSecureConnection);
     model.EstimateShippingButtonUrl = tm.ButtonUrl("estimateshipping", Request.IsSecureConnection);
 }
Esempio n. 3
0
        private CartViewModel IndexSetup()
        {
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.ShoppingCart);
            ViewBag.BodyClass = "store-cart-page";

            CartViewModel model = new CartViewModel();
            LoadButtonImages(model);
            model.KeepShoppingUrl = GetKeepShoppingLocation();
            SetPayPalVisibility(model);
            return model;
        }
Esempio n. 4
0
        private void SetPayPalVisibility(CartViewModel model)
        {
            AvailablePayments availablePayments = new AvailablePayments();
            Collection<DisplayPaymentMethod> enabledMethods;
            enabledMethods = availablePayments.EnabledMethods(MTApp.CurrentStore);

            model.PayPalExpressAvailable = false;
            foreach (DisplayPaymentMethod m in enabledMethods)
            {
                switch (m.MethodId)
                {
                    case WebAppSettings.PaymentIdPaypalExpress:
                        model.PayPalExpressAvailable = true;
                        break;
                    default:
                        // do nothing
                        break;
                }
            }
        }
Esempio n. 5
0
        private void LoadCart(CartViewModel model)
        {
            Order Basket = SessionManager.CurrentShoppingCart(MTApp.OrderServices, MTApp.CurrentStore);
            if (Basket == null) return;
            model.CurrentOrder = Basket;

            if ((Basket.Items == null) || ((Basket.Items != null) && (Basket.Items.Count <= 0)))
            {
                model.CartEmpty = true;
                return;
            }

            foreach (LineItem li in model.CurrentOrder.Items)
            {
                CartLineItemViewModel ci = new CartLineItemViewModel();
                ci.Item = li;

                Product associatedProduct = li.GetAssociatedProduct(MTApp);
                if (associatedProduct != null)
                {
                    ci.ShowImage = true;
                    ci.ImageUrl = MerchantTribe.Commerce.Storage
                                  .DiskStorage.ProductVariantImageUrlMedium(
                                  MTApp, li.ProductId,
                                  associatedProduct.ImageFileSmall,
                                  li.VariantId, Request.IsSecureConnection);

                    ci.LinkUrl = UrlRewriter.BuildUrlForProduct(associatedProduct,
                                   MTApp.CurrentRequestContext.RoutingContext,
                                   "OrderBvin=" + li.OrderBvin + "&LineItemId=" + li.Id);
                }

                if (li.LineTotal != li.LineTotalWithoutDiscounts)
                {
                    ci.HasDiscounts = true;
                }

                model.LineItems.Add(ci);
            }
        }
Esempio n. 6
0
 private bool CheckForStockOnItems(CartViewModel model)
 {
     Order Basket = model.CurrentOrder;
     SystemOperationResult result = MTApp.CheckForStockOnItems(Basket);
     if (result.Success)
     {
         return true;
     }
     else
     {
         this.FlashFailure(result.Message);
         return false;
     }
 }
Esempio n. 7
0
        public void ForwardToPayPalExpress(CartViewModel model)
        {
            Order Basket = model.CurrentOrder;
            // Save as Order
            MerchantTribe.Commerce.BusinessRules.OrderTaskContext c
                = new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp);
            c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
            c.Order = Basket;
            bool checkoutFailed = false;
            if (!MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.CheckoutSelected))
            {
                checkoutFailed = true;
                bool customerMessageFound = false;
                foreach (MerchantTribe.Commerce.BusinessRules.WorkflowMessage msg in c.Errors)
                {
                    EventLog.LogEvent(msg.Name, msg.Description, EventLogSeverity.Error);
                    if (msg.CustomerVisible)
                    {
                        customerMessageFound = true;
                        FlashWarning(msg.Description);
                    }
                }
                if (!customerMessageFound)
                {
                    EventLog.LogEvent("Checkout Selected Workflow", "Checkout failed but no errors were recorded.", EventLogSeverity.Error);
                    FlashWarning("Checkout Failed. If problem continues, please contact customer support.");
                }
            }

            if (!checkoutFailed)
            {
                c.Inputs.Add("bvsoftware", "Mode", "PaypalExpress");
                if (!MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ThirdPartyCheckoutSelected))
                {
                    bool customerMessageFound = false;
                    EventLog.LogEvent("Paypal Express Checkout Failed", "Specific Errors to follow", EventLogSeverity.Error);
                    foreach (MerchantTribe.Commerce.BusinessRules.WorkflowMessage item in c.Errors)
                    {
                        EventLog.LogEvent("Paypal Express Checkout Failed", item.Name + ": " + item.Description, EventLogSeverity.Error);
                        if (item.CustomerVisible)
                        {
                            FlashWarning(item.Description);
                            customerMessageFound = true;
                        }
                    }
                    if (!customerMessageFound)
                    {
                        FlashWarning("Paypal Express Checkout Failed. If this problem persists please notify customer support.");
                    }
                }
            }
        }