Merhabalar arkadaşlar can sıkıntısına basit düzeyde woocommerce için kendi ihtiyaç alanlarımı kolaylaştıran bazı kodları sizlerle paylaşmak istedim belki konu altına ek yapmak isteyenler olur.

Başlamadan önce dosyanızın yedeğini almayı unutmayın. Woodmart temasında kendim bu kodları kullanmaktayım.

Sipariş detayları alanında müşterinin tüm statülerini kapsayan geçmiş siparişleri görüntüleme :
// Sipariş sayfasında geçmiş siparişleri görüntüle
add_action( 'woocommerce_admin_order_data_after_order_details', 'show_customer_past_orders_in_admin_order', 10, 1 );

function show_customer_past_orders_in_admin_order( $order ){
    $customer_id = $order->get_user_id(); // Müşteri ID'sini al
    if( $customer_id ){
        $customer_orders = get_posts( array(
            'numberposts' => -1,
            'post_type'   => 'shop_order',
            'post_status' => array( 'wc-refunded', 'wc-cancelled', 'wc-failed', 'wc-completed' ),
            'meta_key'    => '_customer_user',
            'meta_value'  => $customer_id,
        ) );
        
        if( $customer_orders ){
            echo '<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">';
            echo '<h3>'.__('Geçmiş Siparişler').'</h3>';
            echo '<div class="table-responsive">';
            echo '<table class="table table-bordered">';
            echo '<thead class="thead-light"><tr><th>'.__('Sipariş ID', 'woocommerce').'</th><th>'.__('Tarih', 'woocommerce').'</th><th>'.__('Durum', 'woocommerce').'</th><th>'.__('Toplam', 'woocommerce').'</th></tr></thead>';
            echo '<tbody>';
            foreach( $customer_orders as $order_post ){
                $order = wc_get_order( $order_post->ID );
                echo '<tr>';
                echo '<td><a href="'.admin_url( 'post.php?post=' . absint( $order->get_id() ) . '&action=edit' ).'">#'.$order->get_order_number().'</a></td>';
                echo '<td>'.date_i18n( get_option( 'date_format' ), strtotime( $order->get_date_created() ) ).'</td>';
                echo '<td>'.$order->get_status().'</td>';
                echo '<td>'.$order->get_formatted_order_total().'</td>';
                echo '</tr>';
            }
            echo '</tbody>';
            echo '</table>';
            echo '</div>';
        }
    }
}


tasarım daha da özelleştirilebilir ben pek fazla önemsemedim.

Müşterinin Sipariş verdiği tarihin üstüne 10 gün ekleme yaparak termin süresi belirler ve admin panelimizde siparişlerim ekranında sadece "hazırlanıyor" statüsünde ki müşterilerin x gün termin süresi kaldığını gösterir. Süreyi kodun içerisinde güncelleyerek arttırabilir veya azaltabilirsiniz.

// Kargoya teslim tarihi sütunu ekleme sadece hazırlanıyor siparişleri için
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_columns', 20 );
function custom_shop_order_columns($columns)
{
    $reordered_columns = array();

    foreach( $columns as $key => $column ){
        $reordered_columns[$key] = $column;

        if( 'order_status' === $key ){
            $reordered_columns['shipping_date'] = __( 'Son Termin', 'woocommerce' );
        }
    }

    return $reordered_columns;
}

// Kargoya teslim tarihi sütununu doldurma sadece hazırlanıyor siparişleri için
add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 20, 2 );
function custom_orders_list_column_content( $column, $post_id )
{
    if ( 'shipping_date' === $column ) {
        $order = wc_get_order( $post_id );

        if( $order && $order->has_status('processing') ){ // Sadece hazırlanıyor siparişlerini göster
            $order_date = $order->get_date_created();
            $shipping_date = $order_date->modify('+10 days')->format('d-m-Y');

            $now = new DateTime();
            $shipping_datetime = new DateTime($shipping_date);
            $interval = $now->diff($shipping_datetime);

            $days_left = $interval->format('%a');

            echo '<p>' . $shipping_date . ' (' . $days_left . ' gün kaldı)</p>';
        }
    }
}


// Sipariş detayları sayfasına kargoya teslim tarihi bilgisini ekleme
add_action( 'woocommerce_admin_order_data_after_billing_address', 'add_shipping_date_to_admin_order', 10, 1 );
function add_shipping_date_to_admin_order( $order ){
    if( $order->has_status('processing') ) { // Sadece hazırlanıyor siparişleri için
        $order_date = $order->get_date_created();
        $shipping_date = $order_date->modify('+10 days')->format('d-m-Y');

        $now = new DateTime();
        $shipping_datetime = new DateTime($shipping_date);
        $interval = $now->diff($shipping_datetime);

        $days_left = $interval->format('%a');

        echo '<p><strong>' . __('Son Termin Tarihi', 'woocommerce') . ':</strong> ' . $shipping_date . ' (' . $days_left . ' gün kaldı)</p>';
    }
}

aynı şekilde tasarım daha özel hale getirilebilir.

Müşterinin hangi üründen kaç adet aldığını sipariş detaylarına girmeden gösteren basit bir kod yukarıda ki ss de görebilirsiniz.

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>";
}

Eklemeyi unuttuğum en basit bonus kodlar :

1-) Varsayılan ürün sıralamasını değiştirme :

add_filter( 'woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby' );
function custom_default_catalog_orderby() {
    return 'price'; // Ürünleri fiyata göre varsayılan olarak sırala
}
2-) Varsayılan ürün listeleme sayısını değiştirme :

add_filter( 'loop_shop_per_page', 'custom_loop_shop_per_page', 20 );
function custom_loop_shop_per_page( $cols ) {
    return 12; // Sayfa başına varsayılan olarak 12 ürün göster
}
3-) Ürün Detay sayfasına ekstra bilgi ekleme

add_action( 'woocommerce_single_product_summary', 'custom_product_additional_info', 25 );
function custom_product_additional_info() {
    echo '<p>Özel bilgi: Bu ürün hakkında ekstra bilgi.</p>';
}
4-) Kargo ücreti ekleme :

add_action( 'woocommerce_cart_calculate_fees', 'custom_shipping_fee' );
function custom_shipping_fee() {
    $shipping_cost = 5; // Kargo ücreti
    WC()->cart->add_fee( 'Kargo', $shipping_cost );
}

vakit buldukça bu tür basit işlemler ile gündelik hayatımı biraz daha hızlandıracak işlemler sağlıyorum ve sitemde paylaşıyorum bunları tamamen keyfi bilgi amaçlı paylaşmak istedim ek olarak düzenleme sağlarsanız veya sizlerde kod bilgisi paylaşırsanız konuya ek yapalım herkes faydalansın