init
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/** @var \Esun\LegacyOrder\Block\Account\OrderView $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$order = $block->getOrder();
|
||||
$items = $block->getItems();
|
||||
$shipping = $block->decodeAddress($order['shipping_address'] ?? null);
|
||||
$billing = $block->decodeAddress($order['billing_address'] ?? null);
|
||||
$currency = (string)($order['currency'] ?? '');
|
||||
$discountAmount = abs((float)($order['discount_amount'] ?? 0));
|
||||
$couponCode = trim((string)($order['coupon'] ?? ''));
|
||||
$hasDiscount = $discountAmount > 0.0001 || $couponCode !== '';
|
||||
$formatMoney = static fn ($value): string => number_format((float)$value, 2, '.', ',');
|
||||
$formatQty = static fn ($value): string => (string)(int)round((float)$value);
|
||||
$formatAddress = static function (array $address): array {
|
||||
return array_values(array_filter([
|
||||
$address['name'] ?? '',
|
||||
trim((string)($address['street'] ?? '') . ' ' . (string)($address['unit'] ?? '')),
|
||||
trim((string)($address['city'] ?? '') . ' ' . (string)($address['region'] ?? '') . ' ' . (string)($address['postcode'] ?? '')),
|
||||
$address['country'] ?? '',
|
||||
$address['telephone'] ?? '',
|
||||
], static fn ($value): bool => trim((string)$value) !== ''));
|
||||
};
|
||||
?>
|
||||
<div class="legacy-order-view">
|
||||
<div class="legacy-order-view__notice" role="note">
|
||||
<span class="legacy-order-view__notice-icon" aria-hidden="true">i</span>
|
||||
<span><?= $escaper->escapeHtml(__('This order is from the old website and is for historical reference only.')) ?></span>
|
||||
</div>
|
||||
|
||||
<section class="legacy-order-view__hero">
|
||||
<div>
|
||||
<span class="legacy-order-view__eyebrow"><?= $escaper->escapeHtml(__('Historical record')) ?></span>
|
||||
<h1><?= $escaper->escapeHtml(__('Order #%1', $order['source_order_number'] ?? '')) ?></h1>
|
||||
<p><?= $escaper->escapeHtml(__('Placed on %1', $order['ordered_at'] ?: '-')) ?></p>
|
||||
</div>
|
||||
<div class="legacy-order-view__hero-total">
|
||||
<span><?= $escaper->escapeHtml(__('Grand Total')) ?></span>
|
||||
<strong><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($order['grand_total'] ?? 0))) ?></strong>
|
||||
<a href="<?= $escaper->escapeUrl($block->getUrl('legacy_order/account/index')) ?>">
|
||||
<span aria-hidden="true">←</span> <?= $escaper->escapeHtml(__('Back to Historical Orders')) ?>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="legacy-order-view__status-grid" aria-label="<?= $escaper->escapeHtmlAttr(__('Order status summary')) ?>">
|
||||
<?php foreach ([
|
||||
[__('Order Status'), $order['order_status'] ?? null],
|
||||
[__('Payment Status'), $order['payment_status'] ?? null],
|
||||
[__('Shipping Status'), $order['shipping_status'] ?? null],
|
||||
[__('Tracking Number'), $order['tracking_number'] ?? null],
|
||||
] as [$label, $value]): ?>
|
||||
<div class="legacy-order-view__status-card">
|
||||
<span><?= $escaper->escapeHtml($label) ?></span>
|
||||
<strong><?= $escaper->escapeHtml($value ?: '-') ?></strong>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
||||
<section class="legacy-order-view__panel legacy-order-view__items">
|
||||
<header class="legacy-order-view__section-title">
|
||||
<div><span><?= count($items) ?></span><h2><?= $escaper->escapeHtml(__('Items Ordered')) ?></h2></div>
|
||||
</header>
|
||||
<div class="table-wrapper order-items">
|
||||
<table class="data table table-order-items">
|
||||
<caption class="table-caption"><?= $escaper->escapeHtml(__('Items Ordered')) ?></caption>
|
||||
<thead><tr><th class="col name"><?= $escaper->escapeHtml(__('Product')) ?></th><th class="col sku"><?= $escaper->escapeHtml(__('SKU')) ?></th><th class="col price"><?= $escaper->escapeHtml(__('Price')) ?></th><th class="col qty"><?= $escaper->escapeHtml(__('Qty')) ?></th><th class="col subtotal"><?= $escaper->escapeHtml(__('Subtotal')) ?></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<tr>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Product')) ?>" class="col name"><strong><?= $escaper->escapeHtml($item['product_name'] ?: $item['sku']) ?></strong></td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('SKU')) ?>" class="col sku"><?= $escaper->escapeHtml($item['sku']) ?></td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Price')) ?>" class="col price"><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($item['price']))) ?></td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Qty')) ?>" class="col qty"><span><?= $escaper->escapeHtml($formatQty($item['qty'])) ?></span></td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Subtotal')) ?>" class="col subtotal"><strong><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($item['row_total']))) ?></strong></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><th colspan="4" scope="row"><?= $escaper->escapeHtml(__('Product Subtotal')) ?></th><td><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($order['product_total'] ?? 0))) ?></td></tr>
|
||||
<?php if ($hasDiscount): ?>
|
||||
<tr class="legacy-order-view__discount-row">
|
||||
<th colspan="4" scope="row">
|
||||
<?= $escaper->escapeHtml(__('Discount')) ?>
|
||||
<?php if ($couponCode !== ''): ?><small><?= $escaper->escapeHtml(__('Coupon: %1', $couponCode)) ?></small><?php endif; ?>
|
||||
</th>
|
||||
<td>-<?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($discountAmount))) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ((float)($order['shipping_amount'] ?? 0) !== 0.0): ?><tr><th colspan="4" scope="row"><?= $escaper->escapeHtml(__('Shipping')) ?></th><td><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($order['shipping_amount']))) ?></td></tr><?php endif; ?>
|
||||
<?php if ((float)($order['tax_amount'] ?? 0) !== 0.0): ?><tr><th colspan="4" scope="row"><?= $escaper->escapeHtml(__('Tax')) ?></th><td><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($order['tax_amount']))) ?></td></tr><?php endif; ?>
|
||||
<?php if ((float)($order['fee_amount'] ?? 0) !== 0.0): ?><tr><th colspan="4" scope="row"><?= $escaper->escapeHtml(__('Fee')) ?></th><td><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($order['fee_amount']))) ?></td></tr><?php endif; ?>
|
||||
<tr class="grand_total"><th colspan="4" scope="row"><?= $escaper->escapeHtml(__('Grand Total')) ?></th><td><strong><?= $escaper->escapeHtml(trim($currency . ' ' . $formatMoney($order['grand_total'] ?? 0))) ?></strong></td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="legacy-order-view__panel legacy-order-view__information">
|
||||
<header class="legacy-order-view__section-title"><h2><?= $escaper->escapeHtml(__('Order Information')) ?></h2></header>
|
||||
<div class="legacy-order-view__info-grid">
|
||||
<?php foreach ([[__('Shipping Address'), $shipping], [__('Billing Address'), $billing]] as [$label, $address]): ?>
|
||||
<article class="legacy-order-view__info-card">
|
||||
<h3><?= $escaper->escapeHtml($label) ?></h3>
|
||||
<address><?= /* @noEscape */ implode('<br>', array_map([$escaper, 'escapeHtml'], $formatAddress($address))) ?: $escaper->escapeHtml('-') ?></address>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<article class="legacy-order-view__info-card">
|
||||
<h3><?= $escaper->escapeHtml(__('Shipping Method')) ?></h3>
|
||||
<p><?= $escaper->escapeHtml($order['shipping_method'] ?: '-') ?></p>
|
||||
<?php if (!empty($order['carrier'])): ?><small><?= $escaper->escapeHtml(__('Carrier: %1', $order['carrier'])) ?></small><?php endif; ?>
|
||||
</article>
|
||||
<article class="legacy-order-view__info-card">
|
||||
<h3><?= $escaper->escapeHtml(__('Payment Method')) ?></h3>
|
||||
<p><?= $escaper->escapeHtml($order['payment_method'] ?: '-') ?></p>
|
||||
<?php if (!empty($order['payment_transaction_id'])): ?><small><?= $escaper->escapeHtml(__('Transaction: %1', $order['payment_transaction_id'])) ?></small><?php endif; ?>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
Reference in New Issue
Block a user