Code dưới đây sẽ cho chúng ta số lượng sản phẩm đã bán ra của 1 sản phẩm nào đó trong trang single product.

Các bạn chỉ cần thêm đoạn code vào file functions.php của theme đang sử dụng là được

add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 );
function wc_product_sold_count() {
 global $product;
 $units_sold = get_post_meta( $product->get_id(), 'total_sales', true );
 echo '<p>' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';
}
Xem thêm: http://gerhardpotgieter.com/2013/10/14/woocommerce-number-of-products-sold/

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

All in one