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,39 @@
<?php
declare(strict_types=1);
namespace Esun\Reward\Model;
use Magento\Checkout\Model\Cart as CheckoutCart;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Customer\Helper\Session\CurrentCustomer;
class CheckoutConfigProvider implements ConfigProviderInterface
{
public function __construct(
private readonly CheckoutCart $checkoutCart,
private readonly CurrentCustomer $currentCustomer,
private readonly BalanceManager $balances,
private readonly Config $config
) {}
public function getConfig(): array
{
$quote = $this->checkoutCart->getQuote();
$customerId = (int)$this->currentCustomer->getCustomerId()
?: (int)$quote->getCustomerId();
$balance = $customerId > 0
? (int)$this->balances->getAccount(
$customerId,
(int)$quote->getStore()->getWebsiteId()
)['balance']
: 0;
return ['esunReward' => [
'logged_in' => $customerId > 0,
'balance' => $balance,
'applied_points' => (int)$quote->getData('reward_points_used'),
'maximum' => $this->config->maxCheckoutPoints((int)$quote->getStoreId()),
'rate' => $this->config->redemptionRate((int)$quote->getStoreId()),
]];
}
}