Shipping by weight conf. Post Codes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi Everyone,


Do you b chance know how to configure just parts of general post codes without having to input them one by one? Eg. IV 1 - 46 = Shipping price £56 and IV 47 - 58 = £126 do I have to put every combination in?

Thank you in advance.
Francisco
7 years ago
Yes, unfortunately, when using the Shipping by Weight plugin, you MUST input every possible option manually.
The only other alternative is to use a dynamic shipping rates computation method.
7 years ago
FranciscoP72 wrote:
Do you by chance know how to configure just parts of general post codes without having to input them one by one? Eg. IV 1 - 46 = Shipping price £56 and IV 47 - 58 = £126 do I have to put every combination in?

The Shipping by weight plugin doesn't really work for typical UK postal scenarios without modification. From your question it sounds like you need to map just the outcode part of the postcode (e.g. IV1 from a postcode like IV1 2AB). So generally UK mainland is the default UK zone and you define several groups of outcode fragments that define more specific regions like the Scottish Highlands, Offshore islands, Northern Ireland, Channel Islands, Isle of Wight, Isle of Man, etc.

The Shipping by weight plugin uses an exact match to the entire submitted zip code (see the code here - https://github.com/nopSolutions/nopCommerce/blob/develop/src/Plugins/Nop.Plugin.Shipping.ByWeight/Services/ShippingByWeightService.cs#L120) which means you would actually need to enter every single individual 5-7 character postcode, not just the outcodes like IV1, IV2, IV3, etc.

The good news is it's pretty easy to modify the shipping by weight plugin to work for the UK. Assuming you're working with Outcode groups as described above it's easy to extract the outcode portion of the postcode just by removing all spaces from the submitted postcode string and removing the last 3 characters to leave the first 2-4 characters which is the outcode.

When setting up the shipping by weight record in the admin you then enter a comma delimited list of outcodes like: IV1, IV2, IV3, IV4, IV5, IV6, etc. and change the zip code lookup logic linked above to split the list on commas and see if the resulting array contains the outcode fragment:

//filter by zip
var matchedByZip = new List<ShippingByWeightRecord>();
foreach (var sbw in matchedByStateProvince)
    if (!String.IsNullOrEmpty(sbw.Zip) && sbw.Zip.Split(',').Select(x => x.Trim().ToUpper()).Contains(outcode.ToUpper()))
    {
        matchedByOutcode.Add(sbw);
    }

Alternatively if you want a plugin that can support most shipping scenarios out of the box I can recommend the Shipping Director plugin. You still need to implement the same kind of logic described above but it can be done from the configuration page rather than having to build your own plugin or modify the existing shipping by weight plugin. The plugin's author New York is a regular on the forums and could probably give you more advice on whether it can support whatever specific requirements you have.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.