Untitled
webwizards
plain_text
3 days ago
882 B
0
Indexable
function display_product_sales_count() { global $post; // Get the product object $product = wc_get_product($post->ID); if (!$product) { return; } // Get total sales count $total_sales = $product->get_total_sales(); // Display the sales count field (read-only) woocommerce_wp_text_input(array( 'id' => '_product_sales_count', 'label' => __('Total Sales', 'woocommerce'), 'placeholder' => '', 'description' => __('Number of times this product has been sold.', 'woocommerce'), 'type' => 'number', 'value' => $total_sales, 'custom_attributes' => array( 'readonly' => 'readonly', 'style' => 'background-color: #f9f9f9; color: #666;' ) )); } add_action('woocommerce_product_options_global_unique_id', 'display_product_sales_count');
Editor is loading...
Leave a Comment