Product Analytics counter displayed in Front End Product Page

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Analytics Product Analytics counter displayed in Front End Product Page

This topic contains 6 replies, has 2 voices, and was last updated by Avatar Kreator 3 months, 2 weeks ago.

  • Author
    Posts
  • #105168
    Avatar
    Kreator
    Participant

    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!

  • #105674
    WCFM Forum
    WCFM Forum
    Keymaster

    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>&nbsp;'. __( '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

  • #105900
    Avatar
    Kreator
    Participant

    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?

  • #106426
    WCFM Forum
    WCFM Forum
    Keymaster

    Which theme you are using for the site?

  • #111691
    Avatar
    Kreator
    Participant

    Martfury, thanks!

  • #112385
    Avatar
    Kreator
    Participant

    Any feedback on this, please? Thanks!

  • #112975
    Avatar
    Kreator
    Participant

    Solve it by myself. Thanks!

    $views = (int) get_post_meta( $post->ID, '_wcfm_article_views', true );

The topic ‘Product Analytics counter displayed in Front End Product Page’ is closed to new replies.