skip to Main Content

I have a woocommerce website. I sell fabric. How can I change the stock status text?enter image description here

I checked the stock settings but couldn’t find it. Also, I couldn’t see the plugin like this. Can you help me?

2

Answers


  1. Chosen as BEST ANSWER

    add_filter('woocommerce_get_stock_html', 'custom_get_stock_html', 10, 2);

    function custom_get_stock_html($html, $product) { $availability = $product->get_availability();

    if (!empty($availability['availability'])) {
        ob_start();
    
        // Burada stok durumu için kullanılan template dosyasını kontrol ediyoruz
        wc_get_template(
            'single-product/stock.php',
            array(
                'product'      => $product,
                'class'        => $availability['class'],
                'availability' => $availability['availability'],
            )
        );
    
        // Template dosyasında 'Adet kaldı' metnini 'Metre kaldı' olarak değiştiriyoruz
        $html = str_replace('adet kaldı', 'metre kaldı', ob_get_clean());
    }
    
    return $html;
    

    }


  2. add_action('woocommerce_get_stock_html', 'woocommerce_get_stock_html_mod', 10, 2);
    function woocommerce_get_stock_html_mod($html, $product){
        return $html;
    }
    

    https://woocommerce.wp-a2z.org/oik_api/wc_get_stock_html/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search