• 21-01-2024, 19:22:14
    #19
    Gelistirici adlı üyeden alıntı: mesajı görüntüle
    Teşekkürler.
  • 22-01-2024, 22:36:52
    #20
    Elinize sağlık bende şöyle amatörce sağdan soldan bulduğum kodlar ile bazı geliştirmeler yapmıştım paylaşmak istedim belki işine yarayan olur :

    Ödeme sayfasında şirket adı ve vergi numarası ekleyerek admin panelinde sipariş detaylarında belirgin hale getirerek kendi anlayacağım gibi basit bir hale getirmiştim daha doğrusu muhasebede çalışan ekip arkadaşımız için en basit hale getirmek istemiştim :

    add_action( 'woocommerce_admin_order_data_after_billing_address', 'kurumsal_fatura_meta_box' );
    
    function kurumsal_fatura_meta_box( $order ){
        echo '
    <b><font color="red">KURUMSAL FATURA! ( BOŞ İSE BİREYSEL! ) </font></b>
    &ensp; &ensp;
    ';
        echo '
    <p><font color="red"><b>Şirket Adı:</b></font> ' . get_post_meta( $order->get_id(), '_kurumsal_fatura_sirketi', true ) . '
     &ensp;
    ';
        echo '
    <font color="red"><b>Vergi Numarası:</b></font> ' . get_post_meta( $order->get_id(), '_kurumsal_fatura_vergi_numarasi', true ) . '
    
    ';
    }
    add_action( 'woocommerce_checkout_create_order', 'save_kurumsal_fatura_fields', 20, 2 );
    
    function save_kurumsal_fatura_fields( $order, $data ){
        if( isset( $_POST['_kurumsal_fatura_sirketi'] ) ) {
            $order->update_meta_data( '_kurumsal_fatura_sirketi', sanitize_text_field( $_POST['_kurumsal_fatura_sirketi'] ) );
        }
    
        if( isset( $_POST['_kurumsal_fatura_vergi_numarası'] ) ) {
            $order->update_meta_data( '_kurumsal_fatura_vergi_numarasi', sanitize_text_field( $_POST['_kurumsal_fatura_vergi_numarasi'] ) );
        }
    }
    add_action( 'woocommerce_after_checkout_billing_form', 'kurumsal_fatura_fields' );
    
    function kurumsal_fatura_fields( $checkout ) {
        
       
         echo '
    ' . __('Kurumsal Fatura Bilgileri') . '
    ';
       
        woocommerce_form_field( '_kurumsal_fatura_sirketi', array(
            'type'          => 'text',
            'class'         => array('kurumsal-fatura-sirketi form-row-wide'),
            'label'         => __('Fatura Şirketi'),
            'placeholder'   => __('Fatura Şirketi'),
            ), $checkout->get_value( '_kurumsal_fatura_sirketi' ));
    
        woocommerce_form_field( '_kurumsal_fatura_vergi_numarasi', array(
            'type'          => 'text',
            'class'         => array('kurumsal-fatura-vergi-numarasi form-row-wide'),
            'label'         => __('Vergi Numarası'),
            'placeholder'   => __('Vergi Numarası'),
            ), $checkout->get_value( '_kurumsal_fatura_vergi_numarasi' ));
       
        echo '
    ';
    }
    Burada ise siparişlerim sayfasında müşterinin aldığı ürünleri adetleri ve görselleri küçük görsel ile panelde tek tek sipariş detaylarına girmeye gerek kalmadan gösteren hale getirmek amaçlı oluşturdum :

        add_action('manage_shop_order_posts_custom_column', 'orders_list_preview_items', 20, 2 );
    function orders_list_preview_items($column, $post_id) {
        
        global $the_order, $post;
        
        if ('order_status' === $column) {
            
            // Start list
            echo '<ul class="orders-list-items-preview">';
            
            // Loop through order items
            foreach($the_order->get_items() as $item) {
                
                $product = $item->get_product();
                $img     = wp_get_attachment_url($product->get_image_id());
                
                $name    = $item->get_name();
                $qty     = $item->get_quantity();
                
                echo "<li>
                    <img src=\"$img\" />
                    <label>$qty</label> $name
                </li>";
            }
            
            // End list
            echo '</ul>';
        }
        
        
    }
    
    
    add_action('admin_head', 'orders_list_preview_css');
    function orders_list_preview_css() {
      echo "<style>
        .orders-list-items-preview {
            background-color: #eee;
            padding: 8px 8px 0 5px;
            border-radius: 4px;
        }
        .orders-list-items-preview li {
            padding-left: 55px;
            position: relative;
            padding-bottom: 10px;
            padding-right: 40px;
            padding-top: 0;
            font-size: 10px;
            line-height: 11px;
            min-height: 30px;
        }
        .orders-list-items-preview li label {
            border: 1px solid gray;
            width: 25px;
            display: block;
            text-align: center;
            border-radius: 4px;
            right: 5px;
            top: 0px;
            position: absolute;
            font-size: 12px;
            font-weight: bold;
            padding: 5px 0;
        }
        .orders-list-items-preview img {
            margin: 1px 2px;
            position: absolute;
            left: 0;
            top: 0;
            height: 40px;
            max-height: 40px !important;
        }
      </style>";
    }
  • 23-01-2024, 12:36:38
    #21
    Anestezy adlı üyeden alıntı: mesajı görüntüle
    Elinize sağlık bende şöyle amatörce sağdan soldan bulduğum kodlar ile bazı geliştirmeler yapmıştım paylaşmak istedim belki işine yarayan olur :

    Ödeme sayfasında şirket adı ve vergi numarası ekleyerek admin panelinde sipariş detaylarında belirgin hale getirerek kendi anlayacağım gibi basit bir hale getirmiştim daha doğrusu muhasebede çalışan ekip arkadaşımız için en basit hale getirmek istemiştim :

    add_action( 'woocommerce_admin_order_data_after_billing_address', 'kurumsal_fatura_meta_box' );
    
    function kurumsal_fatura_meta_box( $order ){
        echo '
    <b><font color="red">KURUMSAL FATURA! ( BOŞ İSE BİREYSEL! ) </font></b>
    &ensp; &ensp;
    ';
        echo '
    <p><font color="red"><b>Şirket Adı:</b></font> ' . get_post_meta( $order->get_id(), '_kurumsal_fatura_sirketi', true ) . '
     &ensp;
    ';
        echo '
    <font color="red"><b>Vergi Numarası:</b></font> ' . get_post_meta( $order->get_id(), '_kurumsal_fatura_vergi_numarasi', true ) . '
    
    ';
    }
    add_action( 'woocommerce_checkout_create_order', 'save_kurumsal_fatura_fields', 20, 2 );
    
    function save_kurumsal_fatura_fields( $order, $data ){
        if( isset( $_POST['_kurumsal_fatura_sirketi'] ) ) {
            $order->update_meta_data( '_kurumsal_fatura_sirketi', sanitize_text_field( $_POST['_kurumsal_fatura_sirketi'] ) );
        }
    
        if( isset( $_POST['_kurumsal_fatura_vergi_numarası'] ) ) {
            $order->update_meta_data( '_kurumsal_fatura_vergi_numarasi', sanitize_text_field( $_POST['_kurumsal_fatura_vergi_numarasi'] ) );
        }
    }
    add_action( 'woocommerce_after_checkout_billing_form', 'kurumsal_fatura_fields' );
    
    function kurumsal_fatura_fields( $checkout ) {
        
      
         echo '
    ' . __('Kurumsal Fatura Bilgileri') . '
    ';
      
        woocommerce_form_field( '_kurumsal_fatura_sirketi', array(
            'type'          => 'text',
            'class'         => array('kurumsal-fatura-sirketi form-row-wide'),
            'label'         => __('Fatura Şirketi'),
            'placeholder'   => __('Fatura Şirketi'),
            ), $checkout->get_value( '_kurumsal_fatura_sirketi' ));
    
        woocommerce_form_field( '_kurumsal_fatura_vergi_numarasi', array(
            'type'          => 'text',
            'class'         => array('kurumsal-fatura-vergi-numarasi form-row-wide'),
            'label'         => __('Vergi Numarası'),
            'placeholder'   => __('Vergi Numarası'),
            ), $checkout->get_value( '_kurumsal_fatura_vergi_numarasi' ));
      
        echo '
    ';
    }
    Burada ise siparişlerim sayfasında müşterinin aldığı ürünleri adetleri ve görselleri küçük görsel ile panelde tek tek sipariş detaylarına girmeye gerek kalmadan gösteren hale getirmek amaçlı oluşturdum :

        add_action('manage_shop_order_posts_custom_column', 'orders_list_preview_items', 20, 2 );
    function orders_list_preview_items($column, $post_id) {
        
        global $the_order, $post;
        
        if ('order_status' === $column) {
            
            // Start list
            echo '<ul class="orders-list-items-preview">';
            
            // Loop through order items
            foreach($the_order->get_items() as $item) {
                
                $product = $item->get_product();
                $img     = wp_get_attachment_url($product->get_image_id());
                
                $name    = $item->get_name();
                $qty     = $item->get_quantity();
                
                echo "<li>
                    <img src=\"$img\" />
                    <label>$qty</label> $name
                </li>";
            }
            
            // End list
            echo '</ul>';
        }
        
        
    }
    
    
    add_action('admin_head', 'orders_list_preview_css');
    function orders_list_preview_css() {
      echo "<style>
        .orders-list-items-preview {
            background-color: #eee;
            padding: 8px 8px 0 5px;
            border-radius: 4px;
        }
        .orders-list-items-preview li {
            padding-left: 55px;
            position: relative;
            padding-bottom: 10px;
            padding-right: 40px;
            padding-top: 0;
            font-size: 10px;
            line-height: 11px;
            min-height: 30px;
        }
        .orders-list-items-preview li label {
            border: 1px solid gray;
            width: 25px;
            display: block;
            text-align: center;
            border-radius: 4px;
            right: 5px;
            top: 0px;
            position: absolute;
            font-size: 12px;
            font-weight: bold;
            padding: 5px 0;
        }
        .orders-list-items-preview img {
            margin: 1px 2px;
            position: absolute;
            left: 0;
            top: 0;
            height: 40px;
            max-height: 40px !important;
        }
      </style>";
    }
    teşekkürler 2. özellıkle işlevsellik açısından cok iyi siteme ekledım.
  • 31-01-2024, 16:28:22
    #22
    Ücretsiz kargo seçeneği aktifken diğer kargo yöntemlerini gizler.

    /**
     * EĞER ÜCRETSİZ GÖNDERİ AKTİF İSE DİĞER GÖNDERİ YÖNTEMLERİNİ GİZLE
     */
    function hide_shipping_when_free_is_available( $rates, $package ) {
        $new_rates = array();
        foreach ( $rates as $rate_id => $rate ) {
            // Only modify rates if free_shipping is present.
            if ( 'free_shipping' === $rate->method_id ) {
                $new_rates[ $rate_id ] = $rate;
                break;
            }
        }
        if ( ! empty( $new_rates ) ) {
            //Save local pickup if it's present.
            foreach ( $rates as $rate_id => $rate ) {
                if ('local_pickup' === $rate->method_id ) {
                    $new_rates[ $rate_id ] = $rate;
                    break;
                }
            }
            return $new_rates;
        }
        return $rates;
    }
    add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
  • 01-02-2024, 16:40:39
    #23
    Anestezy adlı üyeden alıntı: mesajı görüntüle
    Elinize sağlık bende şöyle amatörce sağdan soldan bulduğum kodlar ile bazı geliştirmeler yapmıştım paylaşmak istedim belki işine yarayan olur :

    Ödeme sayfasında şirket adı ve vergi numarası ekleyerek admin panelinde sipariş detaylarında belirgin hale getirerek kendi anlayacağım gibi basit bir hale getirmiştim daha doğrusu muhasebede çalışan ekip arkadaşımız için en basit hale getirmek istemiştim :

    add_action( 'woocommerce_admin_order_data_after_billing_address', 'kurumsal_fatura_meta_box' );
    
    function kurumsal_fatura_meta_box( $order ){
        echo '
    <b><font color="red">KURUMSAL FATURA! ( BOŞ İSE BİREYSEL! ) </font></b>
    &ensp; &ensp;
    ';
        echo '
    <p><font color="red"><b>Şirket Adı:</b></font> ' . get_post_meta( $order->get_id(), '_kurumsal_fatura_sirketi', true ) . '
     &ensp;
    ';
        echo '
    <font color="red"><b>Vergi Numarası:</b></font> ' . get_post_meta( $order->get_id(), '_kurumsal_fatura_vergi_numarasi', true ) . '
    
    ';
    }
    add_action( 'woocommerce_checkout_create_order', 'save_kurumsal_fatura_fields', 20, 2 );
    
    function save_kurumsal_fatura_fields( $order, $data ){
        if( isset( $_POST['_kurumsal_fatura_sirketi'] ) ) {
            $order->update_meta_data( '_kurumsal_fatura_sirketi', sanitize_text_field( $_POST['_kurumsal_fatura_sirketi'] ) );
        }
    
        if( isset( $_POST['_kurumsal_fatura_vergi_numarası'] ) ) {
            $order->update_meta_data( '_kurumsal_fatura_vergi_numarasi', sanitize_text_field( $_POST['_kurumsal_fatura_vergi_numarasi'] ) );
        }
    }
    add_action( 'woocommerce_after_checkout_billing_form', 'kurumsal_fatura_fields' );
    
    function kurumsal_fatura_fields( $checkout ) {
        
      
         echo '
    ' . __('Kurumsal Fatura Bilgileri') . '
    ';
      
        woocommerce_form_field( '_kurumsal_fatura_sirketi', array(
            'type'          => 'text',
            'class'         => array('kurumsal-fatura-sirketi form-row-wide'),
            'label'         => __('Fatura Şirketi'),
            'placeholder'   => __('Fatura Şirketi'),
            ), $checkout->get_value( '_kurumsal_fatura_sirketi' ));
    
        woocommerce_form_field( '_kurumsal_fatura_vergi_numarasi', array(
            'type'          => 'text',
            'class'         => array('kurumsal-fatura-vergi-numarasi form-row-wide'),
            'label'         => __('Vergi Numarası'),
            'placeholder'   => __('Vergi Numarası'),
            ), $checkout->get_value( '_kurumsal_fatura_vergi_numarasi' ));
      
        echo '
    ';
    }
    Hocam çok teşekkürler öncelikle çok kullanışlı olmuş. Ödeme sayfasında şirket adı ve vergi numarası eklediğin scripte TCKN de ekleyebiliyor musun? zorunlu olarak. çok ihtiyacım var 20'den fazla eklenti denedim. farklı scriptler denedim çalışmadı doğru dürüst.
  • 01-02-2024, 20:40:58
    #24
    yusufyuxel adlı üyeden alıntı: mesajı görüntüle
    Hocam çok teşekkürler öncelikle çok kullanışlı olmuş. Ödeme sayfasında şirket adı ve vergi numarası eklediğin scripte TCKN de ekleyebiliyor musun? zorunlu olarak. çok ihtiyacım var 20'den fazla eklenti denedim. farklı scriptler denedim çalışmadı doğru dürüst.
    Ben teşekkür ederim, en basit TC ekleme kodunu alta bırakıyorum :

    // Kimlik numarası alanını siparişe ekleme
    add_action( 'woocommerce_after_order_notes', 'add_custom_billing_field' );
    function add_custom_billing_field( $checkout ) {
    
        echo '
    ' . __('T.C Kimlik Numarası') . '
    ';
    
        woocommerce_form_field( 'identity_number', array(
            'type'          => 'text',
            'class'         => array('form-row-wide'),
            'label'         => __('T.C Kimlik Numarası'),
            'placeholder'   => __('T.C Kimlik Numaranızı giriniz'),
            ), $checkout->get_value( 'identity_number' ));
    
        echo '
    ';
    }
    
    // Kimlik numarasını siparişe kaydetme
    add_action( 'woocommerce_checkout_update_order_meta', 'save_custom_billing_field');
    function save_custom_billing_field( $order_id ) {
        if ( ! empty( $_POST['identity_number'] ) ) {
            update_post_meta( $order_id, 'T.C Kimlik Numarası', sanitize_text_field( $_POST['identity_number'] ) );
        }
    }
    
    // Kimlik numarasının sipariş detaylarında görüntülenmesi
    add_action( 'woocommerce_admin_order_data_after_billing_address', 'display_custom_billing_field', 10, 1 );
    function display_custom_billing_field($order){
        echo '
    ' . __('T.C Kimlik Numarası') . ': ' . get_post_meta( $order->get_id(), 'T.C Kimlik Numarası', true ) . '
    
    ';
    }
  • 02-02-2024, 10:43:59
    #25
    Hocam bu da harika ellerine sağlık
  • 03-02-2024, 21:59:30
    #26
    Güzel paylaşımlar hocam rica etsem otomatik kur güncelleme ve çevirme kodlarını paylaşabilir misiniz.
  • 27-09-2024, 10:08:10
    #27
    Checkout sayfasında telefon numarasında bayraklı ülke seçme ve numarayı doğru yazdırmak için gerekli kodlar.

    add_action( 'wp_enqueue_scripts', 'ts_add_phone_mask' );
    
    function ts_add_phone_mask() {
        wp_enqueue_style( 'intltelinput', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/css/intlTelInput.min.css' );
        wp_enqueue_script( 'intltelinput', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/intlTelInput-jquery.min.js', array( 'jquery' ), '', true );
    }
    
    // Initialize the phone mask script
    add_action( 'wp_footer', 'ts_init_phone_mask' );
    
    function ts_init_phone_mask() {
        ?>
        <script>
            jQuery( function( $ ) {
                // Add the phone mask to the phone field on the checkout page
                $( '#billing_phone' ).intlTelInput( {
                    preferredCountries: [ 'IN' ],
                    nationalMode: false,
                    utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.js"
                } );
            } );
        </script>
        <style>
            .iti { width: 100%; }
        </style>
        <?php
    }