• 13-04-2024, 18:04:55
    #1
    Merhabalar
    Woocommerce ana sayfada gösterilen ürünlerde stok sayısını gösterecek bir eklenti yada bir kod arıyorum.
    Yardımcı olabilecek arkadaşlar varsa sevinirim
  • 13-04-2024, 20:36:49
    #2
    Selamlar, şu kodu functions.php dosyasına ekleyip dener misin?

    function add_stock_quantity_to_product_title( $title, $id ) {
        if ( is_shop() || is_product_category() || is_product() ) {
            $product = wc_get_product( $id );
            $stock_quantity = $product->get_stock_quantity();
            if ( ! empty( $stock_quantity ) && $stock_quantity > 0 ) {
                $title .= ' (' . sprintf( __( 'Stok: %d', 'woocommerce' ), $stock_quantity ) . ')';
            }
        }
    
        return $title;
    }
    
    add_filter( 'the_title', 'add_stock_quantity_to_product_title', 10, 2 );
    Stok sayısı listelenen ürün başlıklarının yanında parantez içinde gösterir. Kod çalışırsa siz özelleştirebilirsiniz.