✏️ 正在编辑: orders.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/myaccount/orders.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * Orders * @see https://woocommerce.com/document/template-structure/ * @package WooCommerce\Templates * @version 9.5.0 */ defined('ABSPATH') || exit; if (!function_exists('wc_get_orders')) { return; } $user_id = get_current_user_id(); if (!$user_id) { return; } /** * Resolve current page for Woo My Account Orders * Supports: * - standard WP paged * - Woo endpoint query var like: orders = "page/2" */ $current_page = 1; $paged = absint(get_query_var('paged')); if ($paged > 0) { $current_page = $paged; } else { $orders_qv = (string) get_query_var('orders'); if ($orders_qv && preg_match('~/page/(\d+)(?:/|$)~', $orders_qv, $m)) { $current_page = max(1, (int) $m[1]); } elseif ($orders_qv && ctype_digit($orders_qv)) { $current_page = max(1, (int) $orders_qv); } } $per_page = 6; $statuses = array_keys(wc_get_order_statuses()); $order_type = 'shop_order'; $results = wc_get_orders([ 'customer' => $user_id, 'type' => $order_type, 'status' => $statuses, 'orderby' => 'date', 'order' => 'DESC', 'paginate' => true, 'limit' => $per_page, 'page' => max(1, (int) $current_page), 'return' => 'objects', ]); $orders = (is_object($results) && isset($results->orders) && is_array($results->orders)) ? $results->orders : []; $total_orders = (is_object($results) && isset($results->total)) ? (int) $results->total : 0; $total_pages = (int) ceil($total_orders / max(1, $per_page)); $demo = get_option('datis_active_demo'); $base_url = function_exists('wc_get_account_endpoint_url') ? wc_get_account_endpoint_url('orders') : get_pagenum_link(1); $base_url = trailingslashit($base_url); ?> <div class="orders-shell"> <div class="orders-card"> <?php if (!empty($orders)) : ?> <div class="orders-titlebar"> <h2 class="orders-title"><?php echo esc_html_x('My orders', 'Orders title', 'datis'); ?></h2> </div> <div class="orders-table"> <div class="orders-headrow"> <div class="orders-col orders-col-track"><?php echo esc_html_x('Tracking code', 'Orders head', 'datis'); ?></div> <div class="orders-col orders-col-date"><?php echo esc_html_x('Order date', 'Orders head', 'datis'); ?></div> <div class="orders-col orders-col-status"><?php echo esc_html_x('Status', 'Orders head', 'datis'); ?></div> <div class="orders-col orders-col-total"><?php echo esc_html_x('Total', 'Orders head', 'datis'); ?></div> <div class="orders-col orders-col-actions"><?php echo esc_html_x('Actions', 'Orders head', 'datis'); ?></div> </div> <div class="orders-body"> <?php foreach ($orders as $order) : if (!$order instanceof WC_Order) { continue; } $order_number = $order->get_order_number(); $date_obj = $order->get_date_created(); $date_text = $date_obj ? wc_format_datetime($date_obj) : ''; $total_html = $order->get_formatted_order_total(); $status_slug = $order->get_status(); $status_label = wc_get_order_status_name($status_slug); $status_class_map = [ 'processing' => 'status-processing', 'completed' => 'status-completed', 'pending' => 'status-pending', 'on-hold' => 'status-onhold', 'cancelled' => 'status-cancelled', 'refunded' => 'status-refunded', 'failed' => 'status-failed', ]; $status_class = $status_class_map[$status_slug] ?? 'status-default'; $view_url = $order->get_view_order_url(); ?> <div class="orders-row"> <div class="orders-cell orders-col-track" data-label="<?php echo esc_attr_x('Tracking code', 'Orders label', 'datis'); ?>"> <span class="orders-text orders-track"><?php echo esc_html($order_number); ?></span> </div> <div class="orders-cell orders-col-date" data-label="<?php echo esc_attr_x('Order date', 'Orders label', 'datis'); ?>"> <span class="orders-text"><?php echo esc_html($date_text); ?></span> </div> <div class="orders-cell orders-col-status" data-label="<?php echo esc_attr_x('Status', 'Orders label', 'datis'); ?>"> <span class="order-status <?php echo esc_attr($status_class); ?>"> <span class="order-status-dot" aria-hidden="true"></span> <span class="order-status-text"><?php echo esc_html($status_label); ?></span> </span> </div> <div class="orders-cell orders-col-total" data-label="<?php echo esc_attr_x('Total', 'Orders label', 'datis'); ?>"> <span class="orders-text"><?php echo wp_kses_post($total_html); ?></span> </div> <div class="orders-cell orders-col-actions" data-label="<?php echo esc_attr_x('Actions', 'Orders label', 'datis'); ?>"> <a class="orders-btn" href="<?php echo esc_url($view_url); ?>"> <?php echo esc_html_x('Order details', 'Orders action', 'datis'); ?> </a> </div> </div> <?php endforeach; ?> </div> </div> <?php if ($total_pages > 1 && class_exists('Datis_Pagination')) : ?> <div class="orders-pagination mt-4"> <?php echo Datis_Pagination::get_instance()->render(null, [ 'total' => $total_pages, 'current' => $current_page, 'base_url' => wc_get_account_endpoint_url('orders'), 'format' => 'page/%#%/', 'wrap_class' => 'datis-pagination-list', 'item_class' => 'datis-pagination-item', 'current_class' => 'is-current', ]); ?> </div> <?php endif; ?> <?php else : ?> <div class="empty-orders d-flex flex-column align-items-center justify-content-center gap-3 w-100"> <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="100" height="100" rx="20" fill="currentColor" fill-opacity="0.06" /> <path d="M43.25 36.5V34.25C43.25 30.5221 46.2721 27.5 50 27.5C53.7279 27.5 56.75 30.5221 56.75 34.25V36.5" stroke="currentColor" stroke-width="3" stroke-linecap="round" /> <path d="M43.6348 56.75C44.5614 59.3717 47.0617 61.25 50.0007 61.25C52.9397 61.25 55.44 59.3717 56.3666 56.75" stroke="currentColor" stroke-width="3" stroke-linecap="round" /> <path d="M68.5025 51.1828C67.1857 44.1602 66.5274 40.6488 64.0278 38.5744C61.5283 36.5 57.9558 36.5 50.8108 36.5H49.1881C42.0431 36.5 38.4706 36.5 35.9711 38.5744C33.4716 40.6488 32.8132 44.1602 31.4964 51.1828C29.6449 61.0579 28.7191 65.9955 31.4182 69.2477C34.1174 72.5 39.141 72.5 49.1881 72.5H50.8108C60.858 72.5 65.8816 72.5 68.5807 69.2477C70.1467 67.3608 70.4925 64.9066 70.1452 61.25" stroke="currentColor" stroke-width="3" stroke-linecap="round" /> </svg> <p><?php esc_html_e('Your order list is empty.', 'datis'); ?></p> <a href="<?php echo esc_url(wc_get_page_permalink('shop')); ?>"> <?php if ($demo === 'industry') : ?> <svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M12.7701 11.8579L10.8921 10.2077M0.750669 1.29699L9.2183 0.750029M0.750669 1.29699L1.29763 9.76463M0.750669 1.29699L8.63844 8.22758" stroke="#F5F5F5" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php elseif ($demo === 'business') : ?> <svg width="44" height="40" viewBox="0 0 44 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M10 40C4.47715 40 -1.95703e-07 35.5228 -4.37114e-07 30L-1.31134e-06 10C-1.55275e-06 4.47715 4.47715 -1.95703e-07 10 -4.37114e-07L33.1922 -1.45088e-06C39.6979 -1.73525e-06 44.4715 6.11389 42.8937 12.4254L37.8937 32.4254C36.7807 36.877 32.7809 40 28.1922 40L10 40Z" fill="#F9E65C" /> <path d="M15.3433 15.3139H22.3286M15.3433 15.3139V22.2992M15.3433 15.3139L21.4554 21.4261M24.657 24.6276L23.2017 23.1724" stroke="#0A2647" stroke-width="1.23483" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php else : ?> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M6 6H15M6 6V15M6 6L12.5 12.5M18 18L15.5 15.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> </svg> <?php endif; ?> <?php if ($demo === 'industry' || $demo === 'business') : ?> <?php echo esc_html_x('Shop', 'orders empty action', 'datis'); ?> <?php else : ?> <span><?php echo esc_html_x('Shop', 'orders empty action', 'datis'); ?></span> <?php endif; ?> </a> </div> <?php endif; ?> </div> </div>
💾 保存文件
← 返回文件管理器