Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Products attributes in the resultbox
This topic contains 9 replies, has 2 voices, and was last updated by skempenaar 4 years, 2 months ago.
- AuthorPosts
- February 28, 2020 at 11:41 am #26038
Hi i would like to display some products attributes in the result box. this because we have some products with the same title. this because 1 is a paperback the other is an e-book. i’ve tried to include {pa_bindwijze}. but this did not do the trick.
Attachments:
You must be logged in to view attached files.February 28, 2020 at 12:40 pm #26042Hi,
Some product attributes might be stored as taxonomy terms, try this syntax instead:
Best,{__tax_pa_bindwijze}
For all the details and usage of those fields you can check the Advanced Title and Content fields documentation.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 28, 2020 at 2:02 pm #26043Thx works like a charm!. what if i want to have a separator between it but only displayed when there is content.
Attachments:
You must be logged in to view attached files.February 28, 2020 at 2:18 pm #26046You are welcome!
Use the conditional bracket syntax, in the previous linked documentation.
[{__tax_pa_bindwijze} | {__tax_pa_druk}<br>]
or:
Best,{__tax_pa_bindwijze}[ | {__tax_pa_druk}<br>]
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 28, 2020 at 2:31 pm #26047im sorry did look that up in the docs. thx!!!!
February 28, 2020 at 2:39 pm #26048allright one last question:) are woocommerce star reviews even possible?
February 28, 2020 at 4:10 pm #26054You are welcome 🙂
Well, there was a custom-coded solution that worked a long time ago. I am not sure if that is still the case, but it is worth a try. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
Best,add_filter( 'asp_results', 'asp_add_woo_ratings', 1, 1 ); function asp_my_print_stars( $id ){ global $wpdb; $count = $wpdb->get_var(" SELECT COUNT(meta_value) FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = $id AND comment_approved = '1' AND meta_value > 0 "); $rating = $wpdb->get_var(" SELECT SUM(meta_value) FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = $id AND comment_approved = '1' "); $out = ''; if ( $count > 0 ) { $average = number_format($rating / $count, 2); ob_start(); ?> <div class="woocommerce"> <div itemprop="reviewRating" itemscope="" itemtype="http://schema.org/Rating" class="star-rating" title="<?php sprintf(__('Rated %s out of 5', 'woocommerce'), $average); ?>"> <span style="width:<?php echo ($average*20); ?>%"><strong itemprop="ratingValue"> </strong></span> </div> </div> <?php $out = ob_get_clean(); } return $out; } function asp_add_woo_ratings( $results ) { foreach ($results as $k=>&$v) { if ( $v->content_type == 'pagepost' && in_array($v->post_type, array('product', 'product_variation')) ) { $v->content .= asp_my_print_stars($v->id); } } unset($v); return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 28, 2020 at 4:57 pm #26059yet again! works like a charm:D
February 28, 2020 at 4:58 pm #26060You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 28, 2020 at 5:00 pm #26061done!
- AuthorPosts
The topic ‘Products attributes in the resultbox’ is closed to new replies.