Exemple #1
0
        /// <summary>
        /// Get all shipping providers for current order
        /// </summary>
        /// <returns></returns>
        public static XPathNavigator GetAllShippingProvidersForCurrentOrder()
        {
            var currentOrderInfo = OrderHelper.GetOrder();
            var doc = new XmlDocument();

            if (currentOrderInfo == null)
            {
                return(doc.CreateNavigator());
            }

            var shippingProviderforOrderList = ShippingProviderHelper.GetShippingProvidersForOrder(currentOrderInfo);

            var stream1 = new MemoryStream();

            //Serialize the Record object to a memory stream using DataContractSerializer.
            var serializer = new DataContractSerializer(typeof(List <ShippingProvider>), "ShippingProviders", "");

            serializer.WriteObject(stream1, shippingProviderforOrderList);
            stream1.Position = 0;

            var result = new StreamReader(stream1).ReadToEnd();

            doc.LoadXml(result);

            return(doc.CreateNavigator());
        }
Exemple #2
0
        /// <summary>
        /// Gets the fulfillment providers. (ie shipping/pickup/etc)
        /// </summary>
        /// <param name="useZone">if set to <c>true</c> use zone/countries.</param>
        /// <param name="storeAlias">The store alias.</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <returns></returns>
        public static IEnumerable <IFulfillmentProvider> GetFulfillmentProviders(bool useZone = true, string storeAlias = null, string currencyCode = null)
        {
            var localization = StoreHelper.GetLocalizationOrCurrent(storeAlias, currencyCode);
            var inclVat      = IO.Container.Resolve <ISettingsService>().IncludingVat;
            var currentOrder = OrderHelper.GetOrder();

            return(ShippingProviderHelper.GetShippingProvidersForOrder(currentOrder, useZone, storeAlias, currencyCode).Select(s => new ShippingFulfillmentAdaptor(s, inclVat, localization, currentOrder)));
        }
Exemple #3
0
        /// <summary>
        /// Gets the fulfillment providers. (ie shipping/pickup/etc) for a basket
        /// </summary>
        /// <param name="order">the order to match the fulfillment providers with</param>
        /// <param name="useZone">if set to <c>true</c> use zone/countries.</param>
        /// <param name="storeAlias">The store alias.</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <returns></returns>
        public static IEnumerable <IFulfillmentProvider> GetFulfillmentProvidersForOrder(IBasket order, bool useZone = true, string storeAlias = null, string currencyCode = null)
        {
            var localization = StoreHelper.GetLocalizationOrCurrent(storeAlias, currencyCode);
            var orderInfo    = Basket.GetOrderInfoFromOrderBasket(order);
            var currentOrder = OrderHelper.GetOrder();

            return(ShippingProviderHelper.GetShippingProvidersForOrder(orderInfo, useZone, storeAlias, currencyCode)
                   .Select(p => new ShippingFulfillmentAdaptor(p, orderInfo.PricesAreIncludingVAT, localization, currentOrder)));
        }
Exemple #4
0
        public List <OrderValidationError> ValidateGlobalValidations(OrderInfo orderInfo)
        {
            var errors = new List <OrderValidationError>();

            if (orderInfo.ConfirmValidationFailed)
            {
                if (!orderInfo.TermsAccepted)
                {
                    Log.Instance.LogWarning("ORDERVALIDATIONERROR: TERMS NOT ACCEPTED");
                    errors.Add(new OrderValidationError {
                        Key = "AcceptTermsError", Value = "Terms Not Accepted"
                    });
                }

                var shippingProvidersForOrder = ShippingProviderHelper.GetShippingProvidersForOrder(orderInfo);
                if (orderInfo.Status == OrderStatus.Confirmed && orderInfo.ShippingCostsMightBeOutdated &&
                    shippingProvidersForOrder.Count > 0 &&
                    shippingProvidersForOrder.All(shipPro => shipPro.Id != orderInfo.ShippingInfo.Id))
                {
                    Log.Instance.LogWarning("ORDERVALIDATIONERROR: ShippingCostOutdatedError");
                    errors.Add(new OrderValidationError
                    {
                        Key   = "ShippingCostOutdatedError",
                        Value = "Shipping Not Updated Since Last Basket Change"
                    });
                }

                if (orderInfo.Status == OrderStatus.Confirmed && orderInfo.StoreInfo.Store == null)
                {
                    Log.Instance.LogWarning("ORDERVALIDATIONERROR: NoStoreConnectedToThisOrder");
                    errors.Add(new OrderValidationError
                    {
                        Key   = "NoStoreConnectedToThisOrder",
                        Value = "There Is No Store Connected To This Order"
                    });
                }
            }
            return(errors);
        }
Exemple #5
0
        public List <OrderValidationError> ValidateShipping(OrderInfo orderInfo)
        {
            var errors = new List <OrderValidationError>();

            if (orderInfo.ShippingInfo.Id != 0)
            {
                var shippingProvider = ShippingProviderHelper.GetShippingProvider(orderInfo.ShippingInfo.Id);

                var shippingCountryCode = orderInfo.CustomerInfo.ShippingCountryCode;

                // if shipping country is empty on the order, then use customercountry for validation
                if (string.IsNullOrEmpty(shippingCountryCode))
                {
                    shippingCountryCode = orderInfo.CustomerInfo.CountryCode;
                }

                if (shippingProvider.Type != ShippingProviderType.Pickup && !shippingProvider.Zone.CountryCodes.Contains(shippingCountryCode))
                {
                    Log.Instance.LogWarning("ORDERVALIDATIONERROR: SHIPPING COUNTRY DOES NOT MATCH SHIPPING PROVIDER");
                    errors.Add(new OrderValidationError {
                        Id = orderInfo.ShippingInfo.Id, Key = "ValidationShippingCountryShippingProviderMismatch", Value = "The Shipping Country Does Not Match Countries Allowed For The Chosen Shipping Provider"
                    });
                }
                errors.AddRange(ShippingProviderHelper.GetPaymentValidationResults(orderInfo).Where(e => e.Id == orderInfo.ShippingInfo.Id));
            }

            if (orderInfo.ConfirmValidationFailed && orderInfo.ShippingInfo.Id == 0 && ShippingProviderHelper.GetShippingProvidersForOrder(orderInfo).Count > 0)
            {
                Log.Instance.LogWarning("ORDERVALIDATIONERROR: SHIPPING PROVIDERS AVAILABLE BUT NOT CHOSEN");
                errors.Add(new OrderValidationError {
                    Id = 0, Key = "ValidationNoShippingProviderChosen", Value = "No Shipping Provider Chosen"
                });
            }
            return(errors);
        }
Exemple #6
0
 /// <summary>
 /// Returns Shipping Providers for this order
 /// </summary>
 /// <returns></returns>
 public static List <ShippingProvider> GetShippingProvidersForOrder(bool useCountry = true)
 {
     return(ShippingProviderHelper.GetShippingProvidersForOrder(useCountry));
 }