79708488

Date: 2025-07-21 02:27:11
Score: 2.5
Natty:
Report link

none of these is modifying my variable product out of stock message, still displays

This product is currently out of stock and unavailable.

Ive also tried this snippet

// Universal out-of-stock message for all product types (simple, variable, variations)
add_filter('woocommerce_get_availability_text', function($availability, $product) {
    if (!$product->is_in_stock()) {
        return 'Seems like this product may be only available via special order. Please <a href="/contact/">contact us</a>.';
    }
    return $availability;
}, 10, 2);

add_filter('woocommerce_get_availability', function($availability, $product) {
    if (!$product->is_in_stock()) {
        $availability['availability'] = 'Seems like this product may be only available via special order. Please <a href="/contact/">contact us</a>.';
    }
    return $availability;
}, 10, 2);

and this one too

add_filter('the_content', function($content) {
    $search = 'This product is currently out of stock and unavailable.';
    $replace = 'Seems like this product may be only available via special order. Please <a href="/contact/">contact us</a>.';
    if (strpos($content, $search) !== false) {
        $content = str_replace($search, $replace, $content);
    }
    return $content;
});

Nothing modifies that out of stock product on the variable products that have no price, any ideas?

Reasons:
  • Blacklisted phrase (1): any ideas
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Lautaro Gatti