Hello everyone i dont know about programing i only building my website through wordpress, i found a cool plugin that shows the Total of sales and views of a product, my problem is that i need to custom the field with CSS and i dont know how to add a class in the php file or if it is even possible. I want to add the class to custome the fields in the single product page because if i do without an specific class all the changes affect the whole page, here is the code

<?php
/*
Plugin Name: Product Sold Count
Plugin URI:  http:\bhaskardhote.in
Description: This Plugin will used to show the total product sale count & and total view of product .Nice and easy way to know your sale of each product.
Version: 3.0.1
Author: Bhaskar Dhote
Author URI: http:\bhaskardhote.in
*/
define( 'WP_WOOSOLD_URL', plugin_dir_url(__FILE__) );
define( 'WP_WOOSOLD_PATH', plugin_dir_path(__FILE__) );
define( 'WP_WOOSOLD_SLUG','woo_soldcount' );

if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');
global $wpdbb_content_dir;

if(!function_exists('wp_get_current_user')){
    include(ABSPATH."wp-includes/pluggable.php") ; // Include pluggable.php for current user    
}

function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "View: 0";
    }
    return 'Views: '.$count;
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}

// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);


add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 );
function wc_product_sold_count() {
    global $product;
    setPostViews(get_the_ID());
    $units_sold = get_post_meta( $product->id, 'total_sales', true );
    echo '<p>'. sprintf( __( 'Total Sold: %s', 'woocommerce' ), $units_sold ).' '.getPostViews(get_the_ID());'</p>';
}
add_action('inti','wc_product_sold_count');

?>

Thanks a lot for your help!

Read more here: How can i add a class for this php file?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: