示例#1
0
        public static GCheckout.Checkout.ShippingRestrictions ToShippingRestrictions(this ShippingMethod shippingMethod)
        {
            var restrictions = new GCheckout.Checkout.ShippingRestrictions();

            if (shippingMethod.AllowedPostalAreas == null || !shippingMethod.AllowedPostalAreas.Any())
            {
                // Entire world
                restrictions.AddAllowedWorldArea();
            }
            else if (shippingMethod.AllowedPostalAreas != null)
            {
                foreach (var area in shippingMethod.AllowedPostalAreas)
                {
                    restrictions.AddAllowedPostalArea(area.countrycode, area.postalcodepattern);
                }
            }

            if (shippingMethod.ExcludedPostalAreas != null)
            {
                foreach (var area in shippingMethod.ExcludedPostalAreas)
                {
                    restrictions.AddExcludedPostalArea(area.countrycode, area.postalcodepattern);
                }
            }

            return(restrictions);
        }
示例#2
0
        public static GCheckout.Checkout.ShippingRestrictions ToShippingRestrictions(this ShippingMethod shippingMethod)
        {
            var restrictions = new GCheckout.Checkout.ShippingRestrictions();

            if (shippingMethod.AllowedPostalAreas == null || !shippingMethod.AllowedPostalAreas.Any())
                // Entire world
                restrictions.AddAllowedWorldArea();
            else if (shippingMethod.AllowedPostalAreas != null)
                foreach (var area in shippingMethod.AllowedPostalAreas)
                    restrictions.AddAllowedPostalArea(area.countrycode, area.postalcodepattern);

            if (shippingMethod.ExcludedPostalAreas != null)
                foreach (var area in shippingMethod.ExcludedPostalAreas)
                    restrictions.AddExcludedPostalArea(area.countrycode, area.postalcodepattern);

            return restrictions;
        }