echo woocommerce stock quantity of a particular product id

zero

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!

Mauro

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

WooCommerce product variations: Auto enable Manage Stock and set stock quantity

From Dev

How to echo "# in stock" from product page on WooCommerce?

From Dev

Get The Product Id of An Item If User Changes Quantity to 0 in WooCommerce Cart

From Dev

WooCommerce: function that returns all product ID's in a particular category

From Dev

Prestashop - Cancelled order product quantity not increased in stock quantity

From Dev

Prestashop - Cancelled order product quantity not increased in stock quantity

From Dev

How to get the stock quantity of an article from woocommerce?

From Dev

How get variation's stock quantity woocommerce

From Dev

Woocommerce product query for stock status

From Dev

Woocommerce: Minimum Quantity for Overall Product Category, not variations

From Dev

How to change Woocommerce variable product quantity rule

From Dev

How to change Woocommerce variable product quantity rule

From Dev

Change Woocommerce product quantity on a link click with jQuery

From Dev

Woocommerce: Minimum Quantity for Overall Product Category, not variations

From Dev

Magento 1.9 - echo Product Stock Alert next to "Out of Stock" Label

From Dev

Change WooCommerce product quantity settings for specific product category

From Dev

Move "in stock" up on Woocommerce product page

From Java

Set a max displayed available stock quantity on Woocommerce archives for variable products

From Dev

Woocommerce product price update after cart quantity increase

From Dev

Custom add to cart button to add multiple product into cart with quantity :woocommerce

From Dev

Apply custom quantity arguments based on the product category on the WooCommerce checkout page

From Dev

WooCommerce: Get the cart item quantity of a customized product only

From Dev

How to customise Order Quantity output in Woocommerce product page

From Dev

Woocommerce change quantity min limit for each product in cart

From Dev

Min and Steps quantity in Woocommerce cart and single product page for wholesale role

From Dev

Allow customer to set the product quantity globally on Woocommerce products

From Dev

Get Sale ID to acquire child objects items quantity and check then with stock

From Dev

Woocommerce get Product id using product SKU

From Dev

WooCommerce - Get the product description by product_id

Related Related

  1. 1

    WooCommerce product variations: Auto enable Manage Stock and set stock quantity

  2. 2

    How to echo "# in stock" from product page on WooCommerce?

  3. 3

    Get The Product Id of An Item If User Changes Quantity to 0 in WooCommerce Cart

  4. 4

    WooCommerce: function that returns all product ID's in a particular category

  5. 5

    Prestashop - Cancelled order product quantity not increased in stock quantity

  6. 6

    Prestashop - Cancelled order product quantity not increased in stock quantity

  7. 7

    How to get the stock quantity of an article from woocommerce?

  8. 8

    How get variation's stock quantity woocommerce

  9. 9

    Woocommerce product query for stock status

  10. 10

    Woocommerce: Minimum Quantity for Overall Product Category, not variations

  11. 11

    How to change Woocommerce variable product quantity rule

  12. 12

    How to change Woocommerce variable product quantity rule

  13. 13

    Change Woocommerce product quantity on a link click with jQuery

  14. 14

    Woocommerce: Minimum Quantity for Overall Product Category, not variations

  15. 15

    Magento 1.9 - echo Product Stock Alert next to "Out of Stock" Label

  16. 16

    Change WooCommerce product quantity settings for specific product category

  17. 17

    Move "in stock" up on Woocommerce product page

  18. 18

    Set a max displayed available stock quantity on Woocommerce archives for variable products

  19. 19

    Woocommerce product price update after cart quantity increase

  20. 20

    Custom add to cart button to add multiple product into cart with quantity :woocommerce

  21. 21

    Apply custom quantity arguments based on the product category on the WooCommerce checkout page

  22. 22

    WooCommerce: Get the cart item quantity of a customized product only

  23. 23

    How to customise Order Quantity output in Woocommerce product page

  24. 24

    Woocommerce change quantity min limit for each product in cart

  25. 25

    Min and Steps quantity in Woocommerce cart and single product page for wholesale role

  26. 26

    Allow customer to set the product quantity globally on Woocommerce products

  27. 27

    Get Sale ID to acquire child objects items quantity and check then with stock

  28. 28

    Woocommerce get Product id using product SKU

  29. 29

    WooCommerce - Get the product description by product_id

HotTag

Archive