Forked from kloon/woocommerce_products_sold_single_product.php
Created
May 17, 2016 18:14
-
-
Save seb86/0325d26428d406a3acf8d533a661c38e to your computer and use it in GitHub Desktop.
WooCommerce display number of products sold on single product page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi how would i go about creating a shortcode as i dont want to apply this to all my pages just some products and i want to be able to ad my own text before and after the number as well place it where ever i feel fit