Bootstrap Templates Bundle

Tuesday, February 3, 2015

Display the number of Products Sold in WooCommerce

//To display the number of units sold for a product, add the following snippet of code to your theme’s functions.php file

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

//or Where You want to show

<?php echo get_post_meta($post->ID, 'total_sales', true); ?> 

No comments:

Post a Comment

Wokiee React eCommerce Template