• Hello,

    I’d love to use your plugin but I need different out of stock messages for different categories. I found the following code, which works well on its own, but I have not been unable to combine it with your plugin. If you could offer some assistance, it would be most appreciated.

    function filter_woocommerce_get_availability( $availability, $product ) {
        // Specific categories
        $specific_categories = array( 'category-1', 'category-2' );
        
        // Out of stock and has certain category     
        if ( ! $product->is_in_stock() && has_term( $specific_categories, 'product_cat', $product->get_id() ) ) {
            $availability['availability'] = __('My custom text', 'woocommerce' );
        }
    
        return $availability;
    }
    add_filter( 'woocommerce_get_availability', 'filter_woocommerce_get_availability', 10, 2 );
  • The topic ‘Change by catogory’ is closed to new replies.