• Resolved Grassmedia

    (@grassmedia)


    Hi folks,

    I’m working on a proof of concept for a client and one of the functions I need is a search box for customers to discover if deliveries are made to certain postcodes. The search just needs to return a certain page (or post) for yes or a different page for no. I have a csv of all the postcodes (there are about 14,000) but I’m really struggling to get my head around how to do this – ideally with a plugin but I’m not adverse to a bit of coding.

    Any ideas gratefully received.

Viewing 9 replies - 16 through 24 (of 24 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Please keep your support within these forums (and not give ftp access) – it’s kind that someone’s helping you out here, let’s take advantage of that.

    Andrew – sure! I hope everyone can benefit from our conversation.

    Grassmedia – yes, it can be something with host. Although my code is rather simple in terms of php functions on purpose – just to be “universal” – there’s always a chance that there’s something in host config.

    Anyway, give me a moment and I’ll think about it. I’m sure we’ll find the answer ??

    a.

    Thread Starter Grassmedia

    (@grassmedia)

    Sorry Andrew, I completely understand.

    Logically, I think it must be host related Adam, it works fine for you and not for me – I see you’re even using the same csv as me.

    Grassmedia,

    I’ll get back to you later today and I hope we’ll find the problem ??

    Grassmedia,

    Would you please revert $csv = fgetcsv($zipfile) to $csv = file($zipfile)?

    Then right below this line (before the loop) add:

    echo "<pre>";
    print_r ($csv);
    echo "</pre>";

    Let me know, we’ll work it out step-by-step ??

    Thread Starter Grassmedia

    (@grassmedia)

    That’s done and the array looks to be empty…

    ‘Array
    (
    )’

    that’s what I thought. Try adding this line:

    $zipfile = str_ireplace(get_site_url().'/','',$zipfile);

    right after

    $zipfile = esc_attr( get_option('spyzip_file'));

    and we’ll see what will happen ??

    Thread Starter Grassmedia

    (@grassmedia)

    Hey! That works!

    ‘Array
    (
    [0] => 1234567,canterbury,Friday,PM

    [1] => ct11aa,Canterbury,Monday,14:00 to 16:00

    [2] => ct11ad,Canterbury,Tuesday,14:00 to 16:01

    [3] => CT1 1AF,Canterbury,Wednesday,14:00 to 16:02

    [4] => ct11aa,ct11aa,ct11aa,ct11aa

    )’

    You’re a diamond! Thank you so much and, if you do feel like making it into a proper app with database integration etc. you have your first customer!

    Yep, it works ?? That’s because your host doesn’t allow so called fopen_wrapper. Such a configuration prevents scripts from opening files by URL.

    Later on I’ll update code on pastebin and plugin on dropbox so everyone would eventually be able to use properly working version ??

    I’m glad I helped ??

    A.

    /* UPDATE */
    For everyone interested in this topic:

    Code on pastebin has been updated.
    Here’s a proper plugin for download: https://www.dropbox.com/s/yu8u9nxojnm0xel/spy-zip-search.zip?dl=0

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘Intelligent search?’ is closed to new replies.