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); }
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; }