• 27-01-2022, 02:12:13
    #1
    Merhaba, aşağıdaki kodu "echo $urunayrac . ' ' . $urunfiyat;" yerine
    $argumen = array(
            'meta_key' => '_price',
            'orderby' => 'meta_value_num',
            'order' => 'ASC',
            'limit'=> -1,
            'category' => array( 'denemekategorisi' ),
            'status' => 'publish',
    );
    $producter = wc_get_products( $argumen );
    foreach ($producter as $producted) {
        $urunbaslik = $producted->get_name();
        $urunfiyat = number_format($producted->get_price(), 2, '.', '');
        $urunid = $producted->get_id();
        $urunadi = explode(" ", $urunbaslik);
        $urunayrac = str_replace( array("@", "_", "."), '', $urunadi[1]);
        echo $urunayrac . ' ' . $urunfiyat;
    }
    buradaki kodlar gibi çıktısını almak istiyorum.

    $html = '<div class="urun">';
    $html .= '<select id="hesaplar">
    <option value="1" selected>1. seçenek</option>
    <option value="2">2. seçenek</option>
    <option value="3">3. seçenek</option>
    </select>';
    $html .= '</div>';
    return $html;
    yardımcı olabilir misiniz?
  • 27-01-2022, 02:21:29
    #2
    bu şekilde nasıl çıktı veriyor hata vs. ekrana ne basıyor
  • 27-01-2022, 02:22:35
    #3
    mimarkaan adlı üyeden alıntı: mesajı görüntüle
    bu şekilde nasıl çıktı veriyor hata vs. ekrana ne basıyor
    Ekrana sırasıyla woocommerce deneme kategorisinde bulunan ürünlerin
    ürün adını ve fiyatını basıyor sırasıyla ben aşağıdaki html 'e sırasıyla basması için uyarlamak istiyorum
  • 27-01-2022, 02:26:19
    #4
    Developer
    <?php
    $argumen = array(
        'meta_key' => '_price',
        'orderby' => 'meta_value_num',
        'order' => 'ASC',
        'limit'=> -1,
        'category' => array( 'denemekategorisi' ),
        'status' => 'publish',
    );
    $producter = wc_get_products( $argumen );
    $html = '<div class="urun"><select id="hesaplar">';
    foreach ($producter as $producted) {
    $urunbaslik = $producted->get_name();
    $urunfiyat = number_format($producted->get_price(), 2, '.', '');
    $urunid = $producted->get_id();
    $urunadi = explode(" ", $urunbaslik);
    $urunayrac = str_replace( array("@", "_", "."), '', $urunadi[1]);
    //echo $urunayrac . ' ' . $urunfiyat;
    $html .= '<option value="'.$urunayrac.'" selected>'.$urunadi.'</option>';
    }
    $html .= '</select></div>';
    echo $html;
    ?>
  • 27-01-2022, 02:27:25
    #5
    brown adlı üyeden alıntı: mesajı görüntüle
    <?php
    $argumen = array(
        'meta_key' => '_price',
        'orderby' => 'meta_value_num',
        'order' => 'ASC',
        'limit'=> -1,
        'category' => array( 'denemekategorisi' ),
        'status' => 'publish',
    );
    $producter = wc_get_products( $argumen );
    $html = '<div class="urun"><select id="hesaplar">';
    foreach ($producter as $producted) {
    $urunbaslik = $producted->get_name();
    $urunfiyat = number_format($producted->get_price(), 2, '.', '');
    $urunid = $producted->get_id();
    $urunadi = explode(" ", $urunbaslik);
    $urunayrac = str_replace( array("@", "_", "."), '', $urunadi[1]);
    //echo $urunayrac . ' ' . $urunfiyat;
    $html .= '<option value="'.$urunayrac.'" selected>'.$urunadi.'</option>';
    }
    $html .= '</select></div>';
    echo $html;
    ?>
    hocam bu kod doğru ancak value kısmında 1... 2... 3... 4... 5... diye otomatik doldurma işlemini yapmamız gerekiyor
  • 27-01-2022, 02:29:13
    #6
    Bu şekilde

    $html = '<div class="urun">';
    $html .= '<select id="hesaplar">';
    $argumen = array(
            'meta_key' => '_price',
            'orderby' => 'meta_value_num',
            'order' => 'ASC',
            'limit'=> -1,
            'category' => array( 'denemekategorisi' ),
            'status' => 'publish',
    );
    $producter = wc_get_products( $argumen );
    foreach ($producter as $producted) {
        $urunbaslik = $producted->get_name();
        $urunfiyat = number_format($producted->get_price(), 2, '.', '');
        $urunid = $producted->get_id();
        $urunadi = explode(" ", $urunbaslik);
        $urunayrac = str_replace( array("@", "_", "."), '', $urunadi[1]);
        $html .= '<option value="'. $urunid .'">'. $urunayrac . ' ' . $urunfiyat .'</option>';
    }
    $html .= '</select>';
    $html .= '</div>';
    return $html;
    • EralpCicekdagi
    EralpCicekdagi bunu beğendi.
    1 kişi bunu beğendi.
  • 27-01-2022, 02:33:28
    #7
    Misafir adlı üyeden alıntı: mesajı görüntüle
    Bu şekilde

    $html = '<div class="urun">';
    $html .= '<select id="hesaplar">';
    $argumen = array(
            'meta_key' => '_price',
            'orderby' => 'meta_value_num',
            'order' => 'ASC',
            'limit'=> -1,
            'category' => array( 'denemekategorisi' ),
            'status' => 'publish',
    );
    $producter = wc_get_products( $argumen );
    foreach ($producter as $producted) {
        $urunbaslik = $producted->get_name();
        $urunfiyat = number_format($producted->get_price(), 2, '.', '');
        $urunid = $producted->get_id();
        $urunadi = explode(" ", $urunbaslik);
        $urunayrac = str_replace( array("@", "_", "."), '', $urunadi[1]);
        $html .= '<option value="'. $urunid .'">'. $urunayrac . ' ' . $urunfiyat .'</option>';
    }
    $html .= '</select>';
    $html .= '</div>';
    return $html;
    elinize sağlık ürün id'lerine göre çekiyor ancak ben o idleri bildiğim için js kısmında uyarlama yapabilirim teşekkür ederimm
  • 27-01-2022, 02:35:22
    #8
    EralpCicekdagi adlı üyeden alıntı: mesajı görüntüle
    elinize sağlık ürün id'lerine göre çekiyor ancak ben o idleri bildiğim için js kısmında uyarlama yapabilirim teşekkür ederimm
    zaten value kısmında ürün'e ait olan id yazılı, JS tarafında bir şey yapmanıza gerek yok ID'ler için, select'e 1 tane onchange event'i atarsanız değişince bir JS function'ı seçilen ögenin hem value değerini hemde metni'ni alabilir zaten.
  • 27-01-2022, 02:42:21
    #9
    Misafir adlı üyeden alıntı: mesajı görüntüle
    zaten value kısmında ürün'e ait olan id yazılı, JS tarafında bir şey yapmanıza gerek yok ID'ler için, select'e 1 tane onchange event'i atarsanız değişince bir JS function'ı seçilen ögenin hem value değerini hemde metni'ni alabilir zaten.
    javascript'e foreach'in içinde bulunan kısmı nasıl çekebilirim?
    .html = '<script>'$("div.urun'.$productid.' #hesaplar").on("keyup change", function() {var yeniurun = document.getElementById("'.$productid.'_sepet");var value = $(this).find(":selected").val();
    kod bu şekilde