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 7 years, 8 months ago.
- AuthorPosts
- March 22, 2016 at 12:28 pm #8131
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,
YaseenAttachments:
You must be logged in to view attached files.March 22, 2016 at 12:52 pm #8134Hi!
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.
Best,
Thank you in advance!
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 22, 2016 at 7:13 pm #8139Hi 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,
YaseenMarch 23, 2016 at 3:40 pm #8160Okays. 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 :)
March 23, 2016 at 3:46 pm #8161Hi,
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,
YaseenAttachments:
You must be logged in to view attached files.March 23, 2016 at 3:52 pm #8163Yeah, 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:
Best,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; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 23, 2016 at 3:59 pm #8165Hi,
Unfortunately that didn’t work either.
Thanks,
YaseenMarch 23, 2016 at 4:09 pm #8168Indeed.
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; }
-
This reply was modified 7 years, 8 months ago by
Ernest Marcinko.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 23, 2016 at 4:12 pm #8171Hi,
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,
YaseenMarch 23, 2016 at 4:34 pm #8175You 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:
Best,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; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 23, 2016 at 4:51 pm #8179Hi Ernest,
Thank you very much for the great support and your cooporation.
A 5 star rating from me ( Great Plugin & Great Support ) 🙂Regards,
YaseenMarch 23, 2016 at 5:04 pm #8180Thank 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:
Best,<?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 */ ?>
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 23, 2016 at 5:19 pm #8181Hi Ernest,
Thanks for replying to that also.
What i want exactly a search box beside my logo (See attachment please)Thanks,
YaseenAttachments:
You must be logged in to view attached files.March 25, 2016 at 7:06 pm #8193Hi Ernest,
This is a kind reminder of my issue.
Thanks for understanding,
YaseenMarch 25, 2016 at 8:14 pm #8194Hi 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 7 years, 8 months ago by
Yaseen.
Attachments:
You must be logged in to view attached files. -
This reply was modified 7 years, 8 months ago by
- AuthorPosts
You must be logged in to reply to this topic.