Fixed Shipping Rate for Multiple Post codes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
Hi all,
Was looking at charging a fixed shipping rate based off of a customer's shipping address's post(zip) code. I found the option to do this in the Shipping.ByWeight module but it appears you can only specify 1 post code at a time which will result in hundreds of records being required to be created (and maintained) to cover all the post codes we're delivering to.

Is there a way to specify multiple post codes? I tried a csv eg (2000,2001,2002,2003,2004) and a few other alternatives but couldn't get it to work.

Anyone had any luck with this using either a included shipping module or 3rd party plugin?

Cheers!
9 years ago
You can do csv of zip codes like this in ShippingDirector

String   ZipCode            ShippingAddress.ZipPostalCode
Option   ShippingName1      "2000,2001,2002,2003,2004".Contains([ZipCode])     15.00
Option   ShippingName2      "2005,2006,2007".Contains([ZipCode])        25.00


You can even look at a prefix
Reference   ZipCode3           ShippingAddress.ZipPostalCode.Substring(0,3)
Option      ShippingName2      [@ZipCode3].StartsWith("100")
9 years ago
The Shipping By Total plugin can match multiple zip codes per record since version 1.14/1.15 (nopCommerce 3.20).

From the 1.14 list of changes:
  Added support for multiple ZIP / postal codes per ShippingByTotal record. Store owners will be able to input ZIP / postal codes in multiple formats:
   -single entry (12345)
   -multiple entry (12345, 12346)
   -wildcard (S4? ???)
   -numeric range (10000:30000)
   -combinations of the above (11111, 100??, 11111:22222, 33333)


.
9 years ago
mb wrote:
The Shipping By Total plugin can match multiple zip codes per record since version 1.14/1.15 (nopCommerce 3.20).

From the 1.14 list of changes:
  Added support for multiple ZIP / postal codes per ShippingByTotal record. Store owners will be able to input ZIP / postal codes in multiple formats:
   -single entry (12345)
   -multiple entry (12345, 12346)
   -wildcard (S4? ???)
   -numeric range (10000:30000)
   -combinations of the above (11111, 100??, 11111:22222, 33333)


.

Does that works in Shipping by Weight plugin?
9 years ago
eadameg wrote:
Does that works in Shipping by Weight plugin?

No, the Shipping by Weight plugin only looks for an exact ZIP code match.

.
9 years ago
ok. thanks
3 years ago
Hello! I had a client that also needed to have different costs in respect to the shipping address of the customer and I saw that the plugin's logic didn't support more than one postal codes so I updated the Shipping.FixedByWeightByTotal plug-in to do just that:

(Version 4.30, but probably applies to the previous ones as I don't see the plugin changed a lot over the years)

Find the ShippingByWeightByTotalService.cs (Plugins File->Nop.Plugin.Shpping.fixedByWeightByTotal).


Change the //filter by Zip to:

//filter by zip
            var matchedByZip = string.IsNullOrEmpty(zip)
                ? matchedByStateProvince
                : matchedByStateProvince.Where(r => string.IsNullOrEmpty(r.Zip) || r.Zip.Equals(MatchZip(r.Zip, zip)));

And add this method:

//: MatchZip is a method I created so that we can input a lot of Zipcodes and split them with various ways.
        //We can split zipcodes with ";", eg: 18540; 18541; 18542
        //We can use ranges with "-", eg: 18540-18542
        //We can use a combination of those! eg: 18540-18542; 16724; 16789; 17823-17832;
        public string MatchZip(string rulesZip, string userZip)
        {
            var trimmedZip = rulesZip.Trim(' ');
            string[] zips = trimmedZip.Split(';');

            foreach (var zip in zips)
            {
                if (zip.Equals(userZip))
                    return rulesZip;

                if (zip.Contains("-")) {
                    string[] rangeZips = zip.Split('-');
                    
                    if (int.Parse(userZip) >= int.Parse(rangeZips[0]) && int.Parse(userZip) <= int.Parse(rangeZips[1]) )
                    return rulesZip;
                }
            }


            return "";

        }



Hope it helps somebody!
3 years ago
Hi Chris,
How can i expand on this?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.