• Hi

    I’m trying to get the stock availability showing on the Product Archive page before the add to cart button and after the price but I can’t get it working.

    It is displaying the availability but above the product

    add_action( 'woocommerce_after_shop_loop_item', 'wc_loop_get_product_stock_availability_text', 10 ); 
    
    function wc_loop_get_product_stock_availability_text() {
        global $wpdb, $product;
    
        // For variable products
        if( $product->is_type('variable') ) {
        }
        // Other products types
        else {
            echo wc_get_stock_html( $product );
        }
    }

    Any help would be massively appreciated.

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Pleas e share the snapshot and page URL to see the issue.

    Thread Starter metcala

    (@metcala)

    Here is an example on the site – as you can see it shows the stock status at the start of each product loop. I’m after displaying it between price and add to basket.

    Thanks

    Hello,

    Try to replace the above code with this one and check.

    add_action( 'ocean_before_archive_product_add_to_cart', 'wc_loop_get_product_stock_availability_text', 10 ); 
    
    function wc_loop_get_product_stock_availability_text() {
        global $wpdb, $product;
    
        // For variable products
        if( $product->is_type('variable') ) {
        }
        // Other products types
        else {
            echo wc_get_stock_html( $product );
        }
    }
    Thread Starter metcala

    (@metcala)

    Thanks so much! Worked perfectly!

    You are most welcome and glad to hear that issue has been fixed!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Stock Availability on Product Archive’ is closed to new replies.