This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,98 @@
<?php
/** @var \Esun\Customer\Block\Order\Detail $block */
/** @var \Magento\Framework\Escaper $escaper */
$order = $block->getOrder();
$currentStep = $block->getCurrentStepIndex();
$shippingAddress = $order->getShippingAddress();
$discountAmount = (float)$order->getDiscountAmount();
$rewardDiscount = (float)$order->getData('reward_discount_amount');
?>
<div class="esun-order-detail">
<section class="esun-order-detail__panel esun-order-detail__overview">
<h1><?= $escaper->escapeHtml(__('Order Number %1', $order->getIncrementId())) ?></h1>
<div class="esun-order-progress">
<?php foreach ($block->getSteps() as $index => $step): ?>
<div class="esun-order-progress__step <?= $index <= $currentStep ? 'is-reached' : '' ?> <?= $index === $currentStep ? 'is-current' : '' ?>">
<div class="esun-order-progress__track"><i class="iconfont <?= $escaper->escapeHtmlAttr($step['icon']) ?>" aria-hidden="true"></i></div>
<strong><?= $escaper->escapeHtml($step['label']) ?></strong>
<?php if ($index === $currentStep): ?>
<time><?= $escaper->escapeHtml($block->formatDate($block->getCurrentStepDate(), \IntlDateFormatter::MEDIUM, true)) ?></time>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<div class="esun-order-detail__status-bar">
<strong><?= $escaper->escapeHtml($order->getStatusLabel()) ?></strong>
<?php if ($block->canRepay($order)): ?>
<form method="post" action="<?= $escaper->escapeUrl($block->getRepayUrl($order)) ?>">
<?= $block->getBlockHtml('formkey') ?>
<button class="action primary" type="submit"><?= $escaper->escapeHtml(__('Pay Now')) ?></button>
</form>
<?php elseif ($block->canConfirmReceipt($order)): ?>
<form method="post" action="<?= $escaper->escapeUrl($block->getReceiveUrl()) ?>">
<?= $block->getBlockHtml('formkey') ?>
<input type="hidden" name="order_id" value="<?= (int)$order->getId() ?>">
<button class="action primary" type="submit"><?= $escaper->escapeHtml(__('Confirm Receipt')) ?></button>
</form>
<?php endif; ?>
</div>
</section>
<?= /* @noEscape */ $block->getChildHtml('seventeen_track') ?>
<section class="esun-order-detail__panel esun-order-information">
<h2><?= $escaper->escapeHtml(__('Order Information')) ?></h2>
<dl>
<dt><?= $escaper->escapeHtml(__('Order Date:')) ?></dt>
<dd><?= $escaper->escapeHtml($block->formatDate($order->getCreatedAt(), \IntlDateFormatter::LONG, false)) ?></dd>
<dt><?= $escaper->escapeHtml(__('Payment Method:')) ?></dt>
<dd><?= $escaper->escapeHtml($block->getPaymentMethodTitle()) ?></dd>
<?php if ($shippingAddress): ?>
<dt><?= $escaper->escapeHtml(__('Shipped To:')) ?></dt>
<dd><address><?= /* @noEscape */ $block->getFormattedAddress($shippingAddress) ?></address></dd>
<?php endif; ?>
</dl>
</section>
<section class="esun-order-detail__panel esun-order-summary">
<h2><?= $escaper->escapeHtml(__('Order Summary')) ?></h2>
<?php if (!$order->getIsVirtual()): ?>
<div class="esun-order-summary__shipping">
<span><?= $escaper->escapeHtml(__('Shipping Method: %1', $order->getShippingDescription() ?: __('No shipping information available'))) ?></span>
<span><?= $escaper->escapeHtml(__('Shipping:')) ?> <?= /* @noEscape */ $order->formatPrice($order->getShippingAmount()) ?></span>
</div>
<?php endif; ?>
<div class="esun-order-summary__table">
<div class="esun-order-summary__head">
<span><?= $escaper->escapeHtml(__('Item')) ?></span>
<span><?= $escaper->escapeHtml(__('Price')) ?></span>
<span><?= $escaper->escapeHtml(__('Quantity')) ?></span>
<span><?= $escaper->escapeHtml(__('Subtotal')) ?></span>
</div>
<?php foreach ($order->getAllVisibleItems() as $item): ?>
<div class="esun-order-summary__item">
<div class="esun-order-summary__product">
<img src="<?= $escaper->escapeUrl($block->getItemImageUrl($item)) ?>" alt="<?= $escaper->escapeHtmlAttr($item->getName()) ?>" loading="lazy">
<div><strong><?= $escaper->escapeHtml($item->getName()) ?></strong>
<?php foreach ((array)($item->getProductOptions()['attributes_info'] ?? []) as $option): ?>
<p><?= $escaper->escapeHtml($option['label'] . ': ' . $option['value']) ?></p>
<?php endforeach; ?>
</div>
</div>
<span data-label="<?= $escaper->escapeHtmlAttr(__('Price')) ?>"><?= /* @noEscape */ $order->formatPrice($item->getPrice()) ?></span>
<span data-label="<?= $escaper->escapeHtmlAttr(__('Quantity')) ?>">x<?= $escaper->escapeHtml(rtrim(rtrim(number_format((float)$item->getQtyOrdered(), 2, '.', ''), '0'), '.')) ?></span>
<span data-label="<?= $escaper->escapeHtmlAttr(__('Subtotal')) ?>"><?= /* @noEscape */ $order->formatPrice($item->getRowTotal()) ?></span>
</div>
<?php endforeach; ?>
</div>
<div class="esun-order-summary__totals">
<div><span><?= $escaper->escapeHtml(__('Subtotal:')) ?></span><span><?= /* @noEscape */ $order->formatPrice($order->getSubtotal()) ?></span></div>
<div><span><?= $escaper->escapeHtml(__('Shipping:')) ?></span><span><?= /* @noEscape */ $order->formatPrice($order->getShippingAmount()) ?></span></div>
<?php if ($discountAmount): ?><div><span><?= $escaper->escapeHtml(__('Discount:')) ?></span><span><?= /* @noEscape */ $order->formatPrice($discountAmount) ?></span></div><?php endif; ?>
<?php if ($rewardDiscount): ?><div><span><?= $escaper->escapeHtml(__('Points Discount:')) ?></span><span><?= /* @noEscape */ $order->formatPrice(-abs($rewardDiscount)) ?></span></div><?php endif; ?>
<?php if ((float)$order->getTaxAmount()): ?><div><span><?= $escaper->escapeHtml(__('Tax:')) ?></span><span><?= /* @noEscape */ $order->formatPrice($order->getTaxAmount()) ?></span></div><?php endif; ?>
<?php if ((int)$order->getData('reward_points_earned')): ?><div><span><?= $escaper->escapeHtml(__('Points Earned:')) ?></span><span><?= (int)$order->getData('reward_points_earned') ?></span></div><?php endif; ?>
<div class="grand-total"><strong><?= $escaper->escapeHtml(__('Grand Total:')) ?></strong><strong><?= /* @noEscape */ $order->formatPrice($order->getGrandTotal()) ?></strong></div>
</div>
</section>
</div>
@@ -0,0 +1,63 @@
<?php
/** @var \Esun\Customer\Block\Order\History $block */
/** @var \Magento\Framework\Escaper $escaper */
$orders = $block->getOrders(); $counts = $block->getCounts();
/** @var \Esun\CustomerMessage\ViewModel\OrderUnread|null $messageUnread */
$messageUnread = $block->getData('message_unread_view_model');
$orderUnreadCounts = [];
if ($orders && $messageUnread) {
$orderUnreadCounts = $messageUnread->getUnreadCounts(
array_map('intval', $orders->getColumnValues('entity_id'))
);
}
?>
<div class="esun-order-history">
<h1><?= $escaper->escapeHtml(__('My Orders')) ?></h1>
<nav class="esun-order-statuses esun-order-statuses--history">
<a class="<?= $block->getCurrentStatus() === 'pending' ? 'is-active' : '' ?>" href="<?= $escaper->escapeUrl($block->getUrl('sales/order/history', ['status'=>'pending'])) ?>"><span class="esun-status-icon-wrap"><i class="esun-status-icon iconfont icon-order_payment1" aria-hidden="true"></i><?php if($counts['pending']):?><b><?= (int)$counts['pending'] ?></b><?php endif;?></span><span><?= $escaper->escapeHtml(__('Awaiting Payment')) ?></span></a>
<a class="<?= $block->getCurrentStatus() === 'processing' ? 'is-active' : '' ?>" href="<?= $escaper->escapeUrl($block->getUrl('sales/order/history', ['status'=>'processing'])) ?>"><span class="esun-status-icon-wrap"><i class="esun-status-icon iconfont icon-order_shipped1" aria-hidden="true"></i><?php if($counts['processing']):?><b><?= (int)$counts['processing'] ?></b><?php endif;?></span><span><?= $escaper->escapeHtml(__('Awaiting Shipping')) ?></span></a>
<a class="<?= $block->getCurrentStatus() === 'shipped' ? 'is-active' : '' ?>" href="<?= $escaper->escapeUrl($block->getUrl('sales/order/history', ['status'=>'shipped'])) ?>"><span class="esun-status-icon-wrap"><i class="esun-status-icon iconfont icon-order_shipped3" aria-hidden="true"></i><?php if($counts['shipped']):?><b><?= (int)$counts['shipped'] ?></b><?php endif;?></span><span><?= $escaper->escapeHtml(__('Shipped')) ?></span></a>
<a href="<?= $escaper->escapeUrl($block->getUrl('esun_review/customer/awaiting')) ?>"><span class="esun-status-icon-wrap"><i class="esun-status-icon iconfont icon-order_review1" aria-hidden="true"></i><?php if($counts['awaiting_review']):?><b><?= (int)$counts['awaiting_review'] ?></b><?php endif;?></span><span><?= $escaper->escapeHtml(__('Awaiting Review')) ?></span></a>
</nav>
<form class="esun-order-filters" method="get" action="<?= $escaper->escapeUrl($block->getUrl('sales/order/history')) ?>">
<label><span class="label"><?= $escaper->escapeHtml(__('Search orders')) ?></span><input type="search" name="q" value="<?= $escaper->escapeHtmlAttr($block->getSearchQuery()) ?>" placeholder="<?= $escaper->escapeHtmlAttr(__('Product Name/Order No.')) ?>"></label>
<label><span class="label"><?= $escaper->escapeHtml(__('Order Status')) ?></span><select name="status">
<option value=""><?= $escaper->escapeHtml(__('All Orders')) ?></option>
<?php foreach (['pending'=>__('Awaiting Payment'),'processing'=>__('Awaiting Shipping'),'shipped'=>__('Shipped'),'received'=>__('Received')] as $value=>$label): ?><option value="<?= $escaper->escapeHtmlAttr($value) ?>" <?= $block->getCurrentStatus()===$value?'selected':'' ?>><?= $escaper->escapeHtml($label) ?></option><?php endforeach; ?>
</select></label><button class="action primary" type="submit"><?= $escaper->escapeHtml(__('Search')) ?></button>
</form>
<?php if ($orders && $orders->getSize()): foreach ($orders as $order): ?>
<article class="esun-order-card"><header><span><?= $escaper->escapeHtml(__('Date: %1', $block->formatDate($order->getCreatedAt(), \IntlDateFormatter::MEDIUM, false))) ?></span><span><?= $escaper->escapeHtml(__('Order Number:')) ?> <a class="esun-order-number-link" href="<?= $escaper->escapeUrl($block->getViewUrl($order)) ?>"><?= $escaper->escapeHtml($order->getIncrementId()) ?></a></span></header>
<div class="esun-order-card__content"><div class="esun-order-card__items">
<?php foreach ($order->getAllVisibleItems() as $index=>$item): ?><div class="esun-order-item"><div class="esun-order-item__visual"><img src="<?= $escaper->escapeUrl($block->getItemImageUrl($item)) ?>" alt="<?= $escaper->escapeHtmlAttr($item->getName()) ?>"><span class="esun-item-number"><?= $index+1 ?></span></div><div><h3><?= $escaper->escapeHtml($item->getName()) ?></h3>
<?php foreach ((array)($item->getProductOptions()['attributes_info'] ?? []) as $option): ?><p><?= $escaper->escapeHtml($option['label'].': '.$option['value']) ?></p><?php endforeach; ?>
<strong><?= /* @noEscape */ $order->formatPrice($item->getPrice()) ?></strong></div></div><?php endforeach; ?>
</div><div class="esun-order-card__summary"><strong class="esun-order-card__grand-total"><?= /* @noEscape */ $order->formatPrice($order->getGrandTotal()) ?></strong><span class="esun-order-card__status"><?= $escaper->escapeHtml($order->getStatusLabel()) ?></span><div class="esun-order-card__actions">
<?php if ($block->canRepay($order)): ?><form method="post" action="<?= $escaper->escapeUrl($block->getRepayUrl($order)) ?>"><?= $block->getBlockHtml('formkey') ?><button class="action primary esun-order-pay" type="submit"><?= $escaper->escapeHtml(__('Pay Now')) ?></button></form><?php endif; ?>
<?php if ((string)$order->getStatus()==='shipped'): ?><form method="post" action="<?= $escaper->escapeUrl($block->getUrl('esun_customer/order/receive')) ?>"><?= $block->getBlockHtml('formkey') ?><input type="hidden" name="order_id" value="<?= (int)$order->getId() ?>"><button class="action primary" type="submit"><?= $escaper->escapeHtml(__('Confirm Receipt')) ?></button></form><?php endif; ?>
<?php $unreadCount = $orderUnreadCounts[(int)$order->getId()] ?? 0; ?>
<details class="esun-order-more"><summary><span><?= $escaper->escapeHtml(__('View More')) ?></span><?php if ($unreadCount): ?><b class="esun-unread-badge" aria-label="<?= $escaper->escapeHtmlAttr(__('%1 unread messages', $unreadCount)) ?>"><?= (int)$unreadCount ?></b><?php endif; ?><i aria-hidden="true"></i></summary><div class="esun-order-more__menu">
<a href="#" data-post='<?= /* @noEscape */ $block->getBuyAgainPostData($order) ?>'><?= $escaper->escapeHtml(__('Buy Again')) ?></a>
<a class="esun-order-contact-link" href="<?= $escaper->escapeUrl($block->getUrl('customer-message/order/contact', ['order_id' => (int)$order->getId()])) ?>"><span><?= $escaper->escapeHtml(__('Contact')) ?></span><?php if ($unreadCount): ?><b class="esun-unread-badge" aria-label="<?= $escaper->escapeHtmlAttr(__('%1 unread messages', $unreadCount)) ?>"><?= (int)$unreadCount ?></b><?php endif; ?></a>
<?php if ($block->canCancel($order)): ?><form method="post" action="<?= $escaper->escapeUrl($block->getCancelUrl($order)) ?>"><?= $block->getBlockHtml('formkey') ?><button type="submit"><?= $escaper->escapeHtml(__('Cancel Order')) ?></button></form><?php endif; ?>
</div></details></div></div></div>
</article>
<?php endforeach; echo $block->getPagerHtml(); else: ?><div class="message info empty"><span><?= $escaper->escapeHtml(__('No orders matched your filters.')) ?></span></div><?php endif; ?>
</div>
<script>
require(['jquery'], function ($) {
'use strict';
if (!window.matchMedia('(hover: hover) and (pointer: fine)').matches) {
return;
}
$('.esun-order-more')
.on('mouseenter', function () {
this.open = true;
})
.on('mouseleave', function () {
this.open = false;
});
});
</script>