init
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/** @var \Esun\Reward\Block\Account\Index $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$account = $block->getAccount();
|
||||
$tier = $block->getTier();
|
||||
$transactions = $block->getTransactions();
|
||||
$balance = (int)($account['balance'] ?? 0);
|
||||
$lifetimeSpend = (float)($account['lifetime_spend_base'] ?? 0);
|
||||
?>
|
||||
<div class="esun-reward-account">
|
||||
<section class="esun-account-welcome esun-reward-hero">
|
||||
<i class="esun-account-avatar iconfont icon-jinbi2" aria-hidden="true"></i>
|
||||
<div class="esun-reward-hero__content">
|
||||
<h1><?= $escaper->escapeHtml(__('My Points')) ?></h1>
|
||||
<strong><?= $escaper->escapeHtml(__('Points: %1', $balance)) ?></strong>
|
||||
</div>
|
||||
<div class="esun-reward-tier">
|
||||
<span><?= $escaper->escapeHtml(__('VIP Tier')) ?></span>
|
||||
<strong><?= $escaper->escapeHtml($tier['label']) ?></strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="esun-account-panel esun-reward-overview">
|
||||
<header><h2><?= $escaper->escapeHtml(__('Points Overview')) ?></h2></header>
|
||||
<div class="esun-reward-account__summary">
|
||||
<article class="esun-reward-card">
|
||||
<i class="iconfont icon-jinbi2" aria-hidden="true"></i>
|
||||
<span><?= $escaper->escapeHtml(__('Available Points')) ?></span>
|
||||
<strong><?= $escaper->escapeHtml((string)$balance) ?></strong>
|
||||
</article>
|
||||
<article class="esun-reward-card">
|
||||
<i class="iconfont icon-member6" aria-hidden="true"></i>
|
||||
<span><?= $escaper->escapeHtml(__('VIP Tier')) ?></span>
|
||||
<strong><?= $escaper->escapeHtml($tier['label']) ?></strong>
|
||||
<small><?= $escaper->escapeHtml(__('%1× points', $tier['multiplier'])) ?></small>
|
||||
</article>
|
||||
<article class="esun-reward-card">
|
||||
<i class="iconfont icon-dollar1" aria-hidden="true"></i>
|
||||
<span><?= $escaper->escapeHtml(__('Lifetime Spend')) ?></span>
|
||||
<strong>$<?= $escaper->escapeHtml(number_format($lifetimeSpend, 2)) ?></strong>
|
||||
<?php if ($tier['next_threshold'] !== null): ?>
|
||||
<small>
|
||||
<?= $escaper->escapeHtml(
|
||||
__('$%1 to next tier', number_format(
|
||||
max(0, $tier['next_threshold'] - $lifetimeSpend),
|
||||
2
|
||||
))
|
||||
) ?>
|
||||
</small>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="esun-account-panel esun-reward-history-panel">
|
||||
<header><h2><?= $escaper->escapeHtml(__('Point History')) ?></h2></header>
|
||||
<?php if ($transactions): ?>
|
||||
<div class="table-wrapper">
|
||||
<table class="data table esun-reward-history">
|
||||
<thead><tr>
|
||||
<th scope="col"><?= $escaper->escapeHtml(__('Date')) ?></th>
|
||||
<th scope="col"><?= $escaper->escapeHtml(__('Activity')) ?></th>
|
||||
<th scope="col"><?= $escaper->escapeHtml(__('Change')) ?></th>
|
||||
<th scope="col"><?= $escaper->escapeHtml(__('Balance')) ?></th>
|
||||
<th scope="col"><?= $escaper->escapeHtml(__('Reason')) ?></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($transactions as $row): ?>
|
||||
<?php $delta = (int)$row['points_delta']; ?>
|
||||
<tr>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Date')) ?>">
|
||||
<?= $escaper->escapeHtml($row['created_at']) ?>
|
||||
</td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Activity')) ?>">
|
||||
<?= $escaper->escapeHtml($block->getActivityName((string)$row['type'])) ?>
|
||||
</td>
|
||||
<td class="esun-reward-history__change <?= $delta >= 0
|
||||
? 'is-positive'
|
||||
: 'is-negative' ?>" data-th="<?= $escaper->escapeHtmlAttr(__('Change')) ?>">
|
||||
<?= $escaper->escapeHtml(($delta > 0 ? '+' : '') . (string)$delta) ?>
|
||||
</td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Balance')) ?>">
|
||||
<?= $escaper->escapeHtml((string)(int)$row['balance_after']) ?>
|
||||
</td>
|
||||
<td data-th="<?= $escaper->escapeHtmlAttr(__('Reason')) ?>">
|
||||
<?= $escaper->escapeHtml((string)$row['reason']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="esun-reward-empty">
|
||||
<i class="iconfont icon-jinbi2" aria-hidden="true"></i>
|
||||
<p><?= $escaper->escapeHtml(__('You have no point activity yet.')) ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php /** @var \Esun\Reward\Block\Cart\Reward $block */ /** @var \Magento\Framework\Escaper $escaper */ ?>
|
||||
<div class="esun-coupon esun-coupon--cart esun-reward-use">
|
||||
<div class="esun-coupon__title"><?= $escaper->escapeHtml(__('Use Points')) ?></div>
|
||||
<?php if ($block->isLoggedIn()): ?>
|
||||
<p class="esun-reward-use__balance"><?= $escaper->escapeHtml(__('Available balance: %1 points', $block->getBalance())) ?></p>
|
||||
<form data-role="esun-reward-form" data-url="<?= $escaper->escapeUrl($block->getApplyUrl()) ?>">
|
||||
<?= $block->getBlockHtml('formkey') ?><div class="esun-coupon__controls"><label class="esun-coupon__label" for="esun-cart-reward-points"><?= $escaper->escapeHtml(__('Points to use')) ?></label><input id="esun-cart-reward-points" class="input-text esun-coupon__input" type="number" name="points" min="0" max="<?= $escaper->escapeHtmlAttr((string)min($block->getMaximum(), $block->getBalance())) ?>" value="<?= $escaper->escapeHtmlAttr((string)$block->getAppliedPoints()) ?>"><button class="action esun-coupon__button" type="submit"><span><?= $escaper->escapeHtml(__('Apply')) ?></span></button></div>
|
||||
<p class="note"><?= $escaper->escapeHtml(__('%1 points = $1. Maximum %2 points per order.', $block->getRate(), $block->getMaximum())) ?></p><div data-role="esun-reward-message"></div>
|
||||
</form>
|
||||
<?php else: ?><p><a href="<?= $escaper->escapeUrl($block->getUrl('customer/account/login')) ?>"><?= $escaper->escapeHtml(__('Sign in to view and use your points.')) ?></a></p><?php endif; ?>
|
||||
</div>
|
||||
<script type="text/x-magento-init">{"[data-role=esun-reward-form]":{"Esun_Reward/js/reward-form":{}}}</script>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php /** @var \Esun\Reward\Block\Product\ListProduct $block */ /** @var \Magento\Framework\Escaper $escaper */ ?>
|
||||
<div class="esun-reward-products"><p><?= $escaper->escapeHtml(__('Your points: %1', $block->getBalance())) ?></p><div class="products wrapper grid products-grid"><ol class="products list items product-items"><?php foreach($block->getProducts() as $product):?><li class="item product product-item"><div class="product-item-info"><a class="product photo product-item-photo" href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>"><img class="product-image-photo" src="<?= $escaper->escapeUrl($block->getImageUrl($product)) ?>" alt="<?= $escaper->escapeHtmlAttr($product->getName()) ?>"></a><div class="product details product-item-details"><strong class="product name product-item-name"><?= $escaper->escapeHtml($product->getName()) ?></strong><div class="price-box"><strong><?= (int)$product->getData('reward_points_cost') ?> <?= $escaper->escapeHtml(__('points')) ?></strong></div><?php if($block->isLoggedIn()&&$product->getTypeId()==='simple'):?><form method="post" action="<?= $escaper->escapeUrl($block->getRedeemUrl()) ?>"><?= $block->getBlockHtml('formkey') ?><input type="hidden" name="product_id" value="<?= (int)$product->getId() ?>"><button class="action primary" type="submit" <?= $block->getBalance()<(int)$product->getData('reward_points_cost')?'disabled':'' ?>><span><?= $escaper->escapeHtml(__('Redeem')) ?></span></button></form><?php endif;?></div></div></li><?php endforeach;?></ol></div></div>
|
||||
Reference in New Issue
Block a user