Ejemplo n.º 1
0
        public ActionResult CalculateShipping(string postalCode)
        {
            postalCode = postalCode.ToUpper().Replace(" ", "");
            // Get the shipping type
            Enums.ShippingType shippingType = ShippingService.GetShippingTypeByPostalCode(postalCode);


            // TODO : Rate the shipping depending on the products
            // If we are a guest on the site use cookies for the shopping cart
            if (!UserService.IsUserConnected(System.Web.HttpContext.Current.User))
            {
            }
            else // We are connected with a user account
            {
            }

            CanadaPost.CanadaPostRates rates = new CanadaPost.CanadaPostRates();
            double price = rates.GetRates(postalCode, shippingType);

            return(Json(new { price, error = price == 0 ? "The postal code must be valid" : null }, JsonRequestBehavior.AllowGet));
        }