Replacing price & "out of stock" notice on Single Product page
-
Hello there!
I am trying to figure out how to change the single product page for out of stock products so that they no longer show the price. I would like them instead to say ‘Sold Out’ IN PLACE OF the price (I.E. in the same location & format), and also remove the default ‘Out of stock’ indicator with the little ! symbol.I feel like what I want to achieve here is relatively straight forward… But I am having a heck of a time trying to figure out how to get this to work using hooks/filters.
I managed to get ‘Sold Out’ to replace the price the way I want it in the shop loop by adding this code to my functions.php:
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); add_action( 'woocommerce_after_shop_loop_item_title', 'custom_template_loop_price', 10 ); function custom_template_loop_price() { global $product; if ( ! $product->is_in_stock() ) { echo '<span class="price">' . __( 'Sold Out','woocommerce' ) . '</span>'; } else { woocommerce_get_template( 'loop/price.php' ); } }
but I can’t seem to figure out a working version for single products… Any thoughts?
- The topic ‘Replacing price & "out of stock" notice on Single Product page’ is closed to new replies.