For single product page, I tested it with the themes: ShoppingCart and Storefront and it works fine :
in function.php
:
function shoppingcart_setup(){
add_filter('woocommerce_short_description', function(){
global $product;
$units_sold = $product->get_total_sales();
if ( $units_sold ) return '<p>' . sprintf( __( 'Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';
}, 10, 2);
}
add_action( 'after_setup_theme', 'shoppingcart_setup' );
Note: If you checked: Manage Stock, this code does not work
Related Posts:
- wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?
- how to get woocommerce product attribute slug
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- Create WooCommerce custom stock option that is non-purchasable
- Query multiple post type and categories
- Shipping restrictions with WooCommerce variable products
- WooCommerce – Flat rate shipping based on X quantity steps?
- Custom URL for each product variation – rewrite rules
- Where can I find a single item template
- Get Woocommerce Subscription Product
- Change “Shipping” text to “Delivery” everywhere I appears in woocommerce
- Customize WooCommerce orders displayed shipping
- WooCommerce pages accessible to logged in members only
- Woocomerce language
- How to set default values in Woocommerce checkout? [closed]
- paypal not showing on woocommerce payments
- Target WooCommerce Product Gallery Image (rather than Featured Image) for og:image
- Payment methods are not displaying in Woocommerce
- How to update the WooCommerce cart Icon to show new products added with JavaScript
- Remove the link from the thumbnail and product title on woocommerce
- How to configure Woocommerce Payment Methods programmatically?
- woocommerce_package_rates not fired everytime
- how to change woocommerce shop archive description? [closed]
- Add content to the last slide of each product
- Remove add to cart icon/view product button woocommerce
- Products Shortcode is Displaying Single Product Page Price for all Products [closed]
- Subscription on Checkout
- Woocommerce – display product in page but in list format with excerpt
- how to show store name when I add a product on cart in woocommerce(woocommerce multi store)?
- When Free shipping is available hide other shipping methods except Local pickup in WooCommerce [closed]
- Create archive page for woocommerce attribute
- How to increase execution time out limit in WordPress dashboard?
- Setting an attribute as variation in woo commerce via php [duplicate]
- WooCommerce – Conditionally enable shipping for virtual products
- Make order notes field at woocommerce checkout only viewable on front end by Admin level user role [closed]
- How to apply these filters
- get_the_post_thumbnail_url does not return anything if image size is set
- Add to Cart button displaying twice on Shop Page Woocommerce
- How to exclude a taxonomy from shop & search page wooCommerce?
- How to remove unwanted text bug in wordpress site
- get woocommerce product image url and price from database [closed]
- Trying to style Woocommerce sidebar Cart Widget [closed]
- WooCommerce checkout page price break down table hook
- How can I compel alphanumeric entries for username textbox on woocommerce registration form
- Help me to intergrate product database to WordPress
- WooCommerce how to checkout a product without adding it to the cart
- How can i access woocommerce order variables inside shortcode?
- Using the WordPress and WooCommerce REST APIs in the same Node app
- How to add a “buy now” button below “add to cart” button [closed]
- Cart page displays the price and amount as zero regardless of price entered [closed]
- Custom action not working in Woocommerce
- Display list of only specific tags on product
- Change the “Register” headline in Woocommerce
- How to display customer mobile number in woocommerce customers page
- How to alter taxes amounts when updating an order
- Woocommerce variable product’s total amount by javascript
- Get all categories inside a Product Tag archive page
- Save product short description in order (without updating in order details if it is updated in product)
- Woocommerce – Hide shipping at all, if only certain product or products with certain shipping class is in the cart
- Running JavaScript after using WooCommerce Filter Plugin
- Include stock information in WooCommerce order confirmation email
- Combine one action and one filter
- How to set up dynamic purchase pixel in Woocommerce?
- MySQL error or data corruption after database migration
- My products are showing “not in stock” and I don’t know why
- Woocommerce change the price of products in the database
- Select all products that have a custom field ‘is_new’ set to ‘Yes’
- Woocommerce – Shop can’t find products after domain name change
- “error_message”: “Sorry, you cannot list resources.” using WooCommerce API
- WooCommerce product details page category display
- Woocommerce – Default product image by user role
- Removing Product from Woocommerce checkout page using Ajax
- add_post_meta on subcription renewal
- login or register then access woocommerce website
- Move woocommerce shop page image to left
- WooCommerce Tax Filter Not Working
- WooCommerce does not translate every string
- Woocommerce add a text field if specific option is selected
- Add suffix to price html does not work
- Replace product link with just product name on WooCommerce downloads page
- Woocommerce Product category base same as product base causes 404
- Categories and products in cart Woocommerce
- SyntaxError: unterminated string literal – if WordPress Debug in wp-config is set to true
- How Fragile Is DB if I Upload Completely Updated Files
- Broken 302 redirection for product subcategory (Woocommerce, Apache)
- How to allow registration only from a certain location?
- Add confirmation popup on place order button
- Custom CSS Not working on Product page
- Change WooCommerce Checkout Button – Reverts to normal
- How to add ajax loading icon after click add to cart button on woocommerce
- Can’t display product categories on woocommerce getting Invalid taxonomy?
- Send form data to functions.php
- Create custom add to cart in WordPress
- WooCommerce – How to add a custom field to only a specific email template [closed]
- error 500 in Back Office when using a woocommerce function in functions.php
- How to update all products with same SKU prefixes when updating stock with CSV?
- What is the best and cheapest way to generate dashboards about conversions data and store users? [closed]
- Sort by price when price is set in multiple keys
- Add a custom code with custom link after add to cart for every product
- WooCommerce product permalink based on product’s current category