• Resolved patchyart

    (@patchyart)


    Hi, I hope youre well!

    I know this is a long shot, but we were wondering if there is any way to make the annasta filtering compatible with the dokan geolocation filtering which you can find here.

    Using either works on the page, for example if you search only for products near london, the correct products show up, however if you add a filter such as on sale it just grabs from all products and doesn’t respect the added dokan filters to the url.

    Additionally, after filtering/changing page with ajax the map with the product dokan_geo_address pins is not updated however this seems more complex to fix

    Best,

    Leo

    The page I need help with: [log in to see the link]

Viewing 4 replies - 16 through 19 (of 19 total)
  • Plugin Author annastaa

    (@annastaa)

    Hi Leo,

    If you wish to use the native annasta variables, then the following condition should suffice for detecting whether the infinite scroll is running the page:

    if( ( 'ajax_pagination' in awf_data ) && 'infinite_scroll' === awf_data.ajax_pagination.type ) {}

    For page numbers larger than 1, you can add the awf_data.ajax_pagination_loading check:

    if( ( 'ajax_pagination' in awf_data ) && 'infinite_scroll' === awf_data.ajax_pagination.type && awf_data.ajax_pagination_loading ) {}
    Thread Starter patchyart

    (@patchyart)

    Thank you for all your help!

    Last question lol

    Is there anyway to sort the tags section by product counts?

    Thanks!

    Plugin Author annastaa

    (@annastaa)

    Hello Leo,

    You are most welcome, I hope the tips that we share here will prove to be helpful to you and possibly other users of the plugin! Your last question seems very interesting, even though strangely enough I don’t remember anybody ever asking about this.

    Sorting by counts is not included as a built-in option, but since there was bound to exist a JS solution, I have test-driven the script below on one of our test sites, and it seems to do the trick:

    jQuery( document ).ready( function( $ ){
      'use strict';
    
      if( 'undefined' !== typeof( a_w_f ) ) {
    
        a_w_f.tags_filter_containers = [];
    
        // Set the needed filters here:
        $( '.awf-filters-container.awf-filters-product-tags > ul' ).each( function( i, el ) {
          a_w_f.tags_filter_containers[i] = $( el );
        });
    
        if( 0 < a_w_f.tags_filter_containers.length ) {
    
          a_w_f.sort_tags_by_counts = function() {
            $.each( a_w_f.tags_filter_containers, function( i, $parent ) {
    
              var $fcs = $parent.children( '.awf-filter-container' );
              $fcs.sort( function( a, b ) {
                return parseInt( $( a ).find( '.awf-filter-count' ).html() ) - parseInt( $( b ).find( '.awf-filter-count' ).html() );
              });
              $.each( $fcs, function() { $parent.prepend( $( this ) ); });
            } );
          };
    
          $( document ).on( 'awf_after_counts_update', function() {
            a_w_f.sort_tags_by_counts();
          } );
    
          a_w_f.sort_tags_by_counts();
    
        }
      }
    });

    If you like, try it from the annasta Filters > Plugin settings > Custom JavaScript box to see if it works for your tags filter. If you have changed the tags parameter labels, you can adjust the container selectors under the corresponding comment.

    Disclaimer: though this seems to work on the basic Tags filter, the current script shouldn’t be used on very long lists and will not work on hierarchical taxonomies. It may also go into conflict with some complex JS options offered by the plugin, so please test thoroughly!

    Plugin Author annastaa

    (@annastaa)

    Hello @patchyart,

    I’ll go ahead and close this inactive thread, please open a new one if you have any further questions about the work of the filters!

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Dokan Geolocation filtering’ is closed to new replies.