How to display stock quantity of a product in a post?
-
I’d like to call the stock quantity of a simple product somewhere in a paragraph. For example i’m writing a blog and I’d like to name the available quantity like this:
<p>Only <span class="quantity_product_1"> <?php echo $product->get_stock_quantity(); ?></span> available!</p>
I’ve come across something like this to create a function:
<?php /** * Loop Price * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $product; ?> <?php if ( $price_html = $product->get_price_html() ) : ?> <span class="price">PREIS:<span class="amount"><?php echo $price_html; ?></span></span><p class="stock-m13"><?php get_sku(get_the_ID()); ?></p> <?php endif; ?>
And this:
<p class=”stock-m13″><?php echo $product->get_stock_quantity(); ?></p>
Would anyone know to get this done, how i can do this for a specific product (SKU)?
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘How to display stock quantity of a product in a post?’ is closed to new replies.