• Hello, I’m building a new site for a client using Woocommerce. They’re coming from Prestashop and are wanting to duplicate a a feature that they have on it:

    Display total amount of items in stock, and the last date the update was made.

    You can see an example here:

    https://www.bermoenterprises.com/

    I tried researching around for this but only thing I stumbled upon is showing the stock quantity for a particular product. I need the global quantity of everything in stock.

    Thanks for your help in advance.

    https://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
  • A shortcode to return the total number of products available. Unfortunately it won’t deal correctly with variations which have stock level set at variation level.

    // get number of products in the shop
      // usage: We have [products_available] available!
      // code goes in functions.php for your child theme
      add_shortcode('products_available', 'products_available');
      function products_available() {
        $args = array(
          'post_type' => 'product',
          'posts_per_page' => -1,
          'orderby' => '',
          'order' => '',
          'meta_query' => array(
            array(
            'key' => '_stock_status',
            'value' => 'instock',
            'compare' => '='
            )
          )
        );
        $loop = new WP_Query( $args );
        $products = $loop->posts;
        wp_reset_postdata();
        return count($products);
      }

    What is last update – just the current time?

Viewing 1 replies (of 1 total)
  • The topic ‘Display Stock Quantity & Last Update in Header’ is closed to new replies.