✏️ 正在编辑: thankyou.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/checkout/thankyou.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php if (!defined('ABSPATH')) exit(); /** * ---- Jalali helpers (no plugin dependency) ---- * NOTE: UI strings are in English (translatable). Only date numbers/month/week names are Persian via helpers. */ if (!function_exists('gregorian_to_jalali')) { function gregorian_to_jalali($gy, $gm, $gd, $mod = '') { $g_d_m = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334); $gy2 = ($gm > 2) ? ($gy + 1) : $gy; $days = 355666 + (365 * $gy) + ((int)(($gy2 + 3) / 4)) - ((int)(($gy2 + 99) / 100)) + ((int)(($gy2 + 399) / 400)) + $gd + $g_d_m[$gm - 1]; $jy = -1595 + (33 * ((int)($days / 12053))); $days %= 12053; $jy += 4 * ((int)($days / 1461)); $days %= 1461; if ($days > 365) { $jy += (int)(($days - 1) / 365); $days = ($days - 1) % 365; } if ($days < 186) { $jm = 1 + (int)($days / 31); $jd = 1 + ($days % 31); } else { $jm = 7 + (int)(($days - 186) / 30); $jd = 1 + (($days - 186) % 30); } return ($mod == '') ? array($jy, $jm, $jd) : $jy . $mod . $jm . $mod . $jd; } } if (!function_exists('view_format_jalali_ts')) { /** * Format a UTC timestamp as Jalali (Persian) date in site timezone. * Supported tokens: j,d,n,m,Y,y,F,l and separators ( / - , space ). */ function view_format_jalali_ts(int $ts, ?string $format = null): string { if ($ts <= 0) return ''; try { $tz = wp_timezone(); } catch (\Throwable $e) { $tz = new \DateTimeZone('UTC'); } if ($format === null) { $format = (string)get_option('date_format', 'j F Y'); } try { $dt = (new \DateTimeImmutable('@' . $ts))->setTimezone($tz); } catch (\Throwable $e) { return ''; } $gy = (int)$dt->format('Y'); $gm = (int)$dt->format('n'); $gd = (int)$dt->format('j'); [$jy, $jm, $jd] = gregorian_to_jalali($gy, $gm, $gd); $fa_months = [1 => 'فروردین', 2 => 'اردیبهشت', 3 => 'خرداد', 4 => 'تیر', 5 => 'مرداد', 6 => 'شهریور', 7 => 'مهر', 8 => 'آبان', 9 => 'آذر', 10 => 'دی', 11 => 'بهمن', 12 => 'اسفند']; $w = (int)$dt->format('w'); // 0=Sun..6=Sat $fa_weekdays = [0 => 'یکشنبه', 1 => 'دوشنبه', 2 => 'سهشنبه', 3 => 'چهارشنبه', 4 => 'پنجشنبه', 5 => 'جمعه', 6 => 'شنبه']; $fa_digits = function (string $s): string { $en = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; $fa = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; return str_replace($en, $fa, $s); }; $replacements = [ 'j' => (string)$jd, 'd' => str_pad((string)$jd, 2, '0', STR_PAD_LEFT), 'n' => (string)$jm, 'm' => str_pad((string)$jm, 2, '0', STR_PAD_LEFT), 'Y' => (string)$jy, 'y' => substr((string)$jy, -2), 'F' => $fa_months[$jm] ?? (string)$jm, 'l' => $fa_weekdays[$w] ?? '' ]; $out = ''; $len = strlen($format); for ($i = 0; $i < $len; $i++) { $ch = $format[$i]; $out .= isset($replacements[$ch]) ? $replacements[$ch] : $ch; } $use_fa_digits = apply_filters('view_use_fa_digits', true); return $use_fa_digits ? $fa_digits($out) : $out; } } if (!function_exists('view_weekday_fa')) { function view_weekday_fa(int $ts): string { return $ts > 0 ? view_format_jalali_ts($ts, 'l') : ''; } } if (!function_exists('view_date_fa')) { function view_date_fa(int $ts): string { $date_fmt = (string)get_option('date_format', 'j F Y'); return $ts > 0 ? view_format_jalali_ts($ts, $date_fmt) : ''; } } if (!function_exists('view_relative_days_en')) { // Relative label in English (translatable) function view_relative_days_en(int $target_ts, ?int $now_ts = null): string { if ($target_ts <= 0) return ''; $now_ts = $now_ts ?? current_datetime()->getTimestamp(); $days = (int)ceil(($target_ts - $now_ts) / DAY_IN_SECONDS); if ($days === 0) return __('Today', 'view'); if ($days > 0) { return sprintf(_n('%s day from now', '%s days from now', $days, 'view'), number_format_i18n($days)); } $days = abs($days); return sprintf(_n('%s day ago', '%s days ago', $days, 'view'), number_format_i18n($days)); } } /** @var WC_Order|false $order */ if (empty($order)) { $key = isset($_GET['key']) ? wc_clean((string)wp_unslash($_GET['key'])) : ''; $oid = $key ? wc_get_order_id_by_order_key($key) : 0; $order = $oid ? wc_get_order($oid) : false; } $has_order = ($order instanceof WC_Order); // -------- Normalize order data -------- if ($has_order) { $order_id = $order->get_id(); $order_number = (string)$order->get_order_number(); $created_at = $order->get_date_created(); $created_text = $created_at ? view_date_fa($created_at->getTimestamp()) : ''; $total_html = (string)$order->get_formatted_order_total(); $status_key = (string)$order->get_status(); $status_label = (string)wc_get_order_status_name($status_key); $is_paid = (bool)$order->is_paid(); $payment_title = (string)$order->get_payment_method_title(); $shipping_title = (string)$order->get_shipping_method(); $shipping_total = (float)$order->get_shipping_total(); $shipping_tax = (float)$order->get_shipping_tax(); $shipping_cost = wc_price($shipping_total + $shipping_tax); $tx_id = (string)$order->get_transaction_id(); $bank_ref = (string)$order->get_meta('_bank_reference_code'); $post_track = (string)$order->get_meta('_post_tracking_code'); $order_email = $order_email ? $order->get_meta('_shipping_email') : $order->get_meta('_billing_email'); } ?> <div class="thankyou thankyou-page mt-5"> <div class="thankyou-wrapper p-4"> <div class="thankyou-heading"> <?php echo wp_kses_post(apply_filters( 'woocommerce_thankyou_order_received_text', __('Thank you, your order has been received.', 'datis'), $order )); ?> </div> <div class="order-meta mt-4"> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Order number:', 'datis'); ?></div> <div class="meta-value">#<?php echo esc_html($order_number ?? ''); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Order date:', 'datis'); ?></div> <div class="meta-value"><?php echo esc_html($created_text); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Email:', 'datis'); ?></div> <div class="meta-value"><?php echo esc_html($order_email); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Final order amount:', 'datis'); ?></div> <div class="meta-value"><?php echo wp_kses_post($total_html); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Payment method:', 'datis'); ?></div> <div class="meta-value"><?php echo esc_html($payment_title); ?></div> </div> </div> </div> <div class="product-details"> <?php if ($has_order) : ?> <div class="order-items-header d-flex align-items-center"> <div class="col-6"><span class="order-item-title"><?php esc_html_e('Product name', 'datis'); ?></span></div> <div class="col-3"><span class="order-item-title"><?php esc_html_e('Price', 'datis'); ?></span></div> <div class="col-3"><span class="order-item-title"><?php esc_html_e('Quantity', 'datis'); ?></span> </div> </div> <?php foreach ($order->get_items(apply_filters('woocommerce_purchase_order_item_types', 'line_item')) as $item_id => $item) : $name = (string)$item->get_name(); $qty = absint($item->get_quantity()); $line_total = (float)$item->get_total() + (float)$item->get_total_tax(); $line_html = wc_price($line_total); ?> <div class="order-item-row d-flex align-items-center"> <div class="col-6 fw-bold order-item-name"><?php echo esc_html($name); ?></div> <div class="col-3 order-item-price"><?php echo wp_kses_post($line_html); ?></div> <div class="col-3 order-item-qty"> <?php echo sprintf( /* translators: %s: quantity */ _n('%s item', '%s items', $qty, 'datis'), number_format_i18n($qty) ); ?> </div> </div> <?php endforeach; ?> <?php else : ?> <p class="mt-4"><?php esc_html_e('Order not found.', 'datis'); ?></p> <?php endif; ?> </div> <div class="final-order-meta mt-4 gap-5"> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Final order amount:', 'datis'); ?></div> <div class="meta-value"><?php echo wp_kses_post($total_html); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php esc_html_e('Order stage:', 'datis'); ?></div> <div class="meta-value"><?php echo esc_html($status_label); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Shipping cost:', 'datis'); ?></div> <div class="meta-value"><?php echo wp_kses_post($shipping_cost ?? ''); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Shipping method:', 'datis'); ?></div> <div class="meta-value"><?php echo esc_html($shipping_title); ?></div> </div> </div> <div class="meta-items d-flex flex-row"> <div class="d-flex flex-column"> <div class="meta-name"><?php echo esc_html__('Payment method:', 'datis'); ?></div> <div class="meta-value"><?php echo esc_html($payment_title); ?></div> </div> </div> </div> <div class="separator"></div> <div class="address-wrapper"> <p class="adderss-heading"><?php esc_html_e('biling address', 'datis'); ?></p> <?php if ($order->get_meta('_billing_address_index')) : ?> <p><?php echo $order->get_meta('_billing_address_index'); ?></p> <?php else : ?> <p><?php esc_html_e('No address has been set yet.', 'datis'); ?></p> <?php endif; ?> </div> <div class="address-wrapper"> <p class="adderss-heading"><?php esc_html_e('shipping address', 'datis'); ?></p> <?php if ($order->get_meta('_shipping_address_index')) : ?> <p><?php echo $order->get_meta('_shipping_address_index'); ?></p> <?php else : ?> <p><?php esc_html_e('No address has been set yet.', 'datis'); ?></p> <?php endif; ?> </div> </div> </div>
💾 保存文件
← 返回文件管理器