• Resolved magostino14

    (@magostino14)


    Couple questions regarding the WP Store Locator plugin

    My store locator: http://owlee.eliv8group.com/retailers/

    I am trying to find a way to have the results list on the left hand side of my locator to display the stores that are in a 50 mile radius(which it is currently doing) while at the same time displaying those stores in the 50 mile radius in the order of the store id from 1st to last, i have seen it labeled as ‘id’ => absint( $result[$k]->wpsl_id ), in some of the code
    in wp-store-locator/frontend/wpsl-ajax-functions.php
    this is the section that i believe that this can be changed. Would you be able to help me make this happen?

    Also, I am trying to find a way to get my description back, I believe I deleted the section where it appears and I can’t seem to find a way to get it back.
    It is displaying fine on the map info, but on the results list on the left, it does not appear. Do you know where and how I can get that description to display again?

    Thank you so much.

    https://wordpress.org/plugins/wp-store-locator/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    If you want to sort them by id you should have a look at this topic http://stackoverflow.com/questions/2699086/sort-multi-dimensional-array-by-value . You should do that just before the data is returned in the /frontend/wpsl-ajax-functions.php

    wp_send_json( $store_results );

    You made modifications to the code that the description is gone now? The best way to find differences between the original files and the once you have now is by using a tool like winmerge. It will scan two folders and show the differences, and that should help to revert some of the changes you made so the description is shown again in the results.

    Thread Starter magostino14

    (@magostino14)

    I am having trouble finding that exact line in the /frontend/wpsl-ajax-functions.php
    I see something similar on line 60 but it is not exact.

    and is this the code I am supposed to copy?

    ($myArray, function($a, $b) {
    return $a[‘order’] – $b[‘order’];
    });

    Once again I only would only like the results to be sorted by the id after it has calculated the distances and pulled only the ones within the max radius.

    I really appreciate your help but I am not as tech savvy as you might think or be hoping for. Would you mind telling me exactly what to paste and on which line?
    Thank you so much for your help this far.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Add this on line 96.

    usort( $store_results, 'sortByOrder' );

    And this after the function closes on line 102, so after the ‘}’.

    function sortByOrder( $a, $b ) {
        return $a['id'] - $b['id'];
    }

    This will sort the results by id instead of the distance.

    Do I have to replace the 96 line? This is how it looks to me.

    wp_send_json( $store_results );

    I tried replacing and adding the code line you suggested like this:

    wp_send_json( $store_results );
                    usort( $store_results, 'sortByOrder' );
        }
    
        die();
    }
    
    function sortByOrder( $a, $b ) {
        return $a['id'] - $b['id'];
    }
    
    /**

    but it returns no result…

    Ok, it worked pasting the usort line before sending $store _results, thanks 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Results display questions’ is closed to new replies.