Support » Plugin: WooCommerce » How do I enter a wildcard to save 21 YEARS work?

  • travellers


    The Post/Zip Codes feature under Shipping > Local Delivery only offer an exact match (i.e. to ‘match’ postcode RN12 3AB, you can’t enter RN*, or RN1*, RN12*, or even RN12 3*, you need to enter the whole code for every area you want to match. Since there are 29 MILLION postcodes in the UK, I did a quick ‘back of a fag packet’ calculation and discovered it would take me about 21 years to enter all the permutations. Woo support did say it “might be a bit tedious” to make that feature work correctly!

    So, now I’ve got that off my chest, how can I edit that function to add in wildcard support, to match the two letter code I enter plus whatever the rest of the poscode is? Apparently wildcard support will be in woocommerce 1.7 when its released, but I’d like to get the jump on it and have that ability now. Any ideas welcomed on where I could modify code to manage this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • ManusH


    As you mentioned, in the WooCommerce github repository, it is listed as an already added feature to v1.7 two months ago.

    == Changelog ==
    = 1.7.0 =
    * Feature - Added wildcard support to local delivery postcodes.

    the exact code dhange is displayed in:

    you can make your own modifications, or just download the latest development version from Github:



    I had no idea that you could use Github in that way, to get access to features from the forthcoming version etc. Github seems to be incredibly complicated to understand, or maybe I’m just being thick! Whatever, that is massively useful – thank you very much indeed for passing that snippet along. I’ve replaced my classes/shipping/class-wc-local-delivery.php with the modified file, and hey presto, it works!

    But (isn’t there always a ‘but’?)… The trouble is, it does somewhat confuse the issue when in use.

    PROBLEM 1: I’m using that feature to offer ‘local delivery’ to ALL of the UK mainland, except the postcode areas which carry the surcharge UK couriers apply for remote locations. For example, one such location is all postcodes within the HS1-HS9 range. In other words, if you live in postcode HS10 you don’t carry a surcharge, but if you live in HS9 you do.

    So, because I don’t have an ‘else’ operator, I have to input all the variations of H other than what I want to charge the premium for, which would be
    HA*, HB*, HC*, ... HZ* but not HS
    and then also add

    HS11*, HS12*, HS13*, ... HS19*,
    HS21*, HS22*, HS23*, ... HS29*,

    plus all the other numbers, from HS31 to HS 91.

    My suggestion then is to have the option to choose either:

      ‘Postcodes that INCLUDE the codes in the box’, or
      ‘Postcodes that EXCLUDE the codes in the box’.

    This would permit me to simply enter the codes that I want to charge a premium for, rather than having to list all possible permutations that I DON’T want to charge a premium for.

    PROBLEM 2: Since we can ‘order’ shipping options using drag and drop on the Shipping Options page, why can’t we have it ‘hide’ all options following the first one that’s available? For example, I’ve ‘ordered’ my list as Free Shipping, Local Delivery, Flat Rate, International Delivery. On entering country and/or postcode, the script should check and see that Free Delivery isn’t available and not show it (which it does perfectly already), then check Local Delivery and find that that is available, and then simply stop – why show Flat Rate as well?



    As for most of the open-source projects, that was official Woocommerce Github repository maintained by Woothemes for developers to suggest their ideas or fork their implementations etc.

    It is complicated for me though, as its main purpose is to be used by developers. I used that address to see what is going on development, and even to download the latest beta-release to test locally…

    The plugin has lots of default features on the box, but for some complex functionality beyond those basic features included, to try some other extensions will be a good idea if users are not capable of self-coding.

    There are some “Shipping” extensions, one of which is “Table Rate Shipping” with lots of improved controls over shipping classes.
    maybe you should want to give it a try:

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I enter a wildcard to save 21 YEARS work?’ is closed to new replies.