Home Forums WoodMart support forum Adding total sales to Product Archive Grid

Adding total sales to Product Archive Grid

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #629765

    Amit
    Participant

    Hello,
    How can I add Total Sales (Actual and also Random Fake) to my Product Archive grid?
    Is there a built-in feature for this, or an alternative method using code or a plugin?
    Image Attached

    Please advise.

    Attachments:
    You must be logged in to view attached files.
    #629932

    Hung Pham
    Keymaster

    Hi Amit,

    Thanks for reaching to us.

    Sorry but there is no such option in Theme Settings.

    Best Regards,

    #630069

    Amit
    Participant

    or an alternative method using code or a plugin?

    #630071

    Amit
    Participant

    Hello,
    Could you please tell me:
    If I enable the “Product Sold Counter for Single Product Page” setting,
    what is the meta key name where the counter number is stored?

    Additionally, could you provide details about the database location where this information is saved?
    Thanks

    #630230

    Hung Pham
    Keymaster

    Hi Amit,

    Try to Add the code below to the functions.php file in your child theme:

    add_action('woocommerce_shop_loop_item_title', function () {
    	global $product;
    
    	if ( ! woodmart_get_opt( 'sold_counter_enabled' ) || ! $product ) {
    		return;
    	}
    
    	$sales_count_data = XTS\Modules\Sold_Counter\Main::get_instance()->get_product_sales_count_data($product->get_id());
    
    	if ( empty( $sales_count_data ) ) {
    		return;
    	}
    
    	woodmart_enqueue_inline_style( 'woo-mod-product-info' );
    	woodmart_enqueue_inline_style( 'woo-opt-sold-count' );
    
    	?>
    	<div class="wd-product-info wd-sold-count">
    		<span class="wd-info-icon"></span><span class="wd-info-number"><?php echo esc_html( $sales_count_data['wd_count_number'] ); // Must be in one line. ?></span>
    		<span class="wd-info-msg"><?php echo esc_html( $sales_count_data['wd_count_msg'] ); ?></span>
    	</div>
    	<?php
    }, 100);

    Best Regards

    #630326

    Amit
    Participant

    Hello,
    Thank you very much, Hung.
    I have one last request: I want to show “21 sales” instead of “21 items sold in the last 24 hours.”
    Is there any way to change the text after the sales count?

    Thanks

    #630408

    Amit
    Participant

    I have figured it out. Thank you for your support!

    add_action('woocommerce_shop_loop_item_title', function () {
    	global $product;
    	if ( ! woodmart_get_opt( 'sold_counter_enabled' ) || ! $product ) {
    		return;
    	}
    	$sales_count_data = XTS\Modules\Sold_Counter\Main::get_instance()->get_product_sales_count_data($product->get_id());
    	if ( empty( $sales_count_data ) ) {
    		return;
    	}
    	woodmart_enqueue_inline_style( 'woo-mod-product-info' );
    	woodmart_enqueue_inline_style( 'woo-opt-sold-count' );
    	?>
    	<div class="wd-product-info wd-sold-count">
    		<span class="wd-info-icon"></span><span class="wd-info-number"><?php echo esc_html( $sales_count_data['wd_count_number'] ); ?></span>
    		<span class="wd-info-msg">sales</span>
    	</div>
    	<?php
    }, 100);
    #630965

    Hung Pham
    Keymaster

    Hi Amit,

    First of all, I am appreciate your patience.

    If you have a quick minute we always appreciate a 5-star rating on our theme!

    https://themeforest.net/item/woodmart-woocommerce-wordpress-theme/reviews/20264492

    Your feedback is the motivation to improve our work and services.

    Regards,

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Adding total sales to Product Archive Grid’ is closed to new replies.