As the title says, how do i echo the stock quantity of a particular product id? Let's say the product id is "1100" and i want the stock quantity to appear in a page that is not part of the product archive. Is that possible?
For example, in an empty page, it should appear as
"Product A leftover stock: 10"
I am just learning to code and have come up with the following, but no result appear:
function nntest(){
global $woocommerce;
global $product;
$product_id = 1100;
echo $product->get_stock_quantity();
}
Thanks!
You can use get_post_meta() function to get values from database.
this values are stored in wp_postmeta table.
$stock = get_post_meta( $post->ID, '_stock', true );
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments