View order in my account (Lẩu Nam Bộ}

Nguyen Eric
0
15/11/24
15/11/2024

Thay toàn bộ code bên dưới vào mục woocommerce/myaccount/view-order.php

<?php
/**
 * View Order
 *
 * Shows the details of a particular order on the account page.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/view-order.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://woocommerce.com/document/template-structure/
 * @package WooCommerce\Templates
 * @version 3.0.0
 */

defined( 'ABSPATH' ) || exit;

$notes = $order->get_customer_order_notes();
?>
<div class="heading-sec ord_hd">Chi tiết lịch sử đơn hàng</div>
<div class="order-info">
	<?php
	echo wp_kses_post(
		apply_filters(
			'woocommerce_order_tracking_status',
			sprintf(
				/* translators: 1: order number 2: order date 3: order status */
				__( 'Mã đơn hàng %1$s được đặt vào %2$s.', 'woocommerce' ),
				'<mark class="order-number">' . $order->get_order_number() . '</mark>',
				'<mark class="order-date">' . wc_format_datetime( $order->get_date_created() ) . '</mark>',
				'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>'
			)
		)
	);
	?>
</div>
<div class="ord_grd">
<div class="ord_dt">Trạng thái đơn</div>
<div class="ord_stt"><strong><?php echo '' .wc_get_order_status_name( $order->get_status() ). ''; ?></strong></div>
<div class="ord_dt">Giờ đặt hàng</div>
<div><?php foreach ( $notes as $note ) : ?>
					<?php echo date_i18n( esc_html__( 'H:i:s', 'woocommerce' ), strtotime( $note->comment_date ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
		<?php endforeach; ?><?php
	echo wp_kses_post(
		apply_filters(
			'woocommerce_order_tracking_status',
			sprintf(
				/* translators: 1: order number 2: order date 3: order status */
				__( '- %2$s.', 'woocommerce' ),
				'<mark class="order-number">' . $order->get_order_number() . '</mark>',
				'' . wc_format_datetime( $order->get_date_created() ) . '',
				'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>'
			)
		)
	);
	?></div>
<div>Tổng đơn</div>
<div><?php echo wp_kses_post( $order->get_formatted_order_total() ); ?></div>
	<div>Hình thức</div>
<div><?php echo esc_html( $order->get_payment_method_title() ); ?></div>
</div>
<?php do_action( 'woocommerce_view_order', $order_id ); ?>

Thêm css

.heading-sec{
    color: #222;
    font-size: 17px;
    padding: 0.5rem;
    background: rgba(8, 0, 64, 0.04);
    border-radius: 0.5rem 0.5em 0 0;
}

.order-info {
    background: #EAFAEA;
    border: 1px solid;
    color: #028a0f;
    padding: 5px 10px;
    border-radius: 4px;
}

.ord_grd {
    line-height: 1.5em;
    border-left: 5px solid;
    padding: 0 5px;
    display: grid;
    grid-gap: 3px 10px;
    grid-template-columns: auto 1fr;
    text-align: left;
    color: #222;
    margin: 0 10px 10px;
}
Bài viết này được đăng trong Worpress và được gắn thẻ , .
Tags :
Tags: ,