WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Display stock availabilty on shop page, WooCommerce (1 post)

  1. user1752759B
    Member
    Posted 1 year ago #

    How would I display the stock availability (for example, "9 items left") for variable and single products on my shop page in WooCommerce, similar to how the following script displays the SKU number?

    function shop_inventory() {
    global $product;
    if ( $product->is_type( 'variable' )) {
    echo
    '<div itemprop="productID" id="multi-sku">SKU
    <span>' . $product->sku . '</span></div>';
    }

    else {
    echo
    '<div itemprop="productID" id="multi-sku">SKU
    <span>' . $product->sku . '</span></div>
    <div class="stock" ><span>' . $product->stock . '</span> in stock<small>(backorders allowed)</small></div>';
    }
    };

    add_action( 'woocommerce_after_shop_loop_item_title', 'shop_inventory' );

    http://wordpress.org/extend/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.