Hello Air,
I have been trying to replace the "Out of Stock" ribbon with "Sold" on the product list/single product pages, but I can't seem to be able to do it successfully. I wanted to do it for a specific category category only as we are selling one-of-a-kind pieces in this category. I've tried different snippets that I found online; however, no luck.
Ideally, it would be nice suppress the "Out of Stock" ribbon and display a "Sold" badge instead, but if it's too complicated the one described above would work, too.
Wondering if you can help me replace the relevant code in the theme?
Thank you in advance!
Comments
OK, let us start with a general solution first:
You can rename this ribbon in rife\advance\utilities\woocommerce.php line ~325
Change:
$html .= '<span class="ribbon out-of-stock"><em>'.esc_html__( 'Out of stock', 'rife' ).'</em></span>';
to
$html .= '<span class="ribbon out-of-stock"><em>'.esc_html__( 'Sold', 'rife' ).'</em></span>';
If you want to remove this ribbon, then you can just remove above mentioned line, or comment it out, like this(double slash in front):
//$html .= '<span class="ribbon out-of-stock"><em>'.esc_html__( 'Out of stock', 'rife' ).'</em></span>';
If you want to change/remove it only for a particular category use such code instead: Hope that helps.
With kind regards.
Thank you for the above.
Unfortunately, it didn't work for me... I placed the file in the child theme folder as I didn't want the code to be replaced when the theme gets updated. Also, in the file it was 'rife' instead of 'fatmoon', so that's what I used.
I wonder if there's something that I did wrong?
Thank you.
No clue. I have tested those changes before posting and they work fine.
Try editing the main theme. If it will work fine, then move those changes to the child theme. Otherwise, there are too many "moving parts "to know where the fail happened.
With kind regards.