Exemple #1
0
        /// <summary>
        /// Gets the fulfillment providers. (ie shipping/pickup/etc) for a given country
        /// </summary>
        /// <param name="countryCode">the code of the country</param>
        /// <param name="storeAlias">The store alias.</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <returns></returns>
        public static IEnumerable <IFulfillmentProvider> GetFulfillmentProvidersForCountry(string countryCode, string storeAlias = null, string currencyCode = null)
        {
            var localization = StoreHelper.GetLocalizationOrCurrent(storeAlias, currencyCode);

            var inclVat = IO.Container.Resolve <ISettingsService>().IncludingVat;

            return(ShippingProviderHelper.GetAllShippingProviders(storeAlias, currencyCode).Where(x => x.Zone.CountryCodes.Contains(countryCode)).Select(p => new ShippingFulfillmentAdaptor(p, inclVat, localization, null)));
        }
Exemple #2
0
        public ProviderActionResult AddShippingProvider(OrderInfo order, int shippingProviderId, string shippingProviderMethodId, ILocalization localization)
        {
            if (ChangeOrderToIncompleteAndReturnTrueIfNotAllowed(order))
            {
                Log.Instance.LogDebug("AddShippingMethod: " + ProviderActionResult.NotPermitted);
                return(ProviderActionResult.NotPermitted);
            }

            if (shippingProviderId == 0)
            {
                Log.Instance.LogDebug("AddShippingMethod: " + ProviderActionResult.ProviderIdZero);
                return(ProviderActionResult.ProviderIdZero);
            }

            // todo: move logic and update API
            var shippingProvider = ShippingProviderHelper.GetAllShippingProviders(localization.StoreAlias, localization.CurrencyCode).FirstOrDefault(x => x.Id == shippingProviderId);

            if (shippingProvider == null)
            {
                Log.Instance.LogDebug("AddShippingMethod shippingProvider " + ProviderActionResult.NoCorrectInput + " shippingProviderId: " + shippingProviderId);
                return(ProviderActionResult.NoCorrectInput);
            }

            order.ShippingInfo.Id    = shippingProviderId;
            order.ShippingInfo.Title = shippingProvider.Title;

            order.ShippingInfo.ShippingType = shippingProvider.Type;

            var shippingMethod = shippingProvider.ShippingProviderMethods.FirstOrDefault(x => x.Id == shippingProviderMethodId);

            if (shippingMethod == null)
            {
                Log.Instance.LogDebug("AddShippingMethod shippingMethod " + ProviderActionResult.NoCorrectInput + " shippingProviderMethodId: " + shippingProviderMethodId);
                return(ProviderActionResult.NoCorrectInput);
            }

            order.ShippingInfo.MethodId    = shippingProviderMethodId;
            order.ShippingInfo.MethodTitle = shippingMethod.Title;

            shippingMethod.UpdatePriceFromCustomShippingProvider(order);

            order.ResetDiscounts();

            return(ProviderActionResult.Success);
        }
Exemple #3
0
        public static XPathNavigator GetAllShippingProviders()
        {
            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, ShippingProviderHelper.GetAllShippingProviders().ToList());
            stream1.Position = 0;

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

            var doc = new XmlDocument();

            doc.LoadXml(result);


            return(doc.CreateNavigator());
        }
Exemple #4
0
 /// <summary>
 /// Return a list of shipping providers
 /// </summary>
 /// <returns>
 /// All list of all the Shipping Providers in uWebshop
 /// </returns>
 public static List <ShippingProvider> GetAllShippingProviders()
 {
     return(ShippingProviderHelper.GetAllShippingProviders().ToList());
 }