• Hi,

    I am looking for find the code needed and where to implement said code so that it can display “out of stock” if that applies on any item on the main store front page instead of having to open each individual product to find it out that way instead. Currently you have to select the product picture/text or click the “read more” button to see the stock details.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • This will require the editing of the shop page which has the file name of ‘archive-product.php’. Now, if you want to edit this page then you must first be working with a child theme!

    If you don’t know what a child theme is then read this: Creating a Child Theme

    If you already are working with a child theme then within the theme folder create a folder called ‘woocommerce’. Then copy the file I told you about to this folder from the WooCommerce plugin folder by going to the main plugin folder -> templates.

    Thread Starter dpiffy

    (@dpiffy)

    Sorry if I am missing something but… what file? You said “Then copy the file I told you about” are you referring to the archive-product.php file? Either way, my biggest thing of all is what is the code to pull the item stock management to know rather or not to display the “out of stock” message or not?

    Copy
    wp-content/plugins/woocommerce/templates/archive-product.php
    to
    wp-content/themes/my-theme-directory/woocommerce/templates/archive-product.php

    Its the copy you are going to work on. If you mess up, your site might crash. Just rename the copy and WP will use the original file.

    You will need to edit the template to include a loop to cycle through your products, and find the stock for each product with:

    $items_for_sale = get_product($product_id)->get_stock_quantity( );

    More here.

    This is a development project. I think you’ll be lucky if someone will write, test and debug the code for you in a forum environment. Its a few hours work. The forum is aimed more at pointing users in the right direction. Ultimately if you can’t manage the coding you may have to post a job.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show Out of Stock on main page’ is closed to new replies.