Compatibility with another plugin

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Compatibility with another plugin

This topic contains 21 replies, has 2 voices, and was last updated by Yaseen Yaseen 8 years ago.

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #8131
    Yaseen
    Yaseen
    Participant

    Hi,

    I’m using my website as a multi vendor shop site using this plugin “YITH WooCommerce Multi Vendor” i mainly uses your great plugin to search products and vendors so i want to display the vendors name and image (logo) but i can’t see the logo (you can see attachment).

    I’ve contacted the YITH plugin developer and he wants to contact you and send you this message so read it please as i hope we can work this out easily 🙂

    This is his message:
    “Hi, I’m Andrea from yithemes.
    Our customer use you ajax search plugin and I want to know if it’s possible to add the support to our multi vendor plugin.
    Our multi vendor plugin add a custom product taxonomy and works fine with our plugin but don’t show the term description and the term image.
    Please, it’s possible to works for the full support with our multi vendor plugin.

    If you want I can help you to will do this.
    Thanks.
    Let me know.
    Have a nice day
    Andrea”

    Thanks for your help,
    Yaseen

    Attachments:
    You must be logged in to view attached files.
    #8134
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Thank you for the detailed ticket, it helps me a lot 🙂

    Can you please ask Andrea from yithemes:

    Hi Andrea!

    How can I get the description and the image based on the term ID? If there is a function or class available to do this, then I will be able to suggest a simple filtering method to append the missing description and image information.
    Thank you in advance!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8139
    Yaseen
    Yaseen
    Participant

    Hi Ernest,

    This is Andrea’s reply:

    if( function_exists( ‘YITH_Vendors’ ) ){
    $vendor_description = $vendor_logo = ”;
    $vendor = yith_get_vendor( $term_id, ‘vendor’ );
    if( $vendor->is_valid() ){
    $vendor_description = $vendor->description;
    $vendor_logo = get_avatar( $vendor->get_owner(), get_option( ‘yith_vendors_gravatar_image_size’, ’62’ ) );
    }
    }

    this is the snippet of code to get the vendor logo and vendor description.

    Thanks in advance,
    Yaseen

    #8160
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okays. In this case, try putting this to the functions.php file in your active theme directory:

    add_filter( 'asp_results', 'asp_get_yith_vendor_data', 1, 1 );
     
    function asp_get_yith_vendor_data( $results ) {
    
      foreach ($results as $k=>$v) {
        if ( $v->content_type == "term" ) {
          if( function_exists( 'YITH_Vendors' ) ){
            $vendor_description = $vendor_logo = '';
            $vendor = yith_get_vendor( $term_id, 'vendor' );
            if( $vendor->is_valid() ){
              $vendor_description = $vendor->description;
              $vendor_logo = get_avatar( $vendor->get_owner(), get_option( 'yith_vendors_gravatar_image_size', '62' ) );
            }
            $results[$k]->image = $vendor_logo;
            $results[$k]->content = $vendor_description;
          }
        }
      }
     
      return $results;
    }

    Let’s hope it will work.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8161
    Yaseen
    Yaseen
    Participant

    Hi,

    Ok now i can see the name in a box just like any product but not the image which is by the way the avatar of the user that owns the store (Please see the attachment)

    Thanks,
    Yaseen

    Attachments:
    You must be logged in to view attached files.
    #8163
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Yeah, it appears that the code that andrea provided returns the image code instead of the url, I didn’t notice that. Try this modification instead:

    add_filter( 'asp_results', 'asp_get_yith_vendor_data', 1, 1 );
     
    function asp_get_yith_vendor_data( $results ) {
    
      foreach ($results as $k=>$v) {
        if ( $v->content_type == "term" ) {
          if( function_exists( 'YITH_Vendors' ) ){
            $vendor_description = $vendor_logo = '';
            $vendor = yith_get_vendor( $term_id, 'vendor' );
            if( $vendor->is_valid() ){
              $vendor_description = $vendor->description;
              $vendor_logo = get_avatar_url( $vendor->get_owner() );
            }
            $results[$k]->image = $vendor_logo;
            $results[$k]->content = $vendor_description;
          }
        }
      }
     
      return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8165
    Yaseen
    Yaseen
    Participant

    Hi,

    Unfortunately that didn’t work either.

    Thanks,
    Yaseen

    #8168
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Indeed.

    I went ahead and checked the code in your functions.php file, and it appears that during my copy pasting the apostrophes were “corrected”, so it didn’t work. I’ve corrected that, now it should display the images finally.

    For future reference, this is the final version with correct apostrophes:

    
    /* Ajax Search Pro - Yith Vendor image display */
    
    add_filter( 'asp_results', 'asp_get_yith_vendor_data', 1, 1 );
      
    function asp_get_yith_vendor_data( $results ) {
     
      foreach ($results as $k=>$v) {
        if ( $v->content_type == "term" ) {
          if( function_exists( 'YITH_Vendors' ) ){
            $vendor_description = $vendor_logo = "";
            $vendor = yith_get_vendor( $v->id, 'vendor' );
            if( $vendor->is_valid() ){
              $vendor_description = $vendor->description;
              $vendor_logo = get_avatar_url( $vendor->get_owner() );
            }
            $results[$k]->image = $vendor_logo;
            $results[$k]->content = $vendor_description;
          }
        }
      }
      
      return $results;
    }
    
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8171
    Yaseen
    Yaseen
    Participant

    Hi,

    Yeah, Its working fine now. Thanks 🙂
    But its showing the gravatar image not the custom image i’m using as the store’s logo which is i upload using a plugin called (Avatar Manager).

    Thanks,
    Yaseen

    #8175
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    You are welcome!

    Well, I was going to suggest you to consult with the Avatar Manager plugin author on how to get those images, but instead I downloaded the plugin quickly and took a look at the code. I’ve found how to do it, and made the change for you.

    For future reference, this is the final code with Avatar Manager support:

    add_filter( 'asp_results', 'asp_get_yith_vendor_data', 1, 1 );
      
    function asp_get_yith_vendor_data( $results ) {
     
      foreach ($results as $k=>$v) {
        if ( $v->content_type == "term" ) {
          if( function_exists( 'YITH_Vendors' ) ){
            $vendor_description = $vendor_logo = "";
            $vendor = yith_get_vendor( $v->id, 'vendor' );
            if( $vendor->is_valid() ){
              $vendor_description = $vendor->description;
              if ( function_exists('avatar_manager_get_custom_avatar') ) {
                  $vendor_logo_img = avatar_manager_get_custom_avatar( $vendor->get_owner() );
                  $iarray = array();
                  preg_match( '/src="([^"]*)"/i', $vendor_logo_img, $iarray ) ;
                  if (isset($iarray[1]))
                     $vendor_logo = $iarray[1];
                  } else {
                     $vendor_logo = get_avatar_url( $vendor->get_owner() );
                  }
            }
            $results[$k]->image = $vendor_logo;
            $results[$k]->content = $vendor_description;
          }
        }
      }
      
      return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8179
    Yaseen
    Yaseen
    Participant

    Hi Ernest,

    Thank you very much for the great support and your cooporation.
    A 5 star rating from me ( Great Plugin & Great Support ) 🙂

    Regards,
    Yaseen

    #8180
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you very much Yaseen, you are awesome!

    To answer your other ticket as well:
    I’ve made another search instance “Header search bar” for you and placed it to the header bar. The file I had to edit was the wp-content/themes/jupiter/views/header/global/search.php.
    I did a basic styling and enabled compact mode for that instance, so it acts similarly as the previous search there. Feel free to style it 🙂 I hope it is what you needed.

    If you don’t need that, just remove this code from that file:

    
    <?php
    /* Ajax Search Pro bar START */
    echo '<div class="mk-header-search">';
    echo do_shortcode('[wpdreams_ajaxsearchpro id=4]'); 
    echo '</div>';
    return false;
    /* Ajax Search Pro bar END */
    ?>
    
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8181
    Yaseen
    Yaseen
    Participant

    Hi Ernest,

    Thanks for replying to that also.
    What i want exactly a search box beside my logo (See attachment please)

    Thanks,
    Yaseen

    Attachments:
    You must be logged in to view attached files.
    #8193
    Yaseen
    Yaseen
    Participant

    Hi Ernest,

    This is a kind reminder of my issue.

    Thanks for understanding,
    Yaseen

    #8194
    Yaseen
    Yaseen
    Participant

    Hi Ernest,

    I tried doing it myself. I got this result which is exactly what i want (see attachment please)
    But am having some issues with the styling as the box is not responsive and looks different on other browsers I guess i’ve done something wrong with css.

    Thanks,
    Yaseen

    • This reply was modified 8 years ago by Yaseen Yaseen.
    Attachments:
    You must be logged in to view attached files.
Viewing 15 posts - 1 through 15 (of 22 total)

You must be logged in to reply to this topic.