init
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body><referenceContainer name="content">
|
||||
<block class="Esun\Reward\Block\Adminhtml\Customer\Reward" name="esun.customer.reward" template="Esun_Reward::customer/reward.phtml" after="customer_form"/>
|
||||
</referenceContainer></body>
|
||||
</page>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/** @var \Esun\Reward\Block\Adminhtml\Customer\Reward $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$data = $block->getRewardData();
|
||||
if (!$data) { return; }
|
||||
?>
|
||||
<section class="admin__page-section">
|
||||
<div class="admin__page-section-title"><span class="title"><?= $escaper->escapeHtml(__('Reward Points')) ?></span></div>
|
||||
<div class="admin__page-section-content">
|
||||
<div class="admin__page-section-item"><strong><?= $escaper->escapeHtml(__('Available Balance')) ?>:</strong> <?= (int)$data['balance'] ?> <strong><?= $escaper->escapeHtml(__('VIP Tier')) ?>:</strong> <?= $escaper->escapeHtml($data['tier']['label']) ?> (<?= $escaper->escapeHtml((string)$data['tier']['multiplier']) ?>×) <strong><?= $escaper->escapeHtml(__('Lifetime Spend')) ?>:</strong> $<?= $escaper->escapeHtml(number_format((float)$data['lifetime_spend_base'], 2)) ?></div>
|
||||
<form method="post" action="<?= $escaper->escapeUrl($block->getAdjustUrl()) ?>" style="margin-top:20px">
|
||||
<?= $block->getBlockHtml('formkey') ?><input type="hidden" name="customer_id" value="<?= $escaper->escapeHtmlAttr((string)$block->getCustomerId()) ?>">
|
||||
<div class="admin__field"><label class="admin__field-label"><span><?= $escaper->escapeHtml(__('Type')) ?></span></label><div class="admin__field-control"><select class="admin__control-select" name="adjustment_type"><option value="admin_adjustment"><?= $escaper->escapeHtml(__('Manual Adjustment')) ?></option><option value="social_share"><?= $escaper->escapeHtml(__('Social Media Share (%1 points)', $block->getSocialPoints())) ?></option></select></div></div>
|
||||
<div class="admin__field"><label class="admin__field-label"><span><?= $escaper->escapeHtml(__('Operation')) ?></span></label><div class="admin__field-control"><select class="admin__control-select" name="operation"><option value="add"><?= $escaper->escapeHtml(__('Add')) ?></option><option value="subtract"><?= $escaper->escapeHtml(__('Subtract')) ?></option></select></div></div>
|
||||
<div class="admin__field required"><label class="admin__field-label"><span><?= $escaper->escapeHtml(__('Points')) ?></span></label><div class="admin__field-control"><input class="admin__control-text" type="number" min="1" name="points" required></div></div>
|
||||
<div class="admin__field required"><label class="admin__field-label"><span><?= $escaper->escapeHtml(__('Reason')) ?></span></label><div class="admin__field-control"><textarea class="admin__control-textarea" name="reason" required></textarea></div></div>
|
||||
<div class="admin__field"><label class="admin__field-label"><span><?= $escaper->escapeHtml(__('Evidence URL / Note')) ?></span></label><div class="admin__field-control"><input class="admin__control-text" name="evidence"></div></div>
|
||||
<button class="action-primary" type="submit"><span><?= $escaper->escapeHtml(__('Adjust Points')) ?></span></button>
|
||||
</form>
|
||||
<h3 style="margin-top:25px"><?= $escaper->escapeHtml(__('Recent Point Changes')) ?></h3>
|
||||
<table class="data-grid"><thead><tr><th class="data-grid-th"><?= $escaper->escapeHtml(__('Date')) ?></th><th class="data-grid-th"><?= $escaper->escapeHtml(__('Type')) ?></th><th class="data-grid-th"><?= $escaper->escapeHtml(__('Change')) ?></th><th class="data-grid-th"><?= $escaper->escapeHtml(__('Balance')) ?></th><th class="data-grid-th"><?= $escaper->escapeHtml(__('Reason')) ?></th></tr></thead><tbody>
|
||||
<?php foreach ($block->getTransactions() as $row): ?><tr><td><?= $escaper->escapeHtml($row['created_at']) ?></td><td><?= $escaper->escapeHtml($row['type']) ?></td><td><?= (int)$row['points_delta'] > 0 ? '+' : '' ?><?= (int)$row['points_delta'] ?></td><td><?= (int)$row['balance_after'] ?></td><td><?= $escaper->escapeHtml((string)$row['reason']) ?></td></tr><?php endforeach; ?>
|
||||
</tbody></table>
|
||||
</div>
|
||||
</section>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head><css src="Esun_Reward::css/reward.css"/></head><body><referenceContainer name="cart.summary">
|
||||
<block class="Esun\Reward\Block\Cart\Reward" name="esun.cart.reward" template="Esun_Reward::cart/reward.phtml" after="esun.cart.coupon" before="checkout.cart.methods.bottom"/>
|
||||
</referenceContainer></body>
|
||||
</page>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head><css src="Esun_Reward::css/reward.css"/></head>
|
||||
<body>
|
||||
<referenceBlock name="checkout.root">
|
||||
<arguments>
|
||||
<argument name="jsLayout" xsi:type="array">
|
||||
<item name="components" xsi:type="array">
|
||||
<item name="checkout" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="steps" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="billing-step" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="payment" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="afterMethods" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="esun-reward" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Esun_Reward/js/view/payment/reward</item>
|
||||
<item name="sortOrder" xsi:type="number">20</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
<item name="sidebar" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="summary" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="totals" xsi:type="array">
|
||||
<item name="children" xsi:type="array">
|
||||
<item name="reward_discount" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Esun_Reward/js/view/summary/reward-discount</item>
|
||||
<item name="sortOrder" xsi:type="number">35</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</referenceBlock>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"><body><referenceBlock name="customer_account_navigation"><block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-reward"><arguments><argument name="path" xsi:type="string">reward/account</argument><argument name="label" xsi:type="string" translate="true">My Points</argument><argument name="sortOrder" xsi:type="number">245</argument></arguments></block></referenceBlock></body></page>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<update handle="customer_account"/>
|
||||
<head>
|
||||
<css src="Esun_Customer::css/account-dashboard.css"/>
|
||||
<css src="Esun_Reward::css/reward.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceBlock name="page.main.title" remove="true"/>
|
||||
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
|
||||
<referenceBlock name="wishlist_sidebar" remove="true"/>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Reward\Block\Account\Index" name="esun.reward.account" template="Esun_Reward::account/index.phtml" cacheable="false"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"><head><css src="Esun_Reward::css/reward.css"/></head><body><referenceContainer name="content"><block class="Esun\Reward\Block\Product\ListProduct" name="esun.reward.products" template="Esun_Reward::product/list.phtml" cacheable="false"/></referenceContainer></body></page>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"><body><referenceBlock name="order_totals"><block class="Esun\Reward\Block\Order\RewardTotals" name="esun.order.reward.totals"/></referenceBlock></body></page>
|
||||
@@ -0,0 +1,9 @@
|
||||
var config = {
|
||||
config: {
|
||||
mixins: {
|
||||
'Magento_SalesRule/js/view/payment/discount': {
|
||||
'Esun_Reward/js/view/payment/discount-mixin': true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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>
|
||||
@@ -0,0 +1,379 @@
|
||||
.esun-reward-use {
|
||||
border: 1px solid #ddd;
|
||||
margin: 16px 0;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.esun-reward-use .action,
|
||||
.esun-reward-products .action.primary,
|
||||
.esun-coupon__button {
|
||||
background: #18aa59;
|
||||
background-image: none;
|
||||
border-color: #18aa59;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-reward-use .action:hover,
|
||||
.esun-reward-use .action:focus,
|
||||
.esun-reward-products .action.primary:hover,
|
||||
.esun-reward-products .action.primary:focus,
|
||||
.esun-coupon__button:hover,
|
||||
.esun-coupon__button:focus {
|
||||
background: #148f4b;
|
||||
background-image: none;
|
||||
border-color: #148f4b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-reward-use__title {
|
||||
font-weight: 700;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.esun-reward-use__controls {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.esun-reward-use__controls input {
|
||||
max-width: 180px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-checkout-summary-tool,
|
||||
.checkout-index-index .amcheckout-summary-container .esun-reward-use {
|
||||
background: #fff;
|
||||
border: 1px solid #d8dcde;
|
||||
border-radius: 14px;
|
||||
margin: 12px 0;
|
||||
padding: 18px 20px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__title {
|
||||
color: #292d30;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 11px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__label {
|
||||
clip: rect(0, 0, 0, 0);
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__controls {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__input {
|
||||
flex: 1 1 auto;
|
||||
height: 46px;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
border: 1px solid #cfd4d7;
|
||||
border-radius: 23px;
|
||||
padding: 0 18px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__button {
|
||||
background: #fff;
|
||||
border: 1px solid #18aa59;
|
||||
border-radius: 23px;
|
||||
color: #168b4b;
|
||||
flex: 0 0 auto;
|
||||
font-weight: 700;
|
||||
height: 46px;
|
||||
min-width: 96px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__button:hover,
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__button:focus {
|
||||
background: #148f4b;
|
||||
border-color: #148f4b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__picker-button {
|
||||
font-size: 14px;
|
||||
grid-column: 1 / -1;
|
||||
justify-self: end;
|
||||
min-width: 0;
|
||||
height: auto;
|
||||
margin-top: 2px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__applied {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 16px;
|
||||
min-height: 42px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.amcheckout-summary-container
|
||||
.esun-coupon__applied
|
||||
.esun-coupon__picker-button {
|
||||
grid-column: 1 / -1;
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__applied strong {
|
||||
color: #168b4b;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__applied > span {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__remove {
|
||||
background: transparent !important;
|
||||
border: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
box-shadow: none !important;
|
||||
color: #168b4b;
|
||||
height: auto !important;
|
||||
margin: 0 !important;
|
||||
min-height: 0 !important;
|
||||
min-width: 0 !important;
|
||||
padding: 0 !important;
|
||||
text-decoration: underline;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__message {
|
||||
display: none;
|
||||
font-size: 13px;
|
||||
margin-top: 9px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__message.is-error,
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__message.is-success {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__message.is-error {
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-coupon__message.is-success {
|
||||
color: #168b4b;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-reward-use__balance {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-summary-container .esun-reward-use .note {
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.esun-reward-account {
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.esun-reward-hero .esun-account-avatar {
|
||||
color: #aaa;
|
||||
font-size: 82px;
|
||||
}
|
||||
|
||||
.esun-reward-hero__content {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.esun-reward-tier {
|
||||
background: #050505;
|
||||
border-radius: 30px;
|
||||
color: #fff;
|
||||
margin-left: auto;
|
||||
min-width: 180px;
|
||||
padding: 11px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.esun-reward-tier > span {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
letter-spacing: .08em;
|
||||
line-height: 1.2;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.esun-reward-tier > strong {
|
||||
color: #fff;
|
||||
font-size: 23px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.esun-reward-overview,
|
||||
.esun-reward-history-panel {
|
||||
padding: 38px 34px;
|
||||
}
|
||||
|
||||
.esun-reward-account__summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.esun-reward-card {
|
||||
align-items: center;
|
||||
background: #fafafa;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 190px;
|
||||
padding: 27px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.esun-reward-card + .esun-reward-card {
|
||||
border-left: 1px solid #e2e2e2;
|
||||
}
|
||||
|
||||
.esun-reward-card > .iconfont {
|
||||
color: #666;
|
||||
font-size: 42px;
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.esun-reward-card > span {
|
||||
color: #777;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.esun-reward-card > strong {
|
||||
color: #222;
|
||||
display: block;
|
||||
font-size: 25px;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.esun-reward-card:first-child > strong {
|
||||
color: #f28c00;
|
||||
}
|
||||
|
||||
.esun-reward-card > small {
|
||||
color: #888;
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.esun-reward-history-panel .table-wrapper {
|
||||
margin-top: 30px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.esun-reward-history {
|
||||
border-collapse: collapse;
|
||||
margin: 0;
|
||||
min-width: 720px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.esun-reward-history thead {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.esun-reward-history th,
|
||||
.esun-reward-history td {
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
padding: 16px 18px;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.esun-reward-history th {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.esun-reward-history td {
|
||||
color: #444;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.esun-reward-history tbody tr:hover {
|
||||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
.esun-reward-history__change {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.esun-reward-history__change.is-positive {
|
||||
color: #299b59;
|
||||
}
|
||||
|
||||
.esun-reward-history__change.is-negative {
|
||||
color: #e45752;
|
||||
}
|
||||
|
||||
.esun-reward-empty {
|
||||
color: #888;
|
||||
padding: 48px 20px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.esun-reward-empty .iconfont {
|
||||
color: #aaa;
|
||||
display: block;
|
||||
font-size: 58px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.esun-reward-empty p {
|
||||
margin: 14px 0 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.esun-reward-account__summary {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.esun-reward-card {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.esun-reward-card + .esun-reward-card {
|
||||
border-left: 0;
|
||||
border-top: 1px solid #e2e2e2;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.esun-reward-tier {
|
||||
margin-left: 0;
|
||||
min-width: 0;
|
||||
padding: 9px 22px;
|
||||
}
|
||||
|
||||
.esun-reward-tier > strong {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.esun-reward-overview,
|
||||
.esun-reward-history-panel {
|
||||
padding: 24px 18px;
|
||||
}
|
||||
|
||||
.esun-reward-account__summary,
|
||||
.esun-reward-history-panel .table-wrapper {
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
define(['jquery', 'mage/url', 'mage/cookies'], function ($, urlBuilder) {
|
||||
'use strict';
|
||||
return { apply: function (points) { return $.ajax({url: urlBuilder.build('reward/cart/apply'), type: 'POST', dataType: 'json', data: {form_key: $.mage.cookies.get('form_key'), points: points}}); } };
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
define(['jquery', 'mage/translate', 'Magento_Customer/js/customer-data'], function ($, $t, customerData) {
|
||||
'use strict';
|
||||
return function (config, element) {
|
||||
$(element).on('submit', function (event) {
|
||||
event.preventDefault(); var $form = $(this), $message = $form.find('[data-role=esun-reward-message]');
|
||||
$.ajax({url: $form.data('url'), type: 'POST', dataType: 'json', data: $form.serialize(), showLoader: true})
|
||||
.done(function (response) { $message.text(response.message || ''); customerData.reload(['cart'], true).always(function () { window.location.reload(); }); })
|
||||
.fail(function (xhr) { $message.text((xhr.responseJSON && xhr.responseJSON.message) || $t('Unable to apply points.')); });
|
||||
return false;
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Checkout/js/action/get-totals',
|
||||
'Magento_Customer/js/customer-data'
|
||||
], function ($, getTotalsAction, customerData) {
|
||||
'use strict';
|
||||
|
||||
return function (Discount) {
|
||||
return Discount.extend({
|
||||
initialize: function () {
|
||||
this._super();
|
||||
$(document)
|
||||
.off('esun:customerCouponApplied.esunCheckoutDiscount')
|
||||
.on('esun:customerCouponApplied.esunCheckoutDiscount',
|
||||
this.onCustomerCouponApplied.bind(this));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
onCustomerCouponApplied: function (event, response) {
|
||||
var code = response && response.coupon_code || '';
|
||||
|
||||
this.couponCode(code);
|
||||
this.isApplied(Boolean(code));
|
||||
customerData.reload(['cart'], true);
|
||||
getTotalsAction([]);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
define([
|
||||
'uiComponent',
|
||||
'ko',
|
||||
'jquery',
|
||||
'mage/translate',
|
||||
'mage/url',
|
||||
'Magento_Customer/js/customer-data',
|
||||
'Esun_Reward/js/model/reward-service',
|
||||
'Magento_Checkout/js/action/get-totals'
|
||||
], function (Component, ko, $, $t, urlBuilder, customerData, rewardService, getTotalsAction) {
|
||||
'use strict';
|
||||
return Component.extend({
|
||||
defaults: {template: 'Esun_Reward/payment/reward'},
|
||||
initialize: function () {
|
||||
var self = this,
|
||||
checkoutReward = window.checkoutConfig.esunReward || {},
|
||||
cartReward;
|
||||
|
||||
this._super();
|
||||
this.cart = customerData.get('cart');
|
||||
this.customer = customerData.get('customer');
|
||||
cartReward = this.cart().reward || {};
|
||||
this.rewardData = ko.observable($.extend({
|
||||
logged_in: false,
|
||||
balance: 0,
|
||||
applied_points: 0,
|
||||
maximum: 1500,
|
||||
rate: 100
|
||||
}, cartReward, checkoutReward));
|
||||
this.points = ko.observable(Number(this.rewardData().applied_points || 0));
|
||||
this.message = ko.observable('');
|
||||
this.loading = ko.observable(false);
|
||||
this.ready = ko.observable(false);
|
||||
this.cart.subscribe(function (cart) {
|
||||
if (cart.reward) {
|
||||
self.rewardData(cart.reward);
|
||||
}
|
||||
});
|
||||
this.refreshRewardData();
|
||||
return this;
|
||||
},
|
||||
reward: function () { return this.rewardData(); },
|
||||
isLoggedIn: function () {
|
||||
var customer = this.customer();
|
||||
|
||||
return Boolean(this.reward().logged_in || customer.fullname || customer.firstname);
|
||||
},
|
||||
refreshRewardData: function () {
|
||||
var self = this;
|
||||
|
||||
$.ajax({
|
||||
url: urlBuilder.build('customer/section/load/'),
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
data: {
|
||||
sections: 'cart,customer',
|
||||
force_new_section_timestamp: true
|
||||
}
|
||||
}).done(function (sections) {
|
||||
if (sections.cart) {
|
||||
customerData.set('cart', sections.cart);
|
||||
if (sections.cart.reward) {
|
||||
self.rewardData(sections.cart.reward);
|
||||
}
|
||||
self.points(Number((sections.cart.reward || {}).applied_points || 0));
|
||||
}
|
||||
if (sections.customer) {
|
||||
customerData.set('customer', sections.customer);
|
||||
}
|
||||
}).always(function () {
|
||||
self.ready(true);
|
||||
});
|
||||
},
|
||||
apply: function () { var self = this; if (this.loading()) { return false; } this.loading(true); rewardService.apply(Math.max(0, parseInt(this.points(), 10) || 0)).done(function (response) { self.message(response.message || ''); customerData.reload(['cart'], true); getTotalsAction([]); }).fail(function (xhr) { self.message((xhr.responseJSON && xhr.responseJSON.message) || $t('Unable to apply points.')); }).always(function () { self.loading(false); }); return false; }
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
define(['Magento_Checkout/js/view/summary/abstract-total', 'Magento_Checkout/js/model/quote'], function (Component, quote) {
|
||||
'use strict';
|
||||
return Component.extend({
|
||||
defaults: {template: 'Esun_Reward/summary/reward-discount'},
|
||||
getSegment: function () {
|
||||
var totals = quote.getTotals()();
|
||||
return totals && totals.total_segments && totals.total_segments.filter(function (item) {
|
||||
return item.code === 'reward_discount';
|
||||
})[0];
|
||||
},
|
||||
isDisplayed: function () {
|
||||
return this.getPureValue() !== 0;
|
||||
},
|
||||
getPureValue: function () {
|
||||
var segment = this.getSegment();
|
||||
return segment ? Number(segment.value) : 0;
|
||||
},
|
||||
getTitle: function () {
|
||||
var segment = this.getSegment();
|
||||
return segment && segment.title ? segment.title : this.title;
|
||||
},
|
||||
getValue: function () {
|
||||
return this.getFormattedPrice(this.getPureValue());
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
<div class="esun-coupon esun-coupon--cart esun-reward-use">
|
||||
<div class="esun-coupon__title" data-bind="i18n: 'Use Points'"></div>
|
||||
<!-- ko if: ready -->
|
||||
<!-- ko if: isLoggedIn -->
|
||||
<p class="esun-reward-use__balance">
|
||||
<span data-bind="i18n: 'Available balance:'"></span>
|
||||
<strong data-bind="text: reward().balance"></strong>
|
||||
<span data-bind="i18n: 'points'"></span>
|
||||
</p>
|
||||
<form data-bind="submit: apply">
|
||||
<div class="esun-coupon__controls">
|
||||
<label class="esun-coupon__label" for="esun-checkout-reward-points"
|
||||
data-bind="i18n: 'Points to use'"></label>
|
||||
<input id="esun-checkout-reward-points"
|
||||
class="input-text esun-coupon__input"
|
||||
type="number"
|
||||
min="0"
|
||||
data-bind="value: points,
|
||||
attr: {max: Math.min(Number(reward().balance), Number(reward().maximum))},
|
||||
disable: loading"/>
|
||||
<button class="action esun-coupon__button" type="submit" data-bind="disable: loading">
|
||||
<span data-bind="i18n: 'Apply'"></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="note">
|
||||
<span data-bind="text: reward().rate"></span>
|
||||
<span data-bind="i18n: 'points = $1. Maximum'"></span>
|
||||
<span data-bind="text: reward().maximum"></span>
|
||||
<span data-bind="i18n: 'points per order.'"></span>
|
||||
</p>
|
||||
<div class="esun-coupon__message"
|
||||
data-bind="text: message, css: {'is-success': message()}"></div>
|
||||
</form>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: isLoggedIn -->
|
||||
<p><a data-bind="attr: {href: window.BASE_URL + 'customer/account/login/'},
|
||||
i18n: 'Sign in to view and use your points.'"></a></p>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<!-- ko if: isDisplayed() -->
|
||||
<tr class="totals reward-discount">
|
||||
<th class="mark" scope="row"><span data-bind="text: getTitle()"></span></th>
|
||||
<td class="amount"><span class="price" data-bind="text: getValue()"></span></td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
Reference in New Issue
Block a user