Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1309416

    Hi,

    I’ve got some products which are out of stock, but it’s not mentioned on the catalogus price, so people only know it’s out of stock if they click on the product, and then people can see it mentioned. How can I remove the price of out of stock products on the catalogus page, and replace it with some text like ‘Out of stock’?

    Thanks a ton.

    #1309668

    Hey Jillian,

    Thank you for the inquiry.

    You can try this filter in the functions.php file to add an “out of stock” text when the product is not available.

    
    function wcs_stock_text_shop_page() {
        global $product;
        $availability = $product->get_availability();
    
        if ( $availability['availability'] == 'Out of stock') {
            echo apply_filters( 'woocommerce_stock_html', '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</p>', $availability['availability'] );
        }
    }
    add_action( 'woocommerce_after_shop_loop_item_title', 'wcs_stock_text_shop_page', 25 );
    

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Change price to 'out of stock' on catalogus pages’ is closed to new replies.