Created
January 28, 2021 22:46
-
-
Save AmeliaBriscoe/253d87da2f42739bdd08e4291af307ef to your computer and use it in GitHub Desktop.
Show Unit Stock for Products that have Pre-Orders enabled.
This file contains hidden or 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', 'bbloomer_product_sold_count', 11 ); | |
function bbloomer_product_sold_count() { | |
global $product; | |
$units_sold = $product->get_total_sales(); | |
if ( $units_sold && ( 'yes' === $product->get_meta( '_wc_pre_orders_enabled' ) ) ) 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