'Show "on backorder" for products on archive pages instead of "in stock" in Woocommerce

In Woocommerce, I added code to display the stock status for my products. It works for products that are in stock and products that are out of stock. But for products that are "on backorder" it says "in stock". How can I change the displayed status text to "on backorder"?

Here is the code:

    //* Add stock status to archive pages
function envy_stock_catalog() {
    global $product;
    if ( $product->is_in_stock() ) {
        echo '<div class="stock" >' . $product->get_stock_quantity() . __( 'Op voorraad', 'envy' ) . '</div>';
    } else {
        echo '<div class="out-of-stock" >' . __( 'Uitverkocht', 'envy' ) . '</div>';
    }
}
add_action( 'woocommerce_after_shop_loop_item_title', 'envy_stock_catalog' );


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source