Example #1
0
        /// <summary>
        /// Renders checkout information after sale is done, so gets
        /// everything from invoice. Basket is now empty once again.
        /// </summary>
        /// <param name="invoiceKey"></param>
        /// <returns></returns>
        private ActionResult RenderCompleteInvoiceSummary(Guid invoiceKey)
        {
            var invoice = Services.InvoiceService.GetByKey(invoiceKey);

            var model = new CheckoutViewModel();

            // init objects
            model.CustomerAddress = new AddressModel();
            model.Items = new LineItemCollection();

            var customeraddress = new AddressModel();

            model.CustomerName = invoice.BillToName ?? "";

            customeraddress.Email = invoice.BillToEmail ?? "";
            customeraddress.Address1 = invoice.BillToAddress1 ?? "";
            customeraddress.Locality = invoice.BillToLocality ?? "";
            customeraddress.CountryCode = invoice.BillToCountryCode ?? "";
            customeraddress.PostalCode = invoice.BillToPostalCode ?? "";
            customeraddress.Region = invoice.BillToRegion ?? "";

            model.CustomerAddress = customeraddress;

            //model.PaymentType = invoice.;

            model.Items = invoice.Items;
            model.TotalBasketPrice = invoice.Total;

            return PartialView("CheckoutSummary", model);
        }
        public ActionResult SaveAddress(AddressModel model)
        {
            // Error checking defined in AddressModel
            if (!ModelState.IsValid) return CurrentUmbracoPage();

            if(model.AddressType == AddressType.Custom) throw new InvalidOperationException("We are not handling Custom Address Types in this example");

            // Rosetta extension method "ToAddress()"
            var address = model.ToAddress();

            // Basket has an extension method that handles the "BasketSalesPrepartion" instantiation

            // SalesPrepartionBase is responsible for persisting information needed to facilitate a sale (in this case an order)
            // while we are collecting enough information to create an invoice.
           
            // Addresses are saved to either an AnonymousCustomer (version 1.1.x) or potentially an established
            // customer (assuming they have logged in).  Established, or persisted customers are slated to be introduced
            // in Merchello Version 1.3.0.  No code change will be required here as the "conversion" will be handled in the
            // "CustomerContext"

            if (model.AddressType == AddressType.Shipping)
            {
                Basket.SalePreparation().SaveShipToAddress(address);
            }
            else
            {
                // This workflow never uses this as we combined this call with the select payment information 
                Basket.SalePreparation().SaveBillToAddress(address);
            }

            return RedirectToUmbracoPage(ShipRateQuoteId);
        }
Example #3
0
        public ActionResult SaveAddress(AddressModel model)
        {
            var address = model.ToAddress();

            // address saved to extended data on table merchAnonymousCustomer
            Basket.SalePreparation().SaveBillToAddress(address);
            Basket.SalePreparation().SaveShipToAddress(address);

            // go to payment page - only the cash payment is installed
            return RedirectToUmbracoPage(PaymentInfoId);
        }