Black Friday: $40 off GeneratePress One. See pricing

Archived topic

How to s

5 replies · Started by Jaime on December 3, 2020

Viewing posts 1–6 of 6

I am using the below code to hide the "Out Of Stock" status from the products which are out of stock because I am showing them for pre-order.

.woocommerce div.product .out-of-stock {
display: none;
}
.woocommerce div.product p.stock {
display: none;
}

It is working good... But now I want to show the Out Of Stock on products but when removing this code, out of stock is showing on all products even on Pre-order.

All the pre-orders products are showing because I have created a particular "pre-order" tag for them. So, I want to show the out of stock status but not for the products that they pre-order tag.

So, it is possible to hide the Out Of Stock from pre-order tagged products only...

Can you customize it a bit for me? Thanks for your help!

Hi there,

maybe this stack overflow method would be a good solution:

https://stackoverflow.com/a/41162894

It will allow you to change the Sold Out text to something else on products with a certain tag.

Hey, David!

It is working as I wanted... Just one more help, I want to change the Out Of Stock text to Sold Out.

Can you help with this?

Thanks

I am using the code:


add_filter('woocommerce_get_availability', 'availability_filter_func');
function availability_filter_func($availability)
{
$availability['availability'] = str_ireplace('Out of stock', 'Sold Out', $availability['availability']);
return $availability;
}

But it is again showing for all the products, including pre-order tagged also. Can you customize it a bit so It doesn't show on pre-order tagged products?

Thanks

This archived topic is closed to new replies.