Support » Plugin: WooCommerce » Automatically having products marked "Out of Stock" & Showing Stock Quantity

  • Hello everyone!

    I am currently trying to work out two issues I am having with WooCommerce.

    First, is there a way to have WooCommerce automatically mark a product as “Out of Stock” if the stock quantity is changed to 0? Right now I have a couple thousand products listed on my website. I update this list automatically everyday by using “CSV Import Suite”, I choose to “Merge Products” and upload the updated CSV. Using this process, all of my products are updated daily with the current quantity of each product remaining. But, even though a product has “0” listed for its quantity the product is still shown as “In Stock”- is there any way via Settings or some Plugin to have WooCommerce recognize that this product is “Out of Stock” and mark it as such? And when the product has stock added to it again it will be marked as “In Stock”?

    This would be very difficult and time consuming to do manually.

    Secondly, while this is not a major issue, is there a way to display the remaining quantity of stock on the product’s page? So instead of the product just being listed, it will show in the short description that there is: “X left in Stock”. Is there any good way to do this?

    Thanks all for your help, and I look forward to hearing from you.
    I would be glad to clarify anything if necessary.

    Thanks again,

Viewing 3 replies - 1 through 3 (of 3 total)
  • @branmatt, you can paste this code to your theme functions.php:

    add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
    function custom_price_html( $price, $product ){
        global $post;
        $sales_price_to = get_post_meta($post->ID, '_sale_price_dates_to', true);
        if(is_single() && $sales_price_to != "")
            $sales_price_date_to = date("j M y", $sales_price_to);
            return str_replace( '</ins>', ' </ins> <b>(Offer till '.$sales_price_date_to.')</b>', $price );
            return apply_filters( 'woocommerce_get_price', $price );

    Hope it helps.

    Hi @branmatt, sorry, i posted the wrong code, above code will add sales end date for product page.

    @terrytsang: So that code will not add either of the functions that I requested?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Automatically having products marked "Out of Stock" & Showing Stock Quantity’ is closed to new replies.