How can I add below of Woocommerce out of stock product text the Woocommerce product price on a single product

I have a single woocommerce product page where only availability "Out of Stock" message is shown. How can I show a formatted price with currency below that text?

I think I need to insert the following

<p class="price"><span class="woocommerce-Price-amount amount">(PRODUCT PRICE) &nbsp;<span class="woocommerce-Price-currencySymbol">€</span></span></p>

but I dont know how

This is happening to all simple products. As settings, stock management is disabled. I don't know why price is not displayed. I tried to disable some plugins maybe related to that. Like wooocommerce add ons, or discontinued products plugins. I use wp-rocket. The link of a product maybe help you

https://bestfamily.gr/product/steelseries-headset-arctis-pro-wireless-bt/

Solutions

You should be able to use something like

<?php
global $product;
$price = $product->get_price();

<p class="price"><span class="woocommerce-Price-amount amount"><?php echo $price; ?> &nbsp;<span class="woocommerce-Price-currencySymbol">€</span></span></p>

You would have to put that in a custom template . If you aren't using one then you could display it below the "add to cart" button using a hook, but as far as I know there isn't any kind of "after stock status" hook.

add_action( 'woocommerce_after_add_to_cart_button', 'add_price_below_button' );
function add_price_below_button() {
    global $product;
    $price = $product->get_price();

    echo '<p class="price"><span class="woocommerce-Price-amount amount">' . $price . ' &nbsp;<span class="woocommerce-Price-currencySymbol">€</span></span></p>';
}

If you only want to display the price if the product is out of stock:

add_action( 'woocommerce_after_add_to_cart_button', 'add_price_below_button' );
function add_price_below_button() {
    global $product;

    if ( $product->get_stock_quantity() <= 0 ) {

        $price = $product->get_price();

        echo '<p class="price"><span class="woocommerce-Price-amount amount">' . $price . ' &nbsp;<span class="woocommerce-Price-currencySymbol">€</span></span></p>';

    }
}

Also as a side note, if Euros is your default currency then you should be able to use get_woocommerce_currency_symbol() to display it.

Similar questions

Add text after price unless the price is zero, then Call for price in WooCommerce
I have products with prices that need to all end with "per sq. ft." I want this to only apply to products of a particular category and only when the price is greater than 0. When the product has no price listed I need the price to say "Call for Price" without the square footage text after it. So here is a start I found online but they dont have any...
Add to Out-of-stock availability text, an availability date in Woocommerce single products
I have following code that adds a simple notice to a single product: If statement is not working, but else statement works perfect. What I am doing wrong? Any help is appreciated.
Woocommerece category page showing in stock product as out of stock
All variations of the product has a stock. but still it is showing out of stock in wordpress backend and in product category page, but when we go to the single product page that product is available we can buy that product. Things i tried: Below images are for your reference. Stock quantity. Backend products page. Category page. Single product page...
Woocommerce Admin Filter by In Stock / Out Of Stock
I found some code (below) which I modified to put an extra filter on the products page in woo commerce to filter by in stock and out of stock. I can get out of stock to work, but just cannot figure out how to make it work by in stock.. I know it has to do with this line 'In Stock' => '=<1', but cannot figure out what it is meant to be. Help is g...
woocommerce sort products by in stock and out of stock in front-end
I want to show in stock products first in products category or if possible in any where and then I want to display out of stock products too after them in Woocommerce Actually there are many products which have not quantity number but those are in stock, So it is need to check in stock status, But I prefer to have more quantities first How can I ma...
Unable to get products that are both In-Stock and Out-of-Stock WC_Product_Query Woocommerce
I'm using new WC_Product_Query to get products for a stock report but so far I'm only able to set In-stock or Out-of-Stock in the query. How do I go about setting the query to get all products regardless of stock status or set it to just grab In-stock and Out-of-Stock products as we don't use backorders? Its probably worth mentioning that if i use ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .