I have added this code to my website to show the number of product buy by my clients for each products of my store.
I would like to show the number of sales only if the product has been bought maybe 5 times (to never show "buy 0 time")…
So I have this code:
add_action( 'woocommerce_after_shop_loop_item', 'wpm_product_sold_count', 11 );
function wpm_product_sold_count() {
global $product;
$units_sold = get_post_meta( $product->id, 'total_sales', true );
if ($units_sold > 5) {
echo '<p class="sold-product">' . sprintf( __( 'Produit vendu: %s fois', 'woocommerce' ), $units_sold ) . '</p>';
}
}
But it isn't working. Do you have any tips please?
Thanks