Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Analytics › Product Analytics counter displayed in Front End Product Page
- This topic has 6 replies, 2 voices, and was last updated 4 years, 8 months ago by Kreator.
- AuthorPosts
- February 3, 2020 at 3:37 pm #105168KreatorParticipant
Hi,
I have WCFM Ultimate + Analytics module.
I am interested in showing the number of views of products in the Front End next to Price or Stock.
I can see them in the admin area but I want to display the numbers also in the Front End.Let me know what is the most easy way to do this.
Thanks!
- February 6, 2020 at 10:54 am #105674WCFM ForumMember
Hi,
Please add this code to your site. This will show views like this – https://ibb.co/GkxR2m3
add_action( 'woocommerce_single_product_summary', function() { global $WCFM, $WCFMmp, $product; $product_id = $product->get_id(); $views = (int) get_post_meta( $product_id, '_wcfm_product_views', true ); echo '<div class="wcfm_clearfix"></div><div class="wcfmmp_shipment_processing_display"><i class="wcfmfa fa-eye" aria-hidden="true"></i> '. __( 'Views', 'wc-multivendor-marketplace' ) . ': ' . $views .'</div><div class="wcfm_clearfix"></div>'; }, 15 );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/Thank You
- February 6, 2020 at 8:28 pm #105900KreatorParticipant
Thanks for your reply, I will test this shortly!
Can you please let me know how can I add this counter to Blog posts also/articles? - February 10, 2020 at 2:32 pm #106426WCFM ForumMember
Which theme you are using for the site?
- March 15, 2020 at 9:33 pm #111691KreatorParticipant
Martfury, thanks!
- March 20, 2020 at 4:59 pm #112385KreatorParticipant
Any feedback on this, please? Thanks!
- March 24, 2020 at 6:05 pm #112975KreatorParticipant
Solve it by myself. Thanks!
$views = (int) get_post_meta( $post->ID, '_wcfm_article_views', true );
- AuthorPosts
- The topic ‘Product Analytics counter displayed in Front End Product Page’ is closed to new replies.