init
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Block\Cart;
|
||||
|
||||
use Magento\Checkout\Block\Cart\AbstractCart;
|
||||
|
||||
class Coupon extends AbstractCart
|
||||
{
|
||||
public function getCouponCode(): string
|
||||
{
|
||||
return (string)$this->getQuote()->getCouponCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Block\Cart;
|
||||
|
||||
use Esun\Catalog\Block\Product\RecommendedProducts as ProductRecommendedProducts;
|
||||
use Esun\Catalog\Model\ProductRecommendation\Resolver;
|
||||
use Magento\Catalog\Block\Product\Context;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status;
|
||||
use Magento\Catalog\Model\Product\Visibility as ProductVisibility;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
|
||||
use Magento\Framework\App\ActionInterface;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\Pricing\PriceCurrencyInterface;
|
||||
use Magento\Framework\Url\Helper\Data as UrlHelper;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
/**
|
||||
* Supplies the website-scoped product list rendered below the shopping cart.
|
||||
*/
|
||||
class RecommendedProducts extends ProductRecommendedProducts
|
||||
{
|
||||
private const CONFIG_PATH = 'esun_cart/recommendations/product_skus';
|
||||
|
||||
/** @var ProductVisibility */
|
||||
private readonly ProductVisibility $cartProductVisibility;
|
||||
|
||||
/** @var CollectionFactory */
|
||||
private readonly CollectionFactory $cartProductCollectionFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param ProductVisibility $catalogProductVisibility
|
||||
* @param PriceCurrencyInterface $priceCurrency
|
||||
* @param Resolver $recommendationResolver
|
||||
* @param CollectionFactory $productCollectionFactory
|
||||
* @param ScopeConfigInterface $scopeConfig
|
||||
* @param UrlHelper $urlHelper
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ProductVisibility $catalogProductVisibility,
|
||||
PriceCurrencyInterface $priceCurrency,
|
||||
Resolver $recommendationResolver,
|
||||
CollectionFactory $productCollectionFactory,
|
||||
private readonly ScopeConfigInterface $scopeConfig,
|
||||
private readonly UrlHelper $urlHelper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->cartProductVisibility = $catalogProductVisibility;
|
||||
$this->cartProductCollectionFactory = $productCollectionFactory;
|
||||
parent::__construct(
|
||||
$context,
|
||||
$catalogProductVisibility,
|
||||
$priceCurrency,
|
||||
$recommendationResolver,
|
||||
$productCollectionFactory,
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return configured products in the same order as their SKUs.
|
||||
*
|
||||
* @return Product[]
|
||||
*/
|
||||
public function getRecommendedItems(): array
|
||||
{
|
||||
$store = $this->_storeManager->getStore();
|
||||
$value = (string)$this->scopeConfig->getValue(
|
||||
self::CONFIG_PATH,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
(int)$store->getId()
|
||||
);
|
||||
$skus = array_values(array_unique(array_filter(
|
||||
array_map('trim', preg_split('/[\r\n,]+/', $value) ?: []),
|
||||
static fn(string $sku): bool => $sku !== ''
|
||||
)));
|
||||
if ($skus === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$collection = $this->cartProductCollectionFactory->create();
|
||||
$collection->setStoreId((int)$store->getId());
|
||||
$collection->addAttributeToSelect(['name', 'small_image', 'thumbnail', 'price', 'special_price']);
|
||||
$collection->addAttributeToFilter('sku', ['in' => $skus]);
|
||||
$collection->addWebsiteFilter((int)$store->getWebsiteId());
|
||||
$collection->addAttributeToFilter('status', Status::STATUS_ENABLED);
|
||||
$collection->addAttributeToFilter(
|
||||
'visibility',
|
||||
['in' => $this->cartProductVisibility->getVisibleInCatalogIds()]
|
||||
);
|
||||
|
||||
$itemsBySku = [];
|
||||
foreach ($collection as $item) {
|
||||
$itemsBySku[(string)$item->getSku()] = $item;
|
||||
}
|
||||
|
||||
$items = [];
|
||||
foreach ($skus as $sku) {
|
||||
if (isset($itemsBySku[$sku])) {
|
||||
$items[] = $itemsBySku[$sku];
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether Magento can add the product without selecting required options.
|
||||
*
|
||||
* @param Product $product
|
||||
* @return bool
|
||||
*/
|
||||
public function canAddDirectly(Product $product): bool
|
||||
{
|
||||
return $product->isSaleable() && $product->getTypeInstance()->isPossibleBuyFromList($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the standard Magento cart POST fields.
|
||||
*
|
||||
* @param Product $product
|
||||
* @return array
|
||||
*/
|
||||
public function getAddToCartPostParams(Product $product): array
|
||||
{
|
||||
$url = $this->getAddToCartUrl($product, ['_escape' => false]);
|
||||
|
||||
return [
|
||||
'action' => $url,
|
||||
'data' => [
|
||||
'product' => (int)$product->getId(),
|
||||
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Block;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
|
||||
class TestMode extends Template
|
||||
{
|
||||
public function __construct(
|
||||
Template\Context $context,
|
||||
private readonly TestModeConfig $testModeConfig,
|
||||
private readonly Json $json,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
public function isRestricted(): bool
|
||||
{
|
||||
return $this->testModeConfig->isRestricted();
|
||||
}
|
||||
|
||||
public function getMageInitJson(): string
|
||||
{
|
||||
return $this->json->serialize([
|
||||
'Esun_Cart/js/test-mode' => [
|
||||
'title' => $this->testModeConfig->getPopupTitle(),
|
||||
'message' => $this->testModeConfig->getPopupMessage(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Controller\Coupon;
|
||||
|
||||
use Magento\Checkout\Helper\Cart as CartHelper;
|
||||
use Magento\Checkout\Model\Session as CheckoutSession;
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\Controller\Result\Json;
|
||||
use Magento\Framework\Controller\Result\JsonFactory;
|
||||
use Magento\Framework\Data\Form\FormKey\Validator as FormKeyValidator;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Quote\Api\CartRepositoryInterface;
|
||||
use Magento\SalesRule\Model\CouponFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Save extends Action implements HttpPostActionInterface
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
private readonly JsonFactory $jsonFactory,
|
||||
private readonly CheckoutSession $checkoutSession,
|
||||
private readonly CartRepositoryInterface $quoteRepository,
|
||||
private readonly CouponFactory $couponFactory,
|
||||
private readonly FormKeyValidator $formKeyValidator,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Json
|
||||
{
|
||||
$result = $this->jsonFactory->create();
|
||||
|
||||
if (!$this->formKeyValidator->validate($this->getRequest())) {
|
||||
return $result->setHttpResponseCode(400)->setData([
|
||||
'success' => false,
|
||||
'message' => (string)__('Your session has expired. Please refresh the page and try again.'),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$quote = $this->checkoutSession->getQuote();
|
||||
if (!$quote->getId() || !$quote->getItemsCount()) {
|
||||
throw new LocalizedException(__('Your shopping cart is empty.'));
|
||||
}
|
||||
|
||||
$remove = (bool)$this->getRequest()->getParam('remove', false);
|
||||
$couponCode = $remove
|
||||
? ''
|
||||
: trim((string)$this->getRequest()->getParam('coupon_code', ''));
|
||||
|
||||
if (!$remove && $couponCode === '') {
|
||||
throw new LocalizedException(__('Please enter a coupon code.'));
|
||||
}
|
||||
|
||||
if (strlen($couponCode) > CartHelper::COUPON_CODE_MAX_LENGTH) {
|
||||
throw new LocalizedException(__('The coupon code is invalid.'));
|
||||
}
|
||||
|
||||
$quote->getShippingAddress()->setCollectShippingRates(true);
|
||||
$quote->setCouponCode($couponCode)->collectTotals();
|
||||
$this->quoteRepository->save($quote);
|
||||
|
||||
$appliedCode = (string)$quote->getCouponCode();
|
||||
if (!$remove && (!$this->couponExists($couponCode) || $appliedCode !== $couponCode)) {
|
||||
throw new LocalizedException(__('The coupon code "%1" is not valid.', $couponCode));
|
||||
}
|
||||
|
||||
return $result->setData([
|
||||
'success' => true,
|
||||
'coupon_code' => $appliedCode,
|
||||
'message' => $remove
|
||||
? (string)__('The coupon code has been removed.')
|
||||
: (string)__('The coupon code was applied.'),
|
||||
]);
|
||||
} catch (LocalizedException $exception) {
|
||||
return $result->setHttpResponseCode(400)->setData([
|
||||
'success' => false,
|
||||
'message' => $exception->getMessage(),
|
||||
]);
|
||||
} catch (\Throwable $exception) {
|
||||
$this->logger->critical($exception);
|
||||
|
||||
return $result->setHttpResponseCode(500)->setData([
|
||||
'success' => false,
|
||||
'message' => (string)__('We could not update the coupon code. Please try again.'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function couponExists(string $couponCode): bool
|
||||
{
|
||||
return (bool)$this->couponFactory->create()->load($couponCode, 'code')->getId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Controller\Mix;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Checkout\Model\Cart;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\Data\Form\FormKey\Validator as FormKeyValidator;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Add extends Action implements HttpPostActionInterface
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
private readonly FormKeyValidator $formKeyValidator,
|
||||
private readonly ProductRepositoryInterface $productRepository,
|
||||
private readonly StoreManagerInterface $storeManager,
|
||||
private readonly Cart $cart,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Redirect
|
||||
{
|
||||
$redirect = $this->resultRedirectFactory->create();
|
||||
$backUrl = (string)$this->_redirect->getRefererUrl();
|
||||
|
||||
if (!$this->formKeyValidator->validate($this->getRequest())) {
|
||||
$this->messageManager->addErrorMessage(__('Your session has expired. Please try again.'));
|
||||
return $redirect->setUrl($backUrl);
|
||||
}
|
||||
|
||||
try {
|
||||
$parentProduct = $this->getParentProduct();
|
||||
$items = $this->getRequestedItems();
|
||||
$this->validateChildren($parentProduct, array_keys($items));
|
||||
$configurableAttributes = $parentProduct->getTypeInstance()
|
||||
->getConfigurableAttributes($parentProduct);
|
||||
$itemsToAdd = $items;
|
||||
$isSyncMode = (string)$this->getRequest()->getParam('mix_mode') === 'sync';
|
||||
|
||||
if ($isSyncMode) {
|
||||
$updates = [];
|
||||
foreach ($this->cart->getQuote()->getAllVisibleItems() as $quoteItem) {
|
||||
if ((int)$quoteItem->getProductId() !== (int)$parentProduct->getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$simpleProductOption = $quoteItem->getOptionByCode('simple_product');
|
||||
$childProductId = (int)($simpleProductOption?->getProduct()?->getId() ?: 0);
|
||||
if ($childProductId > 0 && isset($items[$childProductId])) {
|
||||
$updates[(int)$quoteItem->getId()] = ['qty' => $items[$childProductId]];
|
||||
unset($itemsToAdd[$childProductId]);
|
||||
} else {
|
||||
$updates[(int)$quoteItem->getId()] = ['remove' => true];
|
||||
}
|
||||
}
|
||||
if ($updates) {
|
||||
$this->cart->updateItems($updates);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($itemsToAdd as $childProductId => $quantity) {
|
||||
$childProduct = $this->productRepository->getById(
|
||||
$childProductId,
|
||||
false,
|
||||
(int)$this->storeManager->getStore()->getId()
|
||||
);
|
||||
if (!$childProduct->isSaleable()) {
|
||||
throw new LocalizedException(
|
||||
__('%1 is currently unavailable.', $childProduct->getName())
|
||||
);
|
||||
}
|
||||
|
||||
$superAttributes = [];
|
||||
foreach ($configurableAttributes as $configurableAttribute) {
|
||||
$attribute = $configurableAttribute->getProductAttribute();
|
||||
$superAttributes[(int)$attribute->getId()] = $childProduct->getData(
|
||||
$attribute->getAttributeCode()
|
||||
);
|
||||
}
|
||||
|
||||
$this->cart->addProduct(clone $parentProduct, new DataObject([
|
||||
'qty' => $quantity,
|
||||
'super_attribute' => $superAttributes,
|
||||
]));
|
||||
}
|
||||
|
||||
$this->cart->save();
|
||||
$totalQuantity = array_sum($items);
|
||||
$this->messageManager->addSuccessMessage($isSyncMode
|
||||
? __('You updated %1 variants (%2 items) in your shopping cart.', count($items), $totalQuantity)
|
||||
: __('You added %1 variants (%2 items) to your shopping cart.', count($items), $totalQuantity));
|
||||
} catch (LocalizedException $exception) {
|
||||
$this->messageManager->addErrorMessage($exception->getMessage());
|
||||
} catch (\Throwable $exception) {
|
||||
$this->logger->critical($exception);
|
||||
$this->messageManager->addErrorMessage(
|
||||
__('We can\'t add these items to your shopping cart right now.')
|
||||
);
|
||||
}
|
||||
|
||||
return $redirect->setUrl($backUrl);
|
||||
}
|
||||
|
||||
private function getParentProduct(): Product
|
||||
{
|
||||
$productId = (int)$this->getRequest()->getParam('product');
|
||||
$product = $this->productRepository->getById(
|
||||
$productId,
|
||||
false,
|
||||
(int)$this->storeManager->getStore()->getId()
|
||||
);
|
||||
if ($product->getTypeId() !== Configurable::TYPE_CODE || !$product->isSaleable()) {
|
||||
throw new LocalizedException(__('This product is not available for mix purchasing.'));
|
||||
}
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
/** @return array<int, int> */
|
||||
private function getRequestedItems(): array
|
||||
{
|
||||
$requestItems = $this->getRequest()->getParam('mix_items', []);
|
||||
$items = [];
|
||||
|
||||
if (is_array($requestItems)) {
|
||||
foreach ($requestItems as $childProductId => $quantity) {
|
||||
$childProductId = (int)$childProductId;
|
||||
$quantity = (int)$quantity;
|
||||
if ($childProductId > 0 && $quantity > 0) {
|
||||
$items[$childProductId] = $quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$items) {
|
||||
throw new LocalizedException(__('Please choose at least one variant and quantity.'));
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/** @param int[] $childProductIds */
|
||||
private function validateChildren(Product $parentProduct, array $childProductIds): void
|
||||
{
|
||||
$allowedIds = array_map(
|
||||
'intval',
|
||||
$parentProduct->getTypeInstance()->getUsedProductIds($parentProduct)
|
||||
);
|
||||
if (array_diff($childProductIds, $allowedIds)) {
|
||||
throw new LocalizedException(__('One or more selected variants do not belong to this product.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Model\Checkout;
|
||||
|
||||
use Magento\Checkout\Model\ConfigProviderInterface;
|
||||
use Magento\Cms\Block\Block as CmsBlock;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
|
||||
class ServicesConfigProvider implements ConfigProviderInterface
|
||||
{
|
||||
private const PAYMENT_BLOCK = 'esun_product_payment_security';
|
||||
private const DELIVERY_BLOCK = 'esun_product_delivery_shipping';
|
||||
|
||||
public function __construct(private readonly LayoutInterface $layout)
|
||||
{
|
||||
}
|
||||
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
'esunCartServices' => [
|
||||
'paymentSecurity' => $this->renderCmsBlock(self::PAYMENT_BLOCK),
|
||||
'deliveryShipping' => $this->renderCmsBlock(self::DELIVERY_BLOCK)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function renderCmsBlock(string $identifier): string
|
||||
{
|
||||
return $this->layout->createBlock(CmsBlock::class)
|
||||
->setBlockId($identifier)
|
||||
->toHtml();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Model\Config\Backend;
|
||||
|
||||
use Magento\Framework\App\Config\Value;
|
||||
|
||||
/**
|
||||
* Normalizes the admin SKU list while preserving its display order.
|
||||
*/
|
||||
class RecommendedProductSkus extends Value
|
||||
{
|
||||
/**
|
||||
* Normalize commas and line breaks to one unique SKU per line.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforeSave()
|
||||
{
|
||||
$skus = preg_split('/[\r\n,]+/', (string)$this->getValue()) ?: [];
|
||||
$skus = array_values(array_unique(array_filter(
|
||||
array_map('trim', $skus),
|
||||
static fn(string $sku): bool => $sku !== ''
|
||||
)));
|
||||
$this->setValue(implode("\n", $skus));
|
||||
|
||||
return parent::beforeSave();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Model;
|
||||
|
||||
use Esun\Catalog\Model\MixStepPriceProvider;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Checkout\Model\Session as CheckoutSession;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Quote\Model\Quote;
|
||||
use Magento\SalesRule\Api\Data\RuleInterface;
|
||||
use Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory;
|
||||
use Magento\Framework\Pricing\PriceCurrencyInterface;
|
||||
|
||||
class MilestoneProvider
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CollectionFactory $ruleCollectionFactory,
|
||||
private readonly CheckoutSession $checkoutSession,
|
||||
private readonly ProductRepositoryInterface $productRepository,
|
||||
private readonly MixStepPriceProvider $mixStepPriceProvider,
|
||||
private readonly PriceCurrencyInterface $priceCurrency
|
||||
) {
|
||||
}
|
||||
|
||||
public function getData(?Quote $quote = null): array
|
||||
{
|
||||
$quote ??= $this->checkoutSession->getQuote();
|
||||
$mixGroups = $this->getMixGroups($quote);
|
||||
if ($mixGroups) {
|
||||
return array_merge($mixGroups[0], ['groups' => $mixGroups]);
|
||||
}
|
||||
|
||||
$quantity = (int)ceil((float)$quote->getItemsQty());
|
||||
$milestones = $this->getMilestones($quote);
|
||||
$maximum = $milestones ? max(array_column($milestones, 'qty')) : 0;
|
||||
$active = null;
|
||||
$next = null;
|
||||
|
||||
foreach ($milestones as &$milestone) {
|
||||
$milestone['active'] = $quantity >= $milestone['qty'];
|
||||
$milestone['position'] = $maximum > 0
|
||||
? round(min(100, ($milestone['qty'] / $maximum) * 100), 2)
|
||||
: 0;
|
||||
|
||||
if ($milestone['active']) {
|
||||
$active = $milestone;
|
||||
} elseif ($next === null) {
|
||||
$next = $milestone;
|
||||
}
|
||||
}
|
||||
unset($milestone);
|
||||
|
||||
return [
|
||||
'quantity' => $quantity,
|
||||
'progress_percent' => $maximum > 0 ? round(min(100, ($quantity / $maximum) * 100), 2) : 0,
|
||||
'milestones' => $milestones,
|
||||
'message' => $this->getMessage($quantity, $active, $next),
|
||||
'groups' => [],
|
||||
];
|
||||
}
|
||||
|
||||
private function getMixGroups(Quote $quote): array
|
||||
{
|
||||
$groupedItems = [];
|
||||
foreach ($quote->getAllVisibleItems() as $item) {
|
||||
if ($item->getProductType() === Configurable::TYPE_CODE) {
|
||||
$groupedItems[(int)$item->getProductId()][] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$groups = [];
|
||||
foreach ($groupedItems as $parentProductId => $items) {
|
||||
try {
|
||||
$parentProduct = $this->productRepository->getById(
|
||||
$parentProductId,
|
||||
false,
|
||||
(int)$quote->getStoreId()
|
||||
);
|
||||
} catch (\Magento\Framework\Exception\NoSuchEntityException) {
|
||||
continue;
|
||||
}
|
||||
$rules = $this->mixStepPriceProvider->getRules(
|
||||
$parentProduct,
|
||||
(int)$quote->getCustomerGroupId()
|
||||
);
|
||||
if (!$rules) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$quantity = (int)array_sum(array_map(
|
||||
static fn ($item): float => (float)$item->getQty(),
|
||||
$items
|
||||
));
|
||||
$milestones = [];
|
||||
foreach ($rules as $rule) {
|
||||
$isFixed = ($rule['price_type'] ?? '') === 'fixed';
|
||||
$value = $isFixed
|
||||
? $this->priceCurrency->convertAndFormat(
|
||||
(float)$rule['value'],
|
||||
false,
|
||||
2,
|
||||
$quote->getStore()
|
||||
)
|
||||
: $this->formatPercent((float)$rule['value']) . '% Off';
|
||||
$milestones[] = [
|
||||
'qty' => (int)$rule['qty'],
|
||||
'type' => 'discount',
|
||||
'value' => $value,
|
||||
'label' => (string)__('%1 pcs', (int)$rule['qty']),
|
||||
];
|
||||
}
|
||||
|
||||
usort($milestones, static fn (array $left, array $right): int => $left['qty'] <=> $right['qty']);
|
||||
|
||||
$maximum = $milestones ? max(array_column($milestones, 'qty')) : 0;
|
||||
$active = null;
|
||||
$next = null;
|
||||
foreach ($milestones as &$milestone) {
|
||||
$milestone['active'] = $quantity >= $milestone['qty'];
|
||||
$milestone['position'] = $maximum > 0
|
||||
? round(min(100, ($milestone['qty'] / $maximum) * 100), 2)
|
||||
: 0;
|
||||
if ($milestone['active']) {
|
||||
$active = $milestone;
|
||||
} elseif ($next === null) {
|
||||
$next = $milestone;
|
||||
}
|
||||
}
|
||||
unset($milestone);
|
||||
|
||||
$groups[] = [
|
||||
'product_id' => $parentProductId,
|
||||
'name' => (string)$parentProduct->getName(),
|
||||
'quantity' => $quantity,
|
||||
'progress_percent' => $maximum > 0
|
||||
? round(min(100, ($quantity / $maximum) * 100), 2)
|
||||
: 0,
|
||||
'milestones' => $milestones,
|
||||
'message' => $this->getMessage($quantity, $active, $next),
|
||||
];
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
private function getMilestones(Quote $quote): array
|
||||
{
|
||||
if (!$quote->getStoreId()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$collection = $this->ruleCollectionFactory->create();
|
||||
$collection->setValidationFilter(
|
||||
(int)$quote->getStore()->getWebsiteId(),
|
||||
(int)$quote->getCustomerGroupId(),
|
||||
(string)$quote->getCouponCode(),
|
||||
null,
|
||||
$quote->getShippingAddress()
|
||||
);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $rule) {
|
||||
$quantity = $this->findQuantityThreshold($rule->getConditions());
|
||||
if ($quantity === null || $quantity < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$discountAmount = (float)$rule->getDiscountAmount();
|
||||
if ($rule->getSimpleAction() === RuleInterface::DISCOUNT_ACTION_BY_PERCENT && $discountAmount > 0) {
|
||||
$key = $quantity . ':discount';
|
||||
$items[$key] = [
|
||||
'qty' => $quantity,
|
||||
'type' => 'discount',
|
||||
'value' => $this->formatPercent($discountAmount) . '% Off',
|
||||
'label' => (string)__('%1 pcs %2% off', $quantity, $this->formatPercent($discountAmount)),
|
||||
'discount' => $discountAmount,
|
||||
];
|
||||
}
|
||||
|
||||
if ((int)$rule->getSimpleFreeShipping() > 0) {
|
||||
$items[$quantity . ':free_shipping'] = [
|
||||
'qty' => $quantity,
|
||||
'type' => 'free_shipping',
|
||||
'value' => (string)__('Free Shipping'),
|
||||
'label' => (string)__('%1 pcs', $quantity),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$milestones = array_values($items);
|
||||
usort($milestones, static function (array $left, array $right): int {
|
||||
$quantityComparison = $left['qty'] <=> $right['qty'];
|
||||
if ($quantityComparison !== 0) {
|
||||
return $quantityComparison;
|
||||
}
|
||||
|
||||
return $left['type'] === 'discount' ? -1 : 1;
|
||||
});
|
||||
|
||||
return $milestones;
|
||||
}
|
||||
|
||||
private function findQuantityThreshold(DataObject $condition): ?int
|
||||
{
|
||||
$thresholds = [];
|
||||
$this->collectQuantityThresholds($condition, $thresholds);
|
||||
|
||||
return $thresholds ? max($thresholds) : null;
|
||||
}
|
||||
|
||||
private function collectQuantityThresholds(DataObject $condition, array &$thresholds): void
|
||||
{
|
||||
if ((string)$condition->getData('attribute') === 'total_qty') {
|
||||
$value = (float)$condition->getData('value');
|
||||
$operator = (string)$condition->getData('operator');
|
||||
|
||||
if ($operator === '>=') {
|
||||
$thresholds[] = (int)ceil($value);
|
||||
} elseif ($operator === '>') {
|
||||
$thresholds[] = (int)floor($value) + 1;
|
||||
} elseif ($operator === '==') {
|
||||
$thresholds[] = (int)round($value);
|
||||
}
|
||||
}
|
||||
|
||||
$children = method_exists($condition, 'getConditions')
|
||||
? (array)$condition->getConditions()
|
||||
: (array)$condition->getData('conditions');
|
||||
|
||||
foreach ($children as $child) {
|
||||
if ($child instanceof DataObject) {
|
||||
$this->collectQuantityThresholds($child, $thresholds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getMessage(int $quantity, ?array $active, ?array $next): string
|
||||
{
|
||||
if ($next) {
|
||||
$remaining = max(0, (int)$next['qty'] - $quantity);
|
||||
$prefix = $active ? $active['value'] . ' | ' : '';
|
||||
|
||||
return $prefix . (string)__('Add %1 More For %2', $remaining, $next['value']);
|
||||
}
|
||||
|
||||
if ($active) {
|
||||
return (string)__('Unlocked: %1', $active['value']);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function formatPercent(float $value): string
|
||||
{
|
||||
return rtrim(rtrim(number_format($value, 2, '.', ''), '0'), '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Model;
|
||||
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\Pricing\PriceCurrencyInterface;
|
||||
use Magento\Quote\Model\Quote;
|
||||
use Magento\Quote\Model\Quote\Item\AbstractItem;
|
||||
use Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory as RuleCollectionFactory;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class ShippingEstimate
|
||||
{
|
||||
private const XML_PATH_FLATRATE_ACTIVE = 'carriers/flatrate/active';
|
||||
private const XML_PATH_FLATRATE_PRICE = 'carriers/flatrate/price';
|
||||
private const XML_PATH_FLATRATE_TITLE = 'carriers/flatrate/title';
|
||||
private const XML_PATH_FLATRATE_NAME = 'carriers/flatrate/name';
|
||||
|
||||
public function __construct(
|
||||
private readonly ScopeConfigInterface $scopeConfig,
|
||||
private readonly PriceCurrencyInterface $priceCurrency,
|
||||
private readonly RuleCollectionFactory $ruleCollectionFactory
|
||||
) {
|
||||
}
|
||||
|
||||
public function getData(Quote $quote): array
|
||||
{
|
||||
$storeId = (int)$quote->getStoreId();
|
||||
$available = $this->hasPhysicalItems($quote)
|
||||
&& $this->scopeConfig->isSetFlag(
|
||||
self::XML_PATH_FLATRATE_ACTIVE,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
$storeId
|
||||
);
|
||||
$freeShipping = $available && $this->isFreeShipping($quote);
|
||||
$baseAmount = $available && !$freeShipping
|
||||
? (float)$this->scopeConfig->getValue(
|
||||
self::XML_PATH_FLATRATE_PRICE,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
$storeId
|
||||
)
|
||||
: 0.0;
|
||||
$amount = $available
|
||||
? (float)$this->priceCurrency->convertAndRound($baseAmount, $quote->getStore())
|
||||
: 0.0;
|
||||
|
||||
return [
|
||||
'available' => $available,
|
||||
'free_shipping' => $freeShipping,
|
||||
'quantity' => $this->getPhysicalQuantity($quote),
|
||||
'base_amount' => $baseAmount,
|
||||
'amount' => $amount,
|
||||
'description' => $available ? $this->getDescription($storeId, $freeShipping) : '',
|
||||
];
|
||||
}
|
||||
|
||||
public function isFreeShipping(Quote $quote): bool
|
||||
{
|
||||
if (!$this->hasPhysicalItems($quote) || !$quote->getStoreId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$address = clone $quote->getShippingAddress();
|
||||
$address->setTotalQty($this->getPhysicalQuantity($quote))
|
||||
->setSubtotal((float)$quote->getSubtotal())
|
||||
->setBaseSubtotal((float)$quote->getBaseSubtotal());
|
||||
|
||||
$collection = $this->ruleCollectionFactory->create();
|
||||
$collection->setValidationFilter(
|
||||
(int)$quote->getStore()->getWebsiteId(),
|
||||
(int)$quote->getCustomerGroupId(),
|
||||
(string)$quote->getCouponCode(),
|
||||
null,
|
||||
$address
|
||||
);
|
||||
|
||||
foreach ($collection as $rule) {
|
||||
if ((int)$rule->getSimpleFreeShipping() > 0
|
||||
&& $rule->getConditions()->validate($address)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractItem[] $items
|
||||
*/
|
||||
public function isFreeShippingForItems(array $items): bool
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
$quote = $item->getQuote();
|
||||
if ($quote instanceof Quote) {
|
||||
return $this->isFreeShipping($quote);
|
||||
}
|
||||
|
||||
$addressQuote = $item->getAddress()?->getQuote();
|
||||
if ($addressQuote instanceof Quote) {
|
||||
return $this->isFreeShipping($addressQuote);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function hasPhysicalItems(Quote $quote): bool
|
||||
{
|
||||
return $this->getPhysicalQuantity($quote) > 0;
|
||||
}
|
||||
|
||||
private function getPhysicalQuantity(Quote $quote): float
|
||||
{
|
||||
$quantity = 0.0;
|
||||
foreach ($quote->getAllVisibleItems() as $item) {
|
||||
if ($item->getProduct()->isVirtual()) {
|
||||
continue;
|
||||
}
|
||||
$quantity += (float)$item->getQty();
|
||||
}
|
||||
|
||||
return $quantity;
|
||||
}
|
||||
|
||||
private function getDescription(int $storeId, bool $freeShipping): string
|
||||
{
|
||||
if ($freeShipping) {
|
||||
return (string)__('Free Shipping');
|
||||
}
|
||||
|
||||
$title = (string)$this->scopeConfig->getValue(
|
||||
self::XML_PATH_FLATRATE_TITLE,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
$storeId
|
||||
);
|
||||
$name = (string)$this->scopeConfig->getValue(
|
||||
self::XML_PATH_FLATRATE_NAME,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
$storeId
|
||||
);
|
||||
|
||||
return trim($title . ($title !== '' && $name !== '' ? ' - ' : '') . $name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Model;
|
||||
|
||||
use Magento\Customer\Model\Context as CustomerContext;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Http\Context as HttpContext;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class TestModeConfig
|
||||
{
|
||||
private const XML_PATH_ENABLED = 'esun_cart/test_mode/enabled';
|
||||
private const XML_PATH_ALLOWED_CUSTOMER_GROUPS = 'esun_cart/test_mode/allowed_customer_groups';
|
||||
private const XML_PATH_POPUP_TITLE = 'esun_cart/test_mode/popup_title';
|
||||
private const XML_PATH_POPUP_MESSAGE = 'esun_cart/test_mode/popup_message';
|
||||
private const DEFAULT_POPUP_TITLE = 'Test Mode';
|
||||
private const DEFAULT_POPUP_MESSAGE =
|
||||
'Our website is currently in beta testing. Purchases are not available at this time.';
|
||||
|
||||
public function __construct(
|
||||
private readonly ScopeConfigInterface $scopeConfig,
|
||||
private readonly HttpContext $httpContext
|
||||
) {
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE);
|
||||
}
|
||||
|
||||
/** @return int[] */
|
||||
public function getAllowedCustomerGroupIds(): array
|
||||
{
|
||||
$value = (string)$this->scopeConfig->getValue(
|
||||
self::XML_PATH_ALLOWED_CUSTOMER_GROUPS,
|
||||
ScopeInterface::SCOPE_STORE
|
||||
);
|
||||
|
||||
if ($value === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(array_unique(array_map('intval', array_filter(explode(',', $value), 'strlen'))));
|
||||
}
|
||||
|
||||
public function isCurrentCustomerAllowed(): bool
|
||||
{
|
||||
$customerGroupId = (int)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP);
|
||||
|
||||
return in_array($customerGroupId, $this->getAllowedCustomerGroupIds(), true);
|
||||
}
|
||||
|
||||
public function isRestricted(): bool
|
||||
{
|
||||
return $this->isEnabled() && !$this->isCurrentCustomerAllowed();
|
||||
}
|
||||
|
||||
public function getPopupTitle(): string
|
||||
{
|
||||
return $this->getTextValue(self::XML_PATH_POPUP_TITLE, self::DEFAULT_POPUP_TITLE);
|
||||
}
|
||||
|
||||
public function getPopupMessage(): string
|
||||
{
|
||||
return $this->getTextValue(self::XML_PATH_POPUP_MESSAGE, self::DEFAULT_POPUP_MESSAGE);
|
||||
}
|
||||
|
||||
private function getTextValue(string $path, string $default): string
|
||||
{
|
||||
$value = trim((string)$this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE));
|
||||
|
||||
return $value !== '' ? $value : $default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Observer;
|
||||
|
||||
use Esun\Catalog\Model\MixStepPriceProvider;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Quote\Model\Quote;
|
||||
use Magento\Quote\Model\Quote\Item;
|
||||
|
||||
class ApplyMixStepPrices implements ObserverInterface
|
||||
{
|
||||
private const APPLIED_FLAG = 'esun_mix_price_applied';
|
||||
|
||||
public function __construct(
|
||||
private readonly ProductRepositoryInterface $productRepository,
|
||||
private readonly MixStepPriceProvider $mixStepPriceProvider
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(Observer $observer): void
|
||||
{
|
||||
$quote = $observer->getEvent()->getQuote();
|
||||
if (!$quote instanceof Quote || !$quote->getStoreId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$groups = [];
|
||||
foreach ($quote->getAllVisibleItems() as $item) {
|
||||
if ($item->getProductType() !== Configurable::TYPE_CODE) {
|
||||
continue;
|
||||
}
|
||||
$groups[(int)$item->getProductId()][] = $item;
|
||||
}
|
||||
|
||||
foreach ($groups as $parentProductId => $items) {
|
||||
try {
|
||||
$parentProduct = $this->productRepository->getById(
|
||||
$parentProductId,
|
||||
false,
|
||||
(int)$quote->getStoreId()
|
||||
);
|
||||
} catch (NoSuchEntityException) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rules = $this->mixStepPriceProvider->getRules(
|
||||
$parentProduct,
|
||||
(int)$quote->getCustomerGroupId()
|
||||
);
|
||||
if (!$rules) {
|
||||
$this->clearPreviousMixPrices($items);
|
||||
continue;
|
||||
}
|
||||
|
||||
$combinedQuantity = array_reduce(
|
||||
$items,
|
||||
static fn (float $quantity, Item $item): float => $quantity + (float)$item->getQty(),
|
||||
0.0
|
||||
);
|
||||
$activeRule = $this->mixStepPriceProvider->getActiveRule($rules, $combinedQuantity);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$basePrice = $this->getChildBasePrice($item, $quote);
|
||||
if ($basePrice === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$unitPrice = round(
|
||||
$this->mixStepPriceProvider->calculateUnitPrice($basePrice, $activeRule),
|
||||
4
|
||||
);
|
||||
$item->setCustomPrice($unitPrice);
|
||||
$item->setOriginalCustomPrice($unitPrice);
|
||||
$item->setOriginalPrice($basePrice);
|
||||
$item->setBaseOriginalPrice($basePrice);
|
||||
$item->setData(self::APPLIED_FLAG, 1);
|
||||
$item->getProduct()->setIsSuperMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The quantity-one price includes Customer Group Price, Special Price and
|
||||
* Catalog Price Rules, while deliberately excluding child SKU quantity tiers.
|
||||
*/
|
||||
private function getChildBasePrice(Item $item, Quote $quote): ?float
|
||||
{
|
||||
$childProduct = $item->getOptionByCode('simple_product')?->getProduct();
|
||||
if (!$childProduct instanceof Product || !(int)$childProduct->getId()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$childProduct->setStoreId((int)$quote->getStoreId());
|
||||
$childProduct->setCustomerGroupId((int)$quote->getCustomerGroupId());
|
||||
|
||||
return (float)$childProduct->getPriceModel()->getFinalPrice(1, $childProduct);
|
||||
}
|
||||
|
||||
/** @param Item[] $items */
|
||||
private function clearPreviousMixPrices(array $items): void
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
if (!(bool)$item->getData(self::APPLIED_FLAG)) {
|
||||
continue;
|
||||
}
|
||||
$item->setCustomPrice(null);
|
||||
$item->setOriginalCustomPrice(null);
|
||||
$item->setData(self::APPLIED_FLAG, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Plugin\Checkout;
|
||||
|
||||
use Amasty\CheckoutCore\Block\Onepage\LayoutProcessor;
|
||||
|
||||
class SummaryLayoutProcessorPlugin
|
||||
{
|
||||
public function afterProcess(LayoutProcessor $subject, array $jsLayout): array
|
||||
{
|
||||
$sidebar = &$jsLayout['components']['checkout']['children']['sidebar']['children'];
|
||||
|
||||
if (!is_array($sidebar)) {
|
||||
return $jsLayout;
|
||||
}
|
||||
|
||||
$sidebar['esun-cart-services'] = [
|
||||
'component' => 'Esun_Cart/js/view/checkout-services',
|
||||
'sortOrder' => 90
|
||||
];
|
||||
|
||||
return $jsLayout;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Plugin\CustomerData;
|
||||
|
||||
use Esun\Cart\Model\MilestoneProvider;
|
||||
use Esun\Cart\Model\ShippingEstimate;
|
||||
use Magento\Catalog\Helper\Image as ImageHelper;
|
||||
use Magento\CatalogInventory\Api\StockRegistryInterface;
|
||||
use Magento\Checkout\CustomerData\Cart;
|
||||
use Magento\Checkout\Helper\Data as CheckoutHelper;
|
||||
use Magento\Checkout\Model\Session as CheckoutSession;
|
||||
use Magento\Quote\Api\CartRepositoryInterface;
|
||||
use Magento\Quote\Model\Quote;
|
||||
|
||||
class CartPlugin
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CheckoutSession $checkoutSession,
|
||||
private readonly CheckoutHelper $checkoutHelper,
|
||||
private readonly MilestoneProvider $milestoneProvider,
|
||||
private readonly ShippingEstimate $shippingEstimate,
|
||||
private readonly ImageHelper $imageHelper,
|
||||
private readonly StockRegistryInterface $stockRegistry,
|
||||
private readonly CartRepositoryInterface $quoteRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function afterGetSectionData(Cart $subject, array $result): array
|
||||
{
|
||||
$quote = $this->checkoutSession->getQuote();
|
||||
$removedOrphan = $this->removeOrphanedChildItems($quote);
|
||||
$quote->setTotalsCollectedFlag(false)->collectTotals();
|
||||
if ($removedOrphan) {
|
||||
$this->quoteRepository->save($quote);
|
||||
}
|
||||
|
||||
$result['items'] = $this->addItemPrices($result['items'] ?? [], $quote);
|
||||
$result['drawer_totals'] = $this->getTotalsData($quote);
|
||||
$result['purchase_progress'] = $this->milestoneProvider->getData($quote);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function removeOrphanedChildItems(Quote $quote): bool
|
||||
{
|
||||
$removed = false;
|
||||
foreach ($quote->getAllItems() as $item) {
|
||||
$parentItemId = (int)$item->getParentItemId();
|
||||
if ($parentItemId > 0 && !$quote->getItemById($parentItemId)) {
|
||||
$quote->removeItem((int)$item->getId());
|
||||
$removed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $removed;
|
||||
}
|
||||
|
||||
private function getTotalsData(Quote $quote): array
|
||||
{
|
||||
$address = $quote->getShippingAddress();
|
||||
$subtotal = (float)$quote->getSubtotal();
|
||||
$discount = (float)$address->getDiscountAmount();
|
||||
$estimate = $this->shippingEstimate->getData($quote);
|
||||
$shipping = (float)$estimate['amount'];
|
||||
$grandTotal = (float)$quote->getGrandTotal()
|
||||
- (float)$address->getShippingAmount()
|
||||
+ $shipping;
|
||||
|
||||
return [
|
||||
'subtotal' => $this->checkoutHelper->formatPrice($subtotal),
|
||||
'discount' => $this->checkoutHelper->formatPrice($discount),
|
||||
'shipping' => $this->checkoutHelper->formatPrice($shipping),
|
||||
'grand_total' => $this->checkoutHelper->formatPrice($grandTotal),
|
||||
'has_shipping_estimate' => (bool)$estimate['available'],
|
||||
'shipping_description' => (string)$estimate['description'],
|
||||
'coupon_code' => (string)$quote->getCouponCode(),
|
||||
];
|
||||
}
|
||||
|
||||
private function addItemPrices(array $items, Quote $quote): array
|
||||
{
|
||||
$quoteItems = [];
|
||||
foreach ($quote->getAllVisibleItems() as $quoteItem) {
|
||||
$quoteItems[(int)$quoteItem->getId()] = $quoteItem;
|
||||
}
|
||||
|
||||
foreach ($items as &$item) {
|
||||
$itemId = (int)($item['item_id'] ?? 0);
|
||||
if (!isset($quoteItems[$itemId])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$quoteItem = $quoteItems[$itemId];
|
||||
$simpleProductOption = $quoteItem->getOptionByCode('simple_product');
|
||||
$childProduct = $simpleProductOption?->getProduct();
|
||||
$item['parent_product_id'] = (int)$quoteItem->getProductId();
|
||||
$item['child_product_id'] = $childProduct && (int)$childProduct->getId() > 0
|
||||
? (int)$childProduct->getId()
|
||||
: (int)$quoteItem->getProductId();
|
||||
$this->replaceWithChildProductImage($item, $quoteItem);
|
||||
$item['min_sale_qty'] = $this->getMinSaleQty($quoteItem, $quote);
|
||||
$currentPrice = (float)$quoteItem->getCalculationPrice();
|
||||
$originalPrice = (float)$quoteItem->getOriginalPrice();
|
||||
$item['line_total'] = $this->checkoutHelper->formatPrice(
|
||||
$currentPrice * (float)$quoteItem->getQty()
|
||||
);
|
||||
$item['original_price'] = $originalPrice > $currentPrice + 0.0001
|
||||
? $this->checkoutHelper->formatPrice($originalPrice)
|
||||
: '';
|
||||
}
|
||||
unset($item);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getMinSaleQty(\Magento\Quote\Model\Quote\Item $quoteItem, Quote $quote): float
|
||||
{
|
||||
$productIds = [(int)$quoteItem->getProductId()];
|
||||
$simpleProductOption = $quoteItem->getOptionByCode('simple_product');
|
||||
$childProduct = $simpleProductOption?->getProduct();
|
||||
|
||||
if ($childProduct && (int)$childProduct->getId() > 0) {
|
||||
$productIds[] = (int)$childProduct->getId();
|
||||
}
|
||||
|
||||
$minimumQty = 1.0;
|
||||
foreach (array_unique(array_filter($productIds)) as $productId) {
|
||||
try {
|
||||
$stockItem = $this->stockRegistry->getStockItem(
|
||||
$productId,
|
||||
(int)$quote->getStore()->getWebsiteId()
|
||||
);
|
||||
|
||||
if (method_exists($stockItem, 'setCustomerGroupId')) {
|
||||
$stockItem->setCustomerGroupId((int)$quote->getCustomerGroupId());
|
||||
}
|
||||
|
||||
$minimumQty = max($minimumQty, (float)$stockItem->getMinSaleQty());
|
||||
} catch (\Magento\Framework\Exception\LocalizedException) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $minimumQty;
|
||||
}
|
||||
|
||||
private function replaceWithChildProductImage(array &$item, \Magento\Quote\Model\Quote\Item $quoteItem): void
|
||||
{
|
||||
$simpleProductOption = $quoteItem->getOptionByCode('simple_product');
|
||||
$childProduct = $simpleProductOption?->getProduct();
|
||||
|
||||
if (!$childProduct || !(int)$childProduct->getId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$imageFile = $this->getChildImageFile($childProduct);
|
||||
if ($imageFile === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$image = $this->imageHelper
|
||||
->init($childProduct, 'mini_cart_product_thumbnail')
|
||||
->setImageFile($imageFile);
|
||||
$item['product_image'] = [
|
||||
'src' => $image->getUrl(),
|
||||
'alt' => $image->getLabel() ?: (string)$childProduct->getName(),
|
||||
'width' => $image->getWidth(),
|
||||
'height' => $image->getHeight(),
|
||||
];
|
||||
}
|
||||
|
||||
private function getChildImageFile(\Magento\Catalog\Model\Product $childProduct): string
|
||||
{
|
||||
foreach (['thumbnail', 'small_image', 'image'] as $imageAttribute) {
|
||||
$imageFile = (string)$childProduct->getData($imageAttribute);
|
||||
if ($imageFile !== '' && $imageFile !== 'no_selection') {
|
||||
return $imageFile;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Plugin\Shipping;
|
||||
|
||||
use Esun\Cart\Model\ShippingEstimate;
|
||||
use Magento\OfflineShipping\Model\Carrier\Flatrate;
|
||||
use Magento\Quote\Model\Quote\Address\RateRequest;
|
||||
use Magento\Shipping\Model\Rate\Result;
|
||||
|
||||
class FlatratePlugin
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ShippingEstimate $shippingEstimate
|
||||
) {
|
||||
}
|
||||
|
||||
public function afterCollectRates(
|
||||
Flatrate $subject,
|
||||
Result|bool $result,
|
||||
RateRequest $request
|
||||
): Result|bool {
|
||||
if (!$result instanceof Result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$isFreeShipping = (bool)$request->getFreeShipping()
|
||||
|| $this->shippingEstimate->isFreeShippingForItems((array)$request->getAllItems());
|
||||
if (!$isFreeShipping) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($result->getAllRates() as $rate) {
|
||||
$rate->setPrice(0.0);
|
||||
$rate->setCost(0.0);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Plugin\TestMode;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Magento\Checkout\Model\Cart;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
|
||||
class RestrictAddToCartPlugin
|
||||
{
|
||||
public function __construct(private readonly TestModeConfig $testModeConfig)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $productInfo
|
||||
* @param mixed $requestInfo
|
||||
* @return array<mixed>|null
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function beforeAddProduct(Cart $subject, $productInfo, $requestInfo = null): ?array
|
||||
{
|
||||
if ($this->testModeConfig->isRestricted()) {
|
||||
throw new LocalizedException(
|
||||
__('Our website is currently in beta testing. Purchases are not available at this time.')
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Plugin\TestMode;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Magento\Checkout\Controller\Index\Index as CheckoutIndex;
|
||||
use Magento\Framework\Controller\Result\RedirectFactory;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
|
||||
class RestrictCheckoutPlugin
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TestModeConfig $testModeConfig,
|
||||
private readonly RedirectFactory $resultRedirectFactory
|
||||
) {
|
||||
}
|
||||
|
||||
public function aroundExecute(CheckoutIndex $subject, callable $proceed): ResultInterface
|
||||
{
|
||||
if (!$this->testModeConfig->isRestricted()) {
|
||||
return $proceed();
|
||||
}
|
||||
|
||||
return $this->resultRedirectFactory->create()->setPath(
|
||||
'checkout/cart',
|
||||
['_query' => ['purchase_test_mode' => 1]]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Test\Unit\Model;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Magento\Customer\Model\Context as CustomerContext;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Http\Context as HttpContext;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TestModeConfigTest extends TestCase
|
||||
{
|
||||
#[DataProvider('restrictionProvider')]
|
||||
public function testRestrictionUsesModeAndCustomerGroup(
|
||||
bool $enabled,
|
||||
?string $allowedGroups,
|
||||
int $currentGroupId,
|
||||
bool $expected
|
||||
): void {
|
||||
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
||||
$scopeConfig->method('isSetFlag')->willReturn($enabled);
|
||||
$scopeConfig->method('getValue')->willReturn($allowedGroups);
|
||||
|
||||
$httpContext = $this->createMock(HttpContext::class);
|
||||
$httpContext->method('getValue')
|
||||
->with(CustomerContext::CONTEXT_GROUP)
|
||||
->willReturn($currentGroupId);
|
||||
|
||||
self::assertSame($expected, (new TestModeConfig($scopeConfig, $httpContext))->isRestricted());
|
||||
}
|
||||
|
||||
public static function restrictionProvider(): array
|
||||
{
|
||||
return [
|
||||
'mode disabled' => [false, null, 1, false],
|
||||
'allowed group' => [true, '1,3', 3, false],
|
||||
'blocked group' => [true, '1,3', 2, true],
|
||||
'no groups configured' => [true, null, 1, true],
|
||||
];
|
||||
}
|
||||
|
||||
public function testPopupTextUsesConfiguredValues(): void
|
||||
{
|
||||
$config = $this->createConfig([
|
||||
'esun_cart/test_mode/popup_title' => 'Private Preview',
|
||||
'esun_cart/test_mode/popup_message' => 'Purchasing opens soon.',
|
||||
]);
|
||||
|
||||
self::assertSame('Private Preview', $config->getPopupTitle());
|
||||
self::assertSame('Purchasing opens soon.', $config->getPopupMessage());
|
||||
}
|
||||
|
||||
public function testPopupTextFallsBackWhenValuesAreEmpty(): void
|
||||
{
|
||||
$config = $this->createConfig([
|
||||
'esun_cart/test_mode/popup_title' => ' ',
|
||||
'esun_cart/test_mode/popup_message' => null,
|
||||
]);
|
||||
|
||||
self::assertSame('Test Mode', $config->getPopupTitle());
|
||||
self::assertSame(
|
||||
'Our website is currently in beta testing. Purchases are not available at this time.',
|
||||
$config->getPopupMessage()
|
||||
);
|
||||
}
|
||||
|
||||
/** @param array<string, string|null> $values */
|
||||
private function createConfig(array $values): TestModeConfig
|
||||
{
|
||||
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
||||
$scopeConfig->method('getValue')->willReturnCallback(
|
||||
static fn (string $path): ?string => $values[$path] ?? null
|
||||
);
|
||||
|
||||
return new TestModeConfig($scopeConfig, $this->createMock(HttpContext::class));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Test\Unit\Plugin\TestMode;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Esun\Cart\Plugin\TestMode\RestrictAddToCartPlugin;
|
||||
use Magento\Checkout\Model\Cart;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RestrictAddToCartPluginTest extends TestCase
|
||||
{
|
||||
public function testAllowsAddToCartWhenCustomerIsNotRestricted(): void
|
||||
{
|
||||
$config = $this->createMock(TestModeConfig::class);
|
||||
$config->method('isRestricted')->willReturn(false);
|
||||
|
||||
$plugin = new RestrictAddToCartPlugin($config);
|
||||
|
||||
self::assertNull($plugin->beforeAddProduct($this->createMock(Cart::class), 10));
|
||||
}
|
||||
|
||||
public function testRejectsAddToCartWhenCustomerIsRestricted(): void
|
||||
{
|
||||
$config = $this->createMock(TestModeConfig::class);
|
||||
$config->method('isRestricted')->willReturn(true);
|
||||
|
||||
$plugin = new RestrictAddToCartPlugin($config);
|
||||
|
||||
$this->expectException(LocalizedException::class);
|
||||
$this->expectExceptionMessage('Our website is currently in beta testing.');
|
||||
$plugin->beforeAddProduct($this->createMock(Cart::class), 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Test\Unit\Plugin\TestMode;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Esun\Cart\Plugin\TestMode\RestrictCheckoutPlugin;
|
||||
use Magento\Checkout\Controller\Index\Index as CheckoutIndex;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
use Magento\Framework\Controller\Result\RedirectFactory;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RestrictCheckoutPluginTest extends TestCase
|
||||
{
|
||||
public function testContinuesToCheckoutWhenCustomerIsNotRestricted(): void
|
||||
{
|
||||
$config = $this->createMock(TestModeConfig::class);
|
||||
$config->method('isRestricted')->willReturn(false);
|
||||
$redirectFactory = $this->createMock(RedirectFactory::class);
|
||||
$expectedResult = $this->createMock(ResultInterface::class);
|
||||
$plugin = new RestrictCheckoutPlugin($config, $redirectFactory);
|
||||
|
||||
$result = $plugin->aroundExecute(
|
||||
$this->createMock(CheckoutIndex::class),
|
||||
static fn (): ResultInterface => $expectedResult
|
||||
);
|
||||
|
||||
self::assertSame($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testRedirectsRestrictedCustomerToCart(): void
|
||||
{
|
||||
$config = $this->createMock(TestModeConfig::class);
|
||||
$config->method('isRestricted')->willReturn(true);
|
||||
$redirect = $this->createMock(Redirect::class);
|
||||
$redirect->expects(self::once())
|
||||
->method('setPath')
|
||||
->with('checkout/cart', ['_query' => ['purchase_test_mode' => 1]])
|
||||
->willReturnSelf();
|
||||
$redirectFactory = $this->createMock(RedirectFactory::class);
|
||||
$redirectFactory->expects(self::once())->method('create')->willReturn($redirect);
|
||||
$plugin = new RestrictCheckoutPlugin($config, $redirectFactory);
|
||||
|
||||
$result = $plugin->aroundExecute(
|
||||
$this->createMock(CheckoutIndex::class),
|
||||
static fn (): ResultInterface => throw new \LogicException('Checkout must not continue.')
|
||||
);
|
||||
|
||||
self::assertSame($redirect, $result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework/Acl/etc/acl.xsd">
|
||||
<acl>
|
||||
<resources>
|
||||
<resource id="Magento_Backend::admin">
|
||||
<resource id="Magento_Backend::stores">
|
||||
<resource id="Magento_Backend::stores_settings">
|
||||
<resource id="Magento_Config::config">
|
||||
<resource id="Esun_Cart::config"
|
||||
title="Esun Cart Configuration"
|
||||
sortOrder="93"/>
|
||||
</resource>
|
||||
</resource>
|
||||
</resource>
|
||||
</resource>
|
||||
</resources>
|
||||
</acl>
|
||||
</config>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
|
||||
<system>
|
||||
<tab id="esun" translate="label" sortOrder="300">
|
||||
<label>Esun</label>
|
||||
</tab>
|
||||
<section id="esun_cart" translate="label" type="text" sortOrder="930"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Cart</label>
|
||||
<tab>esun</tab>
|
||||
<resource>Esun_Cart::config</resource>
|
||||
<group id="test_mode" translate="label" type="text" sortOrder="10"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Purchase Test Mode</label>
|
||||
<field id="enabled" translate="label comment" type="select" sortOrder="10"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Enable Test Mode</label>
|
||||
<comment>When enabled, only the selected customer groups can add products to the cart.</comment>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
</field>
|
||||
<field id="allowed_customer_groups" translate="label comment" type="multiselect" sortOrder="20"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Allowed Customer Groups</label>
|
||||
<comment>Customers in these groups can use the complete purchase test flow. Leave empty to block all customers.</comment>
|
||||
<source_model>Magento\Customer\Model\Config\Source\Group\Multiselect</source_model>
|
||||
<depends>
|
||||
<field id="enabled">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
<field id="popup_title" translate="label comment" type="text" sortOrder="30"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Popup Title</label>
|
||||
<comment>Leave empty to use: Test Mode</comment>
|
||||
<depends>
|
||||
<field id="enabled">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
<field id="popup_message" translate="label comment" type="textarea" sortOrder="40"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Popup Message</label>
|
||||
<comment>Leave empty to use the default beta testing notice.</comment>
|
||||
<depends>
|
||||
<field id="enabled">1</field>
|
||||
</depends>
|
||||
</field>
|
||||
</group>
|
||||
<group id="recommendations" translate="label" type="text" sortOrder="20"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Cart Recommendations</label>
|
||||
<field id="product_skus" translate="label comment" type="textarea" sortOrder="10"
|
||||
showInDefault="1" showInWebsite="1" showInStore="0">
|
||||
<label>Recommended Product SKUs</label>
|
||||
<backend_model>Esun\Cart\Model\Config\Backend\RecommendedProductSkus</backend_model>
|
||||
<comment>Enter one SKU per line. The order is the display order. Website scope inherits the default list unless Use Default is disabled.</comment>
|
||||
</field>
|
||||
</group>
|
||||
</section>
|
||||
</system>
|
||||
</config>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
|
||||
<default>
|
||||
<esun_cart>
|
||||
<recommendations>
|
||||
<product_skus></product_skus>
|
||||
</recommendations>
|
||||
<test_mode>
|
||||
<enabled>0</enabled>
|
||||
<allowed_customer_groups></allowed_customer_groups>
|
||||
<popup_title>Test Mode</popup_title>
|
||||
<popup_message>Our website is currently in beta testing. Purchases are not available at this time.</popup_message>
|
||||
</test_mode>
|
||||
</esun_cart>
|
||||
<checkout>
|
||||
<cart>
|
||||
<configurable_product_image>itself</configurable_product_image>
|
||||
</cart>
|
||||
</checkout>
|
||||
</default>
|
||||
</config>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
|
||||
<table name="quote_item" resource="checkout" engine="innodb" comment="Sales Flat Quote Item">
|
||||
<column xsi:type="smallint"
|
||||
name="esun_mix_price_applied"
|
||||
unsigned="true"
|
||||
nullable="false"
|
||||
default="0"
|
||||
comment="eSUN Mix Step Price Applied"/>
|
||||
</table>
|
||||
</schema>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<type name="Magento\OfflineShipping\Model\Carrier\Flatrate">
|
||||
<plugin name="esun_cart_quantity_free_shipping"
|
||||
type="Esun\Cart\Plugin\Shipping\FlatratePlugin"/>
|
||||
</type>
|
||||
</config>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
|
||||
<event name="sales_quote_collect_totals_before">
|
||||
<observer name="esun_apply_parent_mix_step_prices"
|
||||
instance="Esun\Cart\Observer\ApplyMixStepPrices"/>
|
||||
</event>
|
||||
</config>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<type name="Magento\Checkout\Model\Cart">
|
||||
<plugin name="esun_cart_test_mode_restriction"
|
||||
type="Esun\Cart\Plugin\TestMode\RestrictAddToCartPlugin"
|
||||
sortOrder="10"/>
|
||||
</type>
|
||||
<type name="Magento\Checkout\Controller\Index\Index">
|
||||
<plugin name="esun_cart_test_mode_checkout_restriction"
|
||||
type="Esun\Cart\Plugin\TestMode\RestrictCheckoutPlugin"
|
||||
sortOrder="10"/>
|
||||
</type>
|
||||
<type name="Magento\Checkout\CustomerData\Cart">
|
||||
<plugin name="esun_cart_drawer_customer_data"
|
||||
type="Esun\Cart\Plugin\CustomerData\CartPlugin"/>
|
||||
</type>
|
||||
<type name="Magento\Checkout\Model\CompositeConfigProvider">
|
||||
<arguments>
|
||||
<argument name="configProviders" xsi:type="array">
|
||||
<item name="esun_cart_checkout_services" xsi:type="object">Esun\Cart\Model\Checkout\ServicesConfigProvider</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<type name="Amasty\CheckoutCore\Block\Onepage\LayoutProcessor">
|
||||
<plugin name="esun_cart_checkout_services_layout"
|
||||
type="Esun\Cart\Plugin\Checkout\SummaryLayoutProcessorPlugin"
|
||||
sortOrder="210"/>
|
||||
</type>
|
||||
<type name="Magento\Framework\View\Element\Message\MessageConfigurationsPool">
|
||||
<arguments>
|
||||
<argument name="configurationsMap" xsi:type="array">
|
||||
<item name="addCartSuccessMessage" xsi:type="array">
|
||||
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
|
||||
<item name="data" xsi:type="array">
|
||||
<item name="template" xsi:type="string">Esun_Cart::messages/addCartSuccessMessage.phtml</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
</config>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
|
||||
<router id="standard">
|
||||
<route id="esun_cart" frontName="esun_cart">
|
||||
<module name="Esun_Cart"/>
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
|
||||
<action name="esun_cart/mix/add">
|
||||
<section name="cart"/>
|
||||
<section name="messages"/>
|
||||
</action>
|
||||
<action name="esun_cart/coupon/save">
|
||||
<section name="cart"/>
|
||||
</action>
|
||||
</config>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Esun_Cart">
|
||||
<sequence>
|
||||
<module name="Magento_Checkout"/>
|
||||
<module name="Magento_ConfigurableProduct"/>
|
||||
<module name="Magento_Cms"/>
|
||||
<module name="Magento_Customer"/>
|
||||
<module name="Magento_OfflineShipping"/>
|
||||
<module name="Magento_SalesRule"/>
|
||||
<module name="Amasty_CheckoutCore"/>
|
||||
<module name="Esun_Catalog"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
"Cart","购物车"
|
||||
"Purchase Test Mode","购买测试模式"
|
||||
"Enable Test Mode","开启测试模式"
|
||||
"When enabled, only the selected customer groups can add products to the cart.","开启后,仅选中的客户组可以将商品加入购物车。"
|
||||
"Allowed Customer Groups","允许购买的客户组"
|
||||
"Customers in these groups can use the complete purchase test flow. Leave empty to block all customers.","这些客户组可以进入完整的购买测试流程。留空将限制所有客户。"
|
||||
"Popup Title","弹窗标题"
|
||||
"Leave empty to use: Test Mode","留空将使用:测试模式"
|
||||
"Popup Message","弹窗提示内容"
|
||||
"Leave empty to use the default beta testing notice.","留空将使用默认的网站内测提示。"
|
||||
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Esun_Cart',
|
||||
__DIR__
|
||||
);
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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_Cart::css/cart-page.css"/>
|
||||
<css src="Esun_Cart::css/cart-recommendations.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceBlock name="page.main.title" remove="true"/>
|
||||
<referenceBlock name="checkout.cart" template="Esun_Cart::cart/page.phtml">
|
||||
<block class="Esun\Cart\Block\Cart\RecommendedProducts"
|
||||
name="esun.cart.recommended.products"
|
||||
as="recommended_products"
|
||||
template="Esun_Cart::cart/recommended-products.phtml">
|
||||
<arguments>
|
||||
<argument name="cardViewModel" xsi:type="object">Esun\Catalog\ViewModel\Category\ProductCard</argument>
|
||||
<argument name="viewModel" xsi:type="object">Magento\Catalog\ViewModel\Product\OptionsData</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceBlock>
|
||||
<referenceBlock name="checkout.cart.summary.title" remove="true"/>
|
||||
<referenceBlock name="checkout.cart.shipping" template="Esun_Cart::cart/checkout-config.phtml"/>
|
||||
<referenceBlock name="checkout.cart.coupon" remove="true"/>
|
||||
<referenceBlock name="checkout.cart.crosssell" remove="true"/>
|
||||
<referenceBlock name="checkout.cart.totals" template="Esun_Cart::cart/totals.phtml"/>
|
||||
|
||||
<referenceBlock name="checkout.cart.item.renderers.default" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
<referenceBlock name="checkout.cart.item.renderers.simple" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
<referenceBlock name="checkout.cart.item.renderers.virtual" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
<referenceBlock name="checkout.cart.item.renderers.configurable" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
<referenceBlock name="checkout.cart.item.renderers.bundle" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
<referenceBlock name="checkout.cart.item.renderers.downloadable" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
<referenceBlock name="checkout.cart.item.renderers.grouped" template="Esun_Cart::cart/item/default.phtml"/>
|
||||
|
||||
<referenceContainer name="cart.summary">
|
||||
<block class="Esun\Cart\Block\Cart\Coupon"
|
||||
name="esun.cart.coupon"
|
||||
template="Esun_Cart::cart/coupon.phtml"
|
||||
before="checkout.cart.methods.bottom"/>
|
||||
<block class="Magento\Framework\View\Element\Template"
|
||||
name="esun.cart.page.services"
|
||||
template="Esun_Cart::cart/page-services.phtml"
|
||||
after="checkout.cart.methods.bottom">
|
||||
<block class="Magento\Cms\Block\Block" name="esun.cart.page.payment.security" as="payment_security">
|
||||
<arguments>
|
||||
<argument name="block_id" xsi:type="string">esun_product_payment_security</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
<block class="Magento\Cms\Block\Block" name="esun.cart.page.delivery.shipping" as="delivery_shipping">
|
||||
<arguments>
|
||||
<argument name="block_id" xsi:type="string">esun_product_delivery_shipping</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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_Cart::css/checkout-services.css"/>
|
||||
</head>
|
||||
</page>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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_Cart::css/cart-drawer.css"/>
|
||||
<css src="Esun_Cart::css/test-mode.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceContainer name="before.body.end">
|
||||
<block class="Esun\Cart\Block\TestMode"
|
||||
name="esun.cart.test.mode"
|
||||
template="Esun_Cart::test-mode.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Checkout\Block\Cart\Shipping $block */
|
||||
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
|
||||
|
||||
$script = sprintf(
|
||||
'window.checkoutConfig = %s; window.customerData = window.checkoutConfig.customerData; window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;',
|
||||
$block->getSerializedCheckoutConfig()
|
||||
);
|
||||
?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $script, false) ?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Coupon form displayed immediately above the cart checkout button.
|
||||
*
|
||||
* @var \Esun\Cart\Block\Cart\Coupon $block
|
||||
* @var \Magento\Framework\Escaper $escaper
|
||||
*/
|
||||
$couponCode = (string)$block->getCouponCode();
|
||||
$hasCouponCode = $couponCode !== '';
|
||||
?>
|
||||
<div class="esun-coupon esun-coupon--cart">
|
||||
<div class="esun-coupon__title"><?= $escaper->escapeHtml(__('Discount Code')) ?></div>
|
||||
<form class="esun-coupon__form"
|
||||
data-role="esun-coupon-form"
|
||||
data-save-url="<?= $escaper->escapeUrl($block->getUrl('esun_cart/coupon/save')) ?>">
|
||||
<?= /* @noEscape */ $block->getBlockHtml('formkey') ?>
|
||||
<?php if (!$hasCouponCode): ?>
|
||||
<label class="esun-coupon__label" for="esun-cart-coupon-code">
|
||||
<span><?= $escaper->escapeHtml(__('Enter discount code')) ?></span>
|
||||
</label>
|
||||
<div class="esun-coupon__controls">
|
||||
<input class="input-text esun-coupon__input"
|
||||
id="esun-cart-coupon-code"
|
||||
name="coupon_code"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
maxlength="255"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Enter discount code')) ?>"/>
|
||||
<button class="action esun-coupon__button" type="submit">
|
||||
<span><?= $escaper->escapeHtml(__('Apply')) ?></span>
|
||||
</button>
|
||||
<button class="action esun-coupon__picker-button"
|
||||
type="button"
|
||||
aria-haspopup="dialog"
|
||||
data-role="open-coupon-picker">
|
||||
<span><?= $escaper->escapeHtml(__('My Coupons')) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="esun-coupon__applied">
|
||||
<span>
|
||||
<?= $escaper->escapeHtml(__('Applied:')) ?>
|
||||
<strong><?= $escaper->escapeHtml($couponCode) ?></strong>
|
||||
</span>
|
||||
<button class="action esun-coupon__remove"
|
||||
type="submit"
|
||||
name="remove"
|
||||
value="1">
|
||||
<span><?= $escaper->escapeHtml(__('Cancel')) ?></span>
|
||||
</button>
|
||||
<button class="action esun-coupon__picker-button"
|
||||
type="button"
|
||||
aria-haspopup="dialog"
|
||||
data-role="open-coupon-picker">
|
||||
<span><?= $escaper->escapeHtml(__('My Coupons')) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="esun-coupon__message" data-role="esun-coupon-message" aria-live="polite"></div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Checkout\Block\Cart\Item\Renderer $block */
|
||||
$_item = $block->getItem();
|
||||
$product = $_item->getProduct();
|
||||
/** @var \Magento\Msrp\Helper\Data $msrpHelper */
|
||||
$msrpHelper = $this->helper(\Magento\Msrp\Helper\Data::class);
|
||||
$canApplyMsrp = $msrpHelper->isShowBeforeOrderConfirm($product)
|
||||
&& $msrpHelper->isMinimalPriceLessMsrp($product);
|
||||
$isFreeGift = (bool)$_item->getData('is_esun_free_gift');
|
||||
?>
|
||||
<tbody class="cart item esun-cart-page-item<?= $isFreeGift ? ' esun-cart-page-item--free-gift' : '' ?>">
|
||||
<tr class="item-info">
|
||||
<td colspan="4" class="esun-cart-page-item__cell">
|
||||
<article class="esun-cart-page-item__card">
|
||||
<?php if ($block->hasProductUrl() && !$isFreeGift): ?>
|
||||
<a href="<?= $block->escapeUrl($block->getProductUrl()) ?>"
|
||||
title="<?= $block->escapeHtmlAttr($block->getProductName()) ?>"
|
||||
class="esun-cart-page-item__photo">
|
||||
<?php else: ?>
|
||||
<span class="esun-cart-page-item__photo">
|
||||
<?php endif; ?>
|
||||
<?= $block->getImage($block->getProductForThumbnail(), 'cart_page_product_thumbnail')->toHtml() ?>
|
||||
<?php if ($block->hasProductUrl() && !$isFreeGift): ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="esun-cart-page-item__details">
|
||||
<strong class="esun-cart-page-item__name">
|
||||
<?php if ($block->hasProductUrl() && !$isFreeGift): ?>
|
||||
<a href="<?= $block->escapeUrl($block->getProductUrl()) ?>">
|
||||
<?= $block->escapeHtml($block->getProductName()) ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?= $block->escapeHtml($block->getProductName()) ?>
|
||||
<?php endif; ?>
|
||||
</strong>
|
||||
|
||||
<?php if ($isFreeGift): ?>
|
||||
<span class="esun-free-gift-label"><?= $block->escapeHtml(__('Free Gift')) ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($_options = $block->getOptionList()): ?>
|
||||
<dl class="esun-cart-page-item__options">
|
||||
<?php foreach ($_options as $_option): ?>
|
||||
<?php $_formattedOptionValue = $block->getFormatedOptionValue($_option); ?>
|
||||
<div class="esun-cart-page-item__option">
|
||||
<dt><?= $block->escapeHtml($_option['label']) ?>:</dt>
|
||||
<dd>
|
||||
<?php if (isset($_formattedOptionValue['full_view'])): ?>
|
||||
<?= $block->escapeHtml($_formattedOptionValue['full_view'], ['span', 'a']) ?>
|
||||
<?php else: ?>
|
||||
<?= $block->escapeHtml($_formattedOptionValue['value'], ['span', 'a']) ?>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($messages = $block->getMessages()): ?>
|
||||
<?php foreach ($messages as $message): ?>
|
||||
<div class="message <?= $block->escapeHtmlAttr($message['type']) ?>">
|
||||
<div><?= $block->escapeHtml($message['text']) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($isFreeGift): ?>
|
||||
<div class="esun-cart-page-item__qty esun-cart-page-item__qty--locked">
|
||||
<span><?= $block->escapeHtml(__('Qty')) ?>:</span>
|
||||
<strong><?= $block->escapeHtml($block->getQty()) ?></strong>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="esun-cart-page-item__qty" data-role="qty-box">
|
||||
<button type="button"
|
||||
class="esun-cart-page-item__qty-button"
|
||||
data-esun-qty-change="-1"
|
||||
aria-label="<?= $block->escapeHtmlAttr(__('Decrease quantity')) ?>">−</button>
|
||||
<input id="cart-<?= $block->escapeHtmlAttr($_item->getId()) ?>-qty"
|
||||
name="cart[<?= $block->escapeHtmlAttr($_item->getId()) ?>][qty]"
|
||||
data-cart-item-id="<?= $block->escapeHtmlAttr($_item->getSku()) ?>"
|
||||
value="<?= $block->escapeHtmlAttr($block->getQty()) ?>"
|
||||
type="number"
|
||||
min="1"
|
||||
step="any"
|
||||
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
|
||||
class="input-text qty"
|
||||
data-validate="{required:true,'validate-greater-than-zero':true}"
|
||||
data-item-qty="<?= $block->escapeHtmlAttr($block->getQty()) ?>"
|
||||
data-role="cart-item-qty"/>
|
||||
<button type="button"
|
||||
class="esun-cart-page-item__qty-button"
|
||||
data-esun-qty-change="1"
|
||||
aria-label="<?= $block->escapeHtmlAttr(__('Increase quantity')) ?>">+</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="esun-cart-page-item__actions">
|
||||
<?php if (!$isFreeGift): ?>
|
||||
<?= /* @noEscape */ $block->getActions($_item) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="esun-cart-page-item__price">
|
||||
<?php if ($isFreeGift): ?>
|
||||
<strong><?= $block->escapeHtml(__('Free')) ?></strong>
|
||||
<?php elseif ($canApplyMsrp): ?>
|
||||
<span><?= $block->escapeHtml(__('See price before order confirmation.')) ?></span>
|
||||
<?php else: ?>
|
||||
<?= /* @noEscape */ $block->getRowTotalHtml($_item) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Checkout\Block\Cart\Sidebar $block */
|
||||
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
|
||||
?>
|
||||
<div data-block="minicart" class="minicart-wrapper esun-cart-wrapper">
|
||||
<button type="button"
|
||||
class="action showcart"
|
||||
data-bind="scope: 'minicart_content'"
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded="false"
|
||||
aria-label="<?= $block->escapeHtmlAttr(__('Open shopping cart')) ?>">
|
||||
<span class="text"><?= $block->escapeHtml(__('My Cart')) ?></span>
|
||||
<span class="counter qty empty"
|
||||
data-bind="css: { empty: !getCartParam('summary_count') && !isLoading() }, blockLoader: isLoading">
|
||||
<span class="counter-number">
|
||||
<!-- ko if: getCartParam('summary_count') -->
|
||||
<!-- ko text: getCartParam('summary_count').toLocaleString(window.LOCALE) --><!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</span>
|
||||
<span class="counter-label">
|
||||
<!-- ko i18n: 'items' --><!-- /ko -->
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<?php if ($block->getIsNeedToDisplaySideBar()): ?>
|
||||
<button type="button"
|
||||
class="esun-cart-backdrop"
|
||||
data-role="esun-cart-backdrop"
|
||||
aria-label="<?= $block->escapeHtmlAttr(__('Close shopping cart')) ?>"></button>
|
||||
<div class="block block-minicart esun-cart-drawer"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="esun-cart-title"
|
||||
data-role="dropdownDialog"
|
||||
data-mage-init='{"dropdownDialog":{"appendTo":"[data-block=minicart]","triggerTarget":".showcart","timeout":"2000","closeOnMouseLeave":false,"closeOnEscape":true,"triggerClass":"active","parentClass":"active","buttons":[]}}'>
|
||||
<div id="minicart-content-wrapper" data-bind="scope: 'minicart_content'">
|
||||
<!-- ko template: getTemplate() --><!-- /ko -->
|
||||
<?= $block->getChildHtml('minicart.addons') ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
$scriptString = <<<script
|
||||
require(['jquery'], function ($) {
|
||||
$('a.action.showcart').on('click', function () {
|
||||
$(document.body).trigger('processStart');
|
||||
});
|
||||
});
|
||||
script;
|
||||
?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag(
|
||||
'script',
|
||||
[],
|
||||
'window.checkout = ' . $block->getSerializedConfig(),
|
||||
false
|
||||
) ?>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"[data-block='minicart']": {
|
||||
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
|
||||
},
|
||||
"*": {
|
||||
"Magento_Ui/js/block-loader": "<?= $block->escapeJs(
|
||||
$block->escapeUrl($block->getViewFileUrl('images/loader-1.gif'))
|
||||
) ?>"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
?>
|
||||
<div class="esun-cart-page-services">
|
||||
<section class="esun-cart-page-service esun-cart-page-service--payment">
|
||||
<h2><?= $block->escapeHtml(__('Payment & Security')) ?></h2>
|
||||
<?= /* @noEscape */ $block->getChildHtml('payment_security') ?>
|
||||
</section>
|
||||
<div class="esun-cart-page-service--delivery esun-product-accordion">
|
||||
<details class="esun-product-accordion__item" open>
|
||||
<summary class="esun-product-accordion__summary">
|
||||
<span><?= $block->escapeHtml(__('Delivery and Shipping')) ?></span>
|
||||
</summary>
|
||||
<div class="esun-product-accordion__content">
|
||||
<?= /* @noEscape */ $block->getChildHtml('delivery_shipping') ?>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Checkout\Block\Cart $block */
|
||||
$itemsSummaryQty = (float)$block->getItemsSummaryQty();
|
||||
$displayQty = fmod($itemsSummaryQty, 1.0) === 0.0
|
||||
? (string)(int)$itemsSummaryQty
|
||||
: (string)$itemsSummaryQty;
|
||||
?>
|
||||
<div class="esun-cart-page">
|
||||
<header class="esun-cart-page__header">
|
||||
<h1><?= $block->escapeHtml(__('My Shopping Cart')) ?> <span>(<?= $block->escapeHtml($displayQty) ?>)</span></h1>
|
||||
<a class="esun-cart-page__continue"
|
||||
href="<?= $block->escapeUrl($block->getContinueShoppingUrl()) ?>">
|
||||
<?= $block->escapeHtml(__('Continue Shopping')) ?>
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<?= /* @noEscape */ $block->getChildHtml('vat_prompt') ?>
|
||||
|
||||
<?php if ($block->getItemsCount()): ?>
|
||||
<?= /* @noEscape */ $block->getChildHtml('with-items') ?>
|
||||
<?php else: ?>
|
||||
<?= /* @noEscape */ $block->getChildHtml('no-items') ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= /* @noEscape */ $block->getChildHtml('recommended_products') ?>
|
||||
</div>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
".esun-cart-page": {
|
||||
"Esun_Cart/js/cart-page": {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/** @var \Esun\Cart\Block\Cart\RecommendedProducts $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
|
||||
use Magento\Framework\App\ActionInterface;
|
||||
|
||||
$items = $block->getRecommendedItems();
|
||||
$urlEncodedParamName = ActionInterface::PARAM_NAME_URL_ENCODED;
|
||||
/** @var \Esun\Catalog\ViewModel\Category\ProductCard|null $cardViewModel */
|
||||
$cardViewModel = $block->getData('cardViewModel');
|
||||
/** @var \Magento\Catalog\ViewModel\Product\OptionsData|null $optionsViewModel */
|
||||
$optionsViewModel = $block->getData('viewModel');
|
||||
?>
|
||||
<?php if ($items): ?>
|
||||
<section class="esun-cart-recommended esun-recommended-products"
|
||||
aria-labelledby="cart-recommendations-title"
|
||||
data-mage-init='{"Esun_Cart/js/recommendations-carousel":{},"esunCategoryCard":{}}'>
|
||||
<div class="esun-recommended-products__heading">
|
||||
<h2 id="cart-recommendations-title"><?= $escaper->escapeHtml(__('You may also like')) ?></h2>
|
||||
<div class="esun-recommended-products__navigation"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Recommendation navigation')) ?>">
|
||||
<button class="esun-recommended-products__previous" type="button"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Previous products')) ?>">‹</button>
|
||||
<button class="esun-recommended-products__next" type="button"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Next products')) ?>">›</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="esun-recommended-products__slider" tabindex="0">
|
||||
<div class="esun-recommended-products__wrapper">
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php
|
||||
$productUrl = $block->getProductUrl($item);
|
||||
$discountPercent = $block->getDiscountPercent($item);
|
||||
$colorSwatches = $cardViewModel ? $cardViewModel->getColorSwatches($item) : [];
|
||||
$visibleSwatches = array_slice($colorSwatches, 0, 11);
|
||||
$remainingSwatches = max(0, count($colorSwatches) - count($visibleSwatches));
|
||||
$categoryLabels = $cardViewModel
|
||||
? array_slice($cardViewModel->getCategoryLabels($item), 0, 2)
|
||||
: [];
|
||||
?>
|
||||
<article class="product-item-info esun-category-card esun-recommended-products__item">
|
||||
<a class="product photo product-item-photo esun-category-card__image
|
||||
esun-recommended-products__image"
|
||||
href="<?= $escaper->escapeUrl($productUrl) ?>"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr($item->getName()) ?>">
|
||||
<?php if ($discountPercent !== null): ?>
|
||||
<span class="esun-category-card__badge">
|
||||
<?= (int)$discountPercent ?>% <?= $escaper->escapeHtml(__('OFF')) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?= /* @noEscape */ $block->getImage($item, 'category_page_grid')->toHtml() ?>
|
||||
</a>
|
||||
<div class="product details product-item-details esun-category-card__details
|
||||
esun-recommended-products__body">
|
||||
<h3 class="product name product-item-name esun-category-card__name
|
||||
esun-recommended-products__name">
|
||||
<a class="product-item-link" href="<?= $escaper->escapeUrl($productUrl) ?>">
|
||||
<?= $escaper->escapeHtml($item->getName()) ?>
|
||||
</a>
|
||||
</h3>
|
||||
<?php if ($categoryLabels): ?>
|
||||
<div class="esun-category-card__tags">
|
||||
<?php foreach ($categoryLabels as $categoryLabel): ?>
|
||||
<span><?= $escaper->escapeHtml($categoryLabel) ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($colorSwatches): ?>
|
||||
<div class="esun-category-card__swatches"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Available Colors')) ?>">
|
||||
<?php foreach ($visibleSwatches as $swatch): ?>
|
||||
<?php
|
||||
$swatchLabel = $swatch['label'];
|
||||
$swatchImage = $swatch['image'];
|
||||
$swatchValue = $swatch['value'];
|
||||
$swatchProductImage = $swatch['product_image'];
|
||||
?>
|
||||
<button class="esun-category-card__swatch"
|
||||
type="button"
|
||||
title="<?= $escaper->escapeHtmlAttr($swatchLabel) ?>"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr($swatchLabel) ?>"
|
||||
data-product-image="<?= $escaper->escapeUrl($swatchProductImage) ?>">
|
||||
<?php if ($swatchImage): ?>
|
||||
<img src="<?= $escaper->escapeUrl($swatchImage) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($swatchLabel) ?>">
|
||||
<?php elseif ($swatchValue): ?>
|
||||
<span style="background-color:
|
||||
<?= $escaper->escapeHtmlAttr($swatchValue) ?>"></span>
|
||||
<?php else: ?>
|
||||
<span></span>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($remainingSwatches > 0): ?>
|
||||
<span class="esun-category-card__swatch-more">
|
||||
+<?= (int)$remainingSwatches ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="product-item-inner esun-category-card__inner">
|
||||
<div class="esun-category-card__footer">
|
||||
<div class="esun-category-card__price">
|
||||
<span class="esun-category-card__final-price">
|
||||
<?= $escaper->escapeHtml($block->getFormattedFinalPrice($item)) ?>
|
||||
</span>
|
||||
<?php if ($block->hasOldPrice($item)): ?>
|
||||
<span class="esun-category-card__regular-price">
|
||||
<?= $escaper->escapeHtml($block->getFormattedRegularPrice($item)) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="product actions product-item-actions
|
||||
esun-recommended-products__actions">
|
||||
<?php if ($block->canAddDirectly($item)): ?>
|
||||
<?php
|
||||
$postParams = $block->getAddToCartPostParams($item);
|
||||
$urlEncodedValue = $postParams['data'][$urlEncodedParamName];
|
||||
$options = $optionsViewModel
|
||||
? $optionsViewModel->getOptionsData($item)
|
||||
: [];
|
||||
?>
|
||||
<form data-role="tocart-form"
|
||||
data-product-sku="<?= $escaper->escapeHtmlAttr($item->getSku()) ?>"
|
||||
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
|
||||
method="post">
|
||||
<?php foreach ($options as $option): ?>
|
||||
<input type="hidden"
|
||||
name="<?= $escaper->escapeHtmlAttr($option['name']) ?>"
|
||||
value="<?= $escaper->escapeHtmlAttr($option['value']) ?>">
|
||||
<?php endforeach; ?>
|
||||
<input type="hidden" name="product"
|
||||
value="<?= (int)$postParams['data']['product'] ?>">
|
||||
<input type="hidden"
|
||||
name="<?= /* @noEscape */ $urlEncodedParamName ?>"
|
||||
value="<?= $escaper->escapeHtmlAttr($urlEncodedValue) ?>">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<button class="action tocart primary esun-category-card__cart"
|
||||
type="submit"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7
|
||||
a2 2 0 0 0 2-1.6L20 8H7"/>
|
||||
<circle cx="9" cy="20" r="1"/>
|
||||
<circle cx="17" cy="20" r="1"/>
|
||||
</svg>
|
||||
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<a class="action tocart primary esun-category-card__cart"
|
||||
href="<?= $escaper->escapeUrl($productUrl) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Select Options')) ?>">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7
|
||||
a2 2 0 0 0 2-1.6L20 8H7"/>
|
||||
<circle cx="9" cy="20" r="1"/>
|
||||
<circle cx="17" cy="20" r="1"/>
|
||||
</svg>
|
||||
<span><?= $escaper->escapeHtml(__('Select Options')) ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
?>
|
||||
<div class="esun-cart-services" data-bind="visible: getCartParam('summary_count')">
|
||||
<section class="esun-cart-service esun-cart-service--payment">
|
||||
<h3><?= $block->escapeHtml(__('Payment & Security')) ?></h3>
|
||||
<?= /* @noEscape */ $block->getChildHtml('payment_security') ?>
|
||||
</section>
|
||||
<section class="esun-cart-service esun-cart-service--delivery">
|
||||
<h3><?= $block->escapeHtml(__('Delivery and Shipping')) ?></h3>
|
||||
<?= /* @noEscape */ $block->getChildHtml('delivery_shipping') ?>
|
||||
</section>
|
||||
</div>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Checkout\Block\Cart\Totals $block */
|
||||
$totals = $block->getTotals();
|
||||
$getTotalValue = static function (string $code) use ($totals): float {
|
||||
return isset($totals[$code]) ? (float)$totals[$code]->getValue() : 0.0;
|
||||
};
|
||||
$formatPrice = static function (float $amount) use ($block): string {
|
||||
return $block->getQuote()->getStore()->getCurrentCurrency()->format($amount, [], false);
|
||||
};
|
||||
$rewardPointsUsed = (int)$block->getQuote()->getData('reward_points_used');
|
||||
?>
|
||||
<div id="cart-totals" class="cart-totals esun-cart-page-totals">
|
||||
<div class="esun-cart-page-total-row">
|
||||
<span><?= $block->escapeHtml(__('Subtotal')) ?></span>
|
||||
<strong><?= $block->escapeHtml($formatPrice($getTotalValue('subtotal'))) ?></strong>
|
||||
</div>
|
||||
<div class="esun-cart-page-total-row">
|
||||
<span><?= $block->escapeHtml(__('Discount')) ?></span>
|
||||
<strong><?= $block->escapeHtml($formatPrice($getTotalValue('discount'))) ?></strong>
|
||||
</div>
|
||||
<?php if ($getTotalValue('reward_discount') != 0.0): ?>
|
||||
<div class="esun-cart-page-total-row">
|
||||
<span><?= $block->escapeHtml(__('Points Discount (%1 points)', $rewardPointsUsed)) ?></span>
|
||||
<strong><?= $block->escapeHtml($formatPrice($getTotalValue('reward_discount'))) ?></strong>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="esun-cart-page-total-row">
|
||||
<span><?= $block->escapeHtml(__('Estimated Shipping')) ?></span>
|
||||
<strong><?= $block->escapeHtml($formatPrice($getTotalValue('shipping'))) ?></strong>
|
||||
</div>
|
||||
<div class="esun-cart-page-total-row esun-cart-page-total-row--grand">
|
||||
<span><?= $block->escapeHtml(__('Total')) ?></span>
|
||||
<strong><?= $block->escapeHtml($formatPrice($getTotalValue('grand_total'))) ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
?>
|
||||
<?= $block->escapeHtml(__(
|
||||
'You added %1 to your shopping cart.',
|
||||
$block->getData('product_name')
|
||||
)) ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/** @var \Esun\Cart\Block\TestMode $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
?>
|
||||
<?php if ($block->isRestricted()): ?>
|
||||
<div data-mage-init='<?= $escaper->escapeHtmlAttr($block->getMageInitJson()) ?>'></div>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,987 @@
|
||||
body.esun-cart-is-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart .esun-cart-wrapper {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart .esun-cart-wrapper > .action.showcart,
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
> .action.showcart:hover,
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
> .action.showcart:focus,
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
> .action.showcart:active {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
color: inherit;
|
||||
outline: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart .esun-cart-wrapper .esun-cart-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 10000;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: rgba(0, 0, 0, 0.35);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition:
|
||||
opacity 0.25s ease,
|
||||
visibility 0.25s ease;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper.active
|
||||
.esun-cart-backdrop {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.block-minicart.esun-cart-drawer {
|
||||
position: fixed !important;
|
||||
top: 0 !important;
|
||||
right: 0 !important;
|
||||
bottom: 0 !important;
|
||||
left: auto !important;
|
||||
z-index: 10001 !important;
|
||||
display: none;
|
||||
width: 620px !important;
|
||||
min-width: 0 !important;
|
||||
max-width: calc(100vw - 48px) !important;
|
||||
height: 100vh;
|
||||
height: 100dvh;
|
||||
max-height: none !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
border: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
background: #fff;
|
||||
box-shadow: -10px 0 34px rgba(0, 0, 0, 0.18) !important;
|
||||
transform: translateX(100%);
|
||||
transition: transform 0.3s ease;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
scrollbar-color: #18aa59 #e1e1e1;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper.active
|
||||
.block-minicart.esun-cart-drawer {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart .esun-cart-drawer::before,
|
||||
.header-top-link-item.header-minicart .esun-cart-drawer::after {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer #minicart-content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
min-height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.block-minicart.esun-cart-drawer::-webkit-scrollbar {
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.block-minicart.esun-cart-drawer::-webkit-scrollbar-thumb {
|
||||
border-radius: 7px;
|
||||
background: #18aa59;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.block-minicart.esun-cart-drawer::-webkit-scrollbar-track {
|
||||
background: #e1e1e1;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__contents {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__header {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 72px;
|
||||
padding: 14px 28px;
|
||||
border-bottom: 1px solid #e7e7e7;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__title-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__icon {
|
||||
display: inline-block;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
margin-right: 14px;
|
||||
border-radius: 50%;
|
||||
background-color: #18aa59;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1'/%3E%3Ccircle cx='18' cy='20' r='1'/%3E%3Cpath d='M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.9a2 2 0 0 0 2-1.6L20.5 8H6'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 21px 21px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__title,
|
||||
.esun-cart-drawer__count {
|
||||
color: #222;
|
||||
font-size: 20px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__count {
|
||||
margin-left: 7px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .action.close {
|
||||
position: static !important;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #7c8189;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .action.close::before {
|
||||
content: "\00d7";
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: 300;
|
||||
line-height: 38px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .action.close span {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.esun-cart-progress {
|
||||
flex: 0 0 auto;
|
||||
min-height: 132px;
|
||||
padding: 22px 38px 16px;
|
||||
}
|
||||
.esun-cart-progress + .esun-cart-progress {
|
||||
margin-top: 14px;
|
||||
}
|
||||
.esun-cart-progress__name {
|
||||
color: #202427;
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.esun-cart-progress__message {
|
||||
min-height: 21px;
|
||||
margin-bottom: 26px;
|
||||
color: #179f54;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.esun-cart-progress__rail {
|
||||
position: relative;
|
||||
height: 8px;
|
||||
margin: 0 8px 52px;
|
||||
border-radius: 8px;
|
||||
background: #d9dcde;
|
||||
}
|
||||
|
||||
.esun-cart-progress__fill {
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
max-width: 100%;
|
||||
border-radius: inherit;
|
||||
background: #19aa59;
|
||||
transition: width 0.25s ease;
|
||||
}
|
||||
|
||||
.esun-cart-progress__step {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 104px;
|
||||
color: #42464a;
|
||||
text-align: center;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.esun-cart-progress__step:first-of-type {
|
||||
transform: translate(0, -50%);
|
||||
}
|
||||
|
||||
.esun-cart-progress__step:last-of-type {
|
||||
transform: translate(-100%, -50%);
|
||||
}
|
||||
|
||||
.esun-cart-progress__marker {
|
||||
display: block;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin: 0 auto;
|
||||
border: 3px solid #b8cfdd;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.esun-cart-progress__step.is-active .esun-cart-progress__marker {
|
||||
border-color: #19aa59;
|
||||
background: #19aa59;
|
||||
box-shadow: inset 0 0 0 4px #fff;
|
||||
}
|
||||
|
||||
.esun-cart-progress__step.is-free-shipping .esun-cart-progress__marker {
|
||||
border-color: #ff8a00;
|
||||
}
|
||||
|
||||
.esun-cart-progress__value,
|
||||
.esun-cart-progress__label {
|
||||
position: absolute;
|
||||
top: 22px;
|
||||
left: 50%;
|
||||
display: block;
|
||||
width: 116px;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.esun-cart-progress__value {
|
||||
padding: 3px 7px;
|
||||
border-radius: 12px;
|
||||
background: #e9f7ef;
|
||||
color: #333;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.esun-cart-progress__step.is-free-shipping .esun-cart-progress__value {
|
||||
background: #fff4e4;
|
||||
color: #f27d00;
|
||||
}
|
||||
|
||||
.esun-cart-progress__label {
|
||||
top: 50px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.esun-cart-items-panel {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
height: auto !important;
|
||||
max-height: none !important;
|
||||
min-height: 0;
|
||||
margin: 0 28px;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .minicart-items {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto !important;
|
||||
max-height: none !important;
|
||||
margin-top: 20px;
|
||||
padding: 0 4px 0 0;
|
||||
list-style: none;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .minicart-items-wrapper,
|
||||
.esun-cart-drawer [data-action="scroll"] {
|
||||
height: auto !important;
|
||||
max-height: none !important;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .minicart-items .product-item {
|
||||
position: relative;
|
||||
margin: 0 0 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid #d8dcde;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .minicart-items .product-item:first-child {
|
||||
border-color: #87dbaa;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item .product {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-image-container {
|
||||
flex: 0 0 104px;
|
||||
width: 104px !important;
|
||||
height: 104px;
|
||||
margin-right: 18px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-image-wrapper {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-image-photo {
|
||||
position: static;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 8px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item-details {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-cart-item__heading {
|
||||
align-items: flex-start;
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
justify-content: space-between;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item-name {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
margin-bottom: 6px;
|
||||
overflow: hidden;
|
||||
color: #343434;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product.options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
color: #686d72;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-cart-item__option {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product.options .label {
|
||||
flex: 0 0 auto;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product.options .values {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.esun-cart-item__bottom {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
margin-top: auto;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.esun-cart-item__qty {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 34px;
|
||||
border: 1px solid #d7dbde;
|
||||
border-radius: 17px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.esun-cart-item__qty-button,
|
||||
.esun-cart-item__qty .item-qty {
|
||||
width: 34px;
|
||||
height: 32px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: #fff;
|
||||
color: #353535;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-cart-item__qty-button:hover,
|
||||
.esun-cart-drawer .esun-cart-item__qty-button:focus,
|
||||
.esun-cart-drawer .esun-cart-item__qty-button:active {
|
||||
border: 0 !important;
|
||||
background: #f1f6f3;
|
||||
outline: 0;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.minicart-items .esun-cart-item__qty .item-qty {
|
||||
width: 42px;
|
||||
border-right: 1px solid #e2e4e5;
|
||||
border-left: 1px solid #e2e4e5;
|
||||
appearance: textfield;
|
||||
}
|
||||
|
||||
.esun-cart-item__qty .item-qty::-webkit-inner-spin-button,
|
||||
.esun-cart-item__qty .item-qty::-webkit-outer-spin-button {
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.esun-cart-item__qty .update-cart-item {
|
||||
position: absolute !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
padding: 0 !important;
|
||||
overflow: hidden !important;
|
||||
clip: rect(0, 0, 0, 0) !important;
|
||||
}
|
||||
|
||||
.esun-cart-item__price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-cart-item__price strong,
|
||||
.esun-cart-item__price .price {
|
||||
color: #252525;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.esun-cart-item__price .old-price,
|
||||
.esun-cart-item__price .old-price .price {
|
||||
color: #8a8d90;
|
||||
font-size: 11px;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item .action {
|
||||
flex: 0 0 auto;
|
||||
position: static;
|
||||
color: #555;
|
||||
font-size: 13px;
|
||||
text-decoration: underline;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item .action.delete::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item .esun-cart-item__remove > span {
|
||||
position: static;
|
||||
width: auto;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
clip: auto;
|
||||
clip-path: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-cart-totals {
|
||||
display: block;
|
||||
flex: 0 0 auto;
|
||||
margin: 18px 28px 0;
|
||||
padding: 16px 0 18px;
|
||||
border-top: 1px solid #d9dcde;
|
||||
border-bottom: 1px solid #d9dcde;
|
||||
}
|
||||
|
||||
.esun-cart-total-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 29px;
|
||||
color: #555b60;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.esun-cart-total-row .price {
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.esun-cart-total-row__pending {
|
||||
color: #81868a;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.esun-cart-total-row--grand {
|
||||
min-height: 42px;
|
||||
margin-top: 7px;
|
||||
padding-top: 9px;
|
||||
border-top: 1px solid #eceeef;
|
||||
color: #222;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-totals
|
||||
.action.primary.checkout {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
margin-top: 12px;
|
||||
border-radius: 22px;
|
||||
background: #18aa59;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon--mini {
|
||||
margin-top: 14px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #eceeef;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__title {
|
||||
margin-bottom: 9px;
|
||||
color: #292d30;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__label {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__controls {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__input {
|
||||
min-width: 0;
|
||||
height: 40px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid #cfd4d7;
|
||||
border-radius: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__button {
|
||||
flex: 0 0 auto;
|
||||
min-width: 82px;
|
||||
height: 40px;
|
||||
padding: 0 17px;
|
||||
border: 1px solid #18aa59 !important;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
color: #168b4b;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.esun-cart-drawer .esun-coupon__button:hover {
|
||||
background: #18aa59;
|
||||
}
|
||||
.esun-cart-drawer .esun-coupon__applied {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
min-height: 38px;
|
||||
color: #4e5357;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__applied > span {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__applied strong {
|
||||
color: #168b4b;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__remove {
|
||||
display: inline !important;
|
||||
flex: 0 0 auto;
|
||||
width: auto !important;
|
||||
min-width: 0 !important;
|
||||
max-width: none !important;
|
||||
height: auto !important;
|
||||
min-height: 0 !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
border: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
color: #168b4b;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4 !important;
|
||||
text-decoration: underline;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__remove:hover,
|
||||
.esun-cart-drawer .esun-coupon__remove:focus,
|
||||
.esun-cart-drawer .esun-coupon__remove:active {
|
||||
border: 0 !important;
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
color: #116d3c;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__message {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__message.is-error {
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .esun-coupon__message.is-success {
|
||||
color: #168b4b;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-totals
|
||||
.action.esun-cart-viewcart {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
margin-top: 10px;
|
||||
border: 1px solid #18aa59;
|
||||
border-radius: 22px;
|
||||
background: #fff;
|
||||
color: #18aa59;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-totals
|
||||
.action.esun-cart-viewcart:hover,
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-totals
|
||||
.action.esun-cart-viewcart:focus {
|
||||
background: #f1f8f4;
|
||||
color: #138849;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.esun-cart-services {
|
||||
flex: 0 0 auto;
|
||||
margin: 0 28px;
|
||||
padding: 14px 0 22px;
|
||||
}
|
||||
|
||||
.esun-cart-service {
|
||||
padding: 12px 16px;
|
||||
background: #f5f6f6;
|
||||
color: #444;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.esun-cart-service + .esun-cart-service {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.esun-cart-service h3 {
|
||||
margin: 0 0 8px;
|
||||
color: #333;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.esun-cart-service p,
|
||||
.esun-cart-service ul {
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
|
||||
.esun-cart-service ul {
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
.esun-cart-service--payment .esun-payment-methods {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.esun-cart-service--payment .esun-payment-methods span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 0;
|
||||
height: 44px;
|
||||
padding: 6px 8px;
|
||||
border: 1px solid #d9dcdf;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.esun-cart-service--payment .esun-payment-methods img {
|
||||
display: block;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
height: 26px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.esun-cart-empty {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 260px;
|
||||
gap: 20px;
|
||||
padding: 30px;
|
||||
color: #464b4f;
|
||||
}
|
||||
|
||||
.esun-cart-wrapper.has-cart-items .esun-cart-empty:not(.esun-cart-loading),
|
||||
.esun-cart-wrapper:has(#mini-cart > .product-item)
|
||||
.esun-cart-empty:not(.esun-cart-loading),
|
||||
.esun-cart-wrapper.is-cart-syncing .esun-cart-empty:not(.esun-cart-loading) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.esun-cart-wrapper.has-no-cart-items:not(:has(#mini-cart > .product-item))
|
||||
.esun-cart-items-panel,
|
||||
.esun-cart-wrapper.has-no-cart-items:not(:has(#mini-cart > .product-item))
|
||||
.esun-cart-totals {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.esun-cart-wrapper:has(#mini-cart > .product-item) .esun-cart-items-panel {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.esun-cart-wrapper:has(#mini-cart > .product-item) .esun-cart-totals {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.esun-cart-loading {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.esun-cart-loading__spinner {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border: 3px solid #dcefe3;
|
||||
border-top-color: #159447;
|
||||
border-radius: 50%;
|
||||
animation: esun-cart-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes esun-cart-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart .esun-cart-empty .action.primary {
|
||||
display: inline-flex;
|
||||
width: auto;
|
||||
min-width: 176px;
|
||||
height: auto;
|
||||
min-height: 44px;
|
||||
padding: 11px 28px;
|
||||
border-radius: 22px;
|
||||
background: #18aa59;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
line-height: 22px;
|
||||
white-space: nowrap;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.header-top-link-item.header-minicart .esun-cart-empty .action.primary:hover,
|
||||
.header-top-link-item.header-minicart .esun-cart-empty .action.primary:focus {
|
||||
background: #148a47;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.esun-cart-service--payment .esun-payment-methods {
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
}
|
||||
.catalog-product-view .esun-product-service--payment {
|
||||
padding: 0 !important;
|
||||
}
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.block-minicart.esun-cart-drawer {
|
||||
width: 100vw !important;
|
||||
max-width: 100vw !important;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__header {
|
||||
min-height: 62px;
|
||||
padding: 10px 16px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__icon {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin-right: 9px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer__title,
|
||||
.esun-cart-drawer__count {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.esun-cart-progress {
|
||||
min-height: 122px;
|
||||
padding: 18px 19px 12px;
|
||||
}
|
||||
|
||||
.esun-cart-progress__step {
|
||||
width: 72px;
|
||||
}
|
||||
|
||||
.esun-cart-progress__value,
|
||||
.esun-cart-progress__label {
|
||||
width: 84px;
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.esun-cart-items-panel {
|
||||
flex-basis: auto;
|
||||
min-height: 0;
|
||||
margin: 0 16px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .minicart-items .product-item {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-image-container {
|
||||
flex-basis: 82px;
|
||||
width: 82px !important;
|
||||
height: 82px;
|
||||
margin-right: 11px;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item-details {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.esun-cart-drawer .product-item .action.delete {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.esun-cart-item__bottom {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.esun-cart-totals,
|
||||
.esun-cart-services {
|
||||
margin-right: 16px;
|
||||
margin-left: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.esun-cart-backdrop,
|
||||
.header-top-link-item.header-minicart
|
||||
.esun-cart-wrapper
|
||||
.block-minicart.esun-cart-drawer,
|
||||
.esun-cart-progress__fill {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
.esun-free-gift-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
margin-top: 4px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: #e8f7ef;
|
||||
color: #138a4b;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.esun-cart-item__qty--locked {
|
||||
align-items: center;
|
||||
height: auto;
|
||||
gap: 4px;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
overflow: visible;
|
||||
background: transparent;
|
||||
color: #353535;
|
||||
line-height: 1.4;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,310 @@
|
||||
.checkout-cart-index .esun-cart-recommended {
|
||||
--esun-green: #12ad5c;
|
||||
--esun-green-dark: #0c914c;
|
||||
--esun-text: #242424;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__slider {
|
||||
cursor: grab;
|
||||
min-width: 0;
|
||||
overflow-x: auto !important;
|
||||
overflow-y: hidden;
|
||||
overscroll-behavior-x: contain;
|
||||
scrollbar-width: none;
|
||||
scroll-behavior: smooth;
|
||||
scroll-snap-type: x mandatory;
|
||||
touch-action: pan-x pan-y;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__slider::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__slider.is-dragging {
|
||||
cursor: grabbing;
|
||||
scroll-behavior: auto;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__wrapper {
|
||||
align-items: stretch;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
gap: 22px;
|
||||
transform: none !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__item {
|
||||
background: #fff;
|
||||
border: 1px solid #eef2ef;
|
||||
border-radius: 18px;
|
||||
box-shadow: 0 8px 22px rgba(23, 50, 36, .08);
|
||||
box-sizing: border-box;
|
||||
flex: 0 0 calc((100% - 88px) / 5);
|
||||
height: auto;
|
||||
min-height: 374px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
padding: 14px;
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__image {
|
||||
background: #fafbfa;
|
||||
border-radius: 12px;
|
||||
display: block;
|
||||
height: 178px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__badge {
|
||||
background: var(--esun-green) !important;
|
||||
border-radius: 999px;
|
||||
color: #fff !important;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
left: 10px;
|
||||
line-height: 1;
|
||||
padding: 6px 9px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__image .product-image-container,
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__image .product-image-wrapper {
|
||||
height: 100%;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__image .product-image-wrapper {
|
||||
padding-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__image .product-image-photo {
|
||||
height: 100%;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
max-height: none;
|
||||
object-fit: contain;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__details {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
padding: 14px 2px 2px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__name {
|
||||
display: -webkit-box;
|
||||
font-size: 15px;
|
||||
font-weight: 750;
|
||||
line-height: 1.35;
|
||||
margin: 0 0 10px;
|
||||
min-height: 41px;
|
||||
overflow: hidden;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__name a {
|
||||
color: var(--esun-text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
margin: 0 0 10px;
|
||||
max-height: 24px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__tags span {
|
||||
background: #f6f8f7;
|
||||
border: 1px solid #e4e9e6;
|
||||
border-radius: 999px;
|
||||
color: #727a75;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
line-height: 20px;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__swatches {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin: 0 0 12px;
|
||||
max-height: 22px;
|
||||
min-height: 22px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__swatch {
|
||||
align-items: center;
|
||||
appearance: none;
|
||||
background: #fff;
|
||||
border: 1px solid #dfe5e1;
|
||||
border-radius: 50%;
|
||||
display: inline-flex;
|
||||
flex: 0 0 18px;
|
||||
height: 18px;
|
||||
justify-content: center;
|
||||
padding: 2px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__swatch > span,
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__swatch img {
|
||||
border-radius: 50%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__inner {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__footer {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: space-between;
|
||||
margin-top: auto;
|
||||
min-height: 42px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__price {
|
||||
align-items: baseline;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__final-price {
|
||||
color: var(--esun-green);
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__regular-price {
|
||||
color: #a8b0ab;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__actions,
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__actions form {
|
||||
border: 0 !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .action.tocart.esun-category-card__cart {
|
||||
align-items: center;
|
||||
background: var(--esun-green) !important;
|
||||
border: 0 !important;
|
||||
border-radius: 50% !important;
|
||||
box-shadow: none !important;
|
||||
color: #fff !important;
|
||||
display: inline-flex !important;
|
||||
height: 42px !important;
|
||||
justify-content: center;
|
||||
min-height: 42px !important;
|
||||
min-width: 42px !important;
|
||||
padding: 0 !important;
|
||||
width: 42px !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .action.tocart.esun-category-card__cart:hover,
|
||||
.checkout-cart-index .esun-cart-recommended .action.tocart.esun-category-card__cart:focus {
|
||||
background: var(--esun-green-dark) !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__cart svg {
|
||||
fill: none !important;
|
||||
height: 18px !important;
|
||||
max-height: 18px !important;
|
||||
max-width: 18px !important;
|
||||
stroke: currentColor;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
stroke-width: 1.9;
|
||||
width: 18px !important;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-category-card__cart span {
|
||||
clip: rect(0, 0, 0, 0);
|
||||
clip-path: inset(50%);
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__previous.is-disabled,
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__next.is-disabled,
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__previous:disabled,
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__next:disabled {
|
||||
cursor: default;
|
||||
opacity: .35;
|
||||
}
|
||||
|
||||
@media (max-width: 1439px) {
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__wrapper {
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__item {
|
||||
flex-basis: calc((100% - 60px) / 4);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1023px) {
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__wrapper {
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__item {
|
||||
flex-basis: calc((100% - 36px) / 3);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__wrapper {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__item {
|
||||
flex-basis: calc((100% - 16px) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 479px) {
|
||||
.checkout-cart-index .esun-cart-recommended .esun-recommended-products__item {
|
||||
flex-basis: 86%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,761 @@
|
||||
.checkout-index-index .am-checkout {
|
||||
width: 83.333333%;
|
||||
margin: 0 auto;
|
||||
max-width: 1600px;
|
||||
}
|
||||
.field-tooltip {
|
||||
display: none;
|
||||
}
|
||||
.checkout-index-index .esun-checkout-services {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 22px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.checkout-index-index dl.item-options {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.checkout-index-index .esun-checkout-service--payment {
|
||||
background: #f5f6f6;
|
||||
color: #444;
|
||||
font-size: 12px;
|
||||
padding: 20px 22px;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-service--payment h2 {
|
||||
color: #333;
|
||||
font-size: 19px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-service--payment .esun-payment-methods {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--payment
|
||||
.esun-payment-methods
|
||||
span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 0;
|
||||
height: 44px;
|
||||
padding: 6px 8px;
|
||||
border: 1px solid #d9dcdf;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--payment
|
||||
.esun-payment-methods
|
||||
img {
|
||||
display: block;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
height: 26px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-service--delivery {
|
||||
border-top: 1px solid #d9d9d9;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--delivery
|
||||
.esun-product-accordion__item {
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--delivery
|
||||
.esun-product-accordion__summary {
|
||||
align-items: center;
|
||||
color: #333;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
justify-content: space-between;
|
||||
line-height: 1.35;
|
||||
list-style: none;
|
||||
min-height: 56px;
|
||||
padding: 0 18px 0 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--delivery
|
||||
.esun-product-accordion__summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--delivery
|
||||
.esun-product-accordion__summary::after {
|
||||
content: "+";
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--delivery
|
||||
.esun-product-accordion__item[open]
|
||||
.esun-product-accordion__summary::after {
|
||||
content: "×";
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-service--delivery
|
||||
.esun-product-accordion__content {
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
padding: 0 0 22px;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-services .esun-product-service ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-services .esun-product-service li {
|
||||
margin: 0 0 8px;
|
||||
padding-left: 14px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-services .esun-product-service li::before {
|
||||
content: "·";
|
||||
left: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-services .esun-product-service a {
|
||||
color: #666;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Keep checkout form spacing consistent across Amasty checkout sections. */
|
||||
.checkout-index-index
|
||||
.amcheckout-main-container
|
||||
.amcheckout-step-container
|
||||
.field:not(.choice) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.amcheckout-main-container
|
||||
.amcheckout-step-container
|
||||
.field:not(.choice)
|
||||
> .label {
|
||||
display: block;
|
||||
line-height: 1.4;
|
||||
margin: 0 0 6px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field
|
||||
> .label,
|
||||
.checkout-index-index
|
||||
.amcheckout-form-login
|
||||
#customer-email-fieldset
|
||||
> .field
|
||||
> .label {
|
||||
box-sizing: border-box;
|
||||
float: none;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field
|
||||
> .control,
|
||||
.checkout-index-index
|
||||
.amcheckout-form-login
|
||||
#customer-email-fieldset
|
||||
> .field
|
||||
> .control {
|
||||
box-sizing: border-box;
|
||||
float: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.amcheckout-form-login
|
||||
.amcheckout-email
|
||||
.amcheckout-wrapper {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index .amcheckout-form-login .amcheckout-email .note {
|
||||
width: 100%;
|
||||
margin: 6px 0 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.field.street
|
||||
.control
|
||||
.nested
|
||||
.field {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout input[type="text"],
|
||||
.checkout-index-index .am-checkout input[type="password"],
|
||||
.checkout-index-index .am-checkout input[type="url"],
|
||||
.checkout-index-index .am-checkout input[type="tel"],
|
||||
.checkout-index-index .am-checkout input[type="search"],
|
||||
.checkout-index-index .am-checkout input[type="number"]:not(.qty),
|
||||
.checkout-index-index .am-checkout input[type="email"],
|
||||
.checkout-index-index .am-checkout select,
|
||||
.checkout-index-index .am-checkout textarea {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
border: 1px solid #aeb5b1;
|
||||
border-radius: 12px;
|
||||
background-color: #fff;
|
||||
box-shadow: none;
|
||||
color: #303437;
|
||||
font-size: 14px;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout input[type="text"],
|
||||
.checkout-index-index .am-checkout input[type="password"],
|
||||
.checkout-index-index .am-checkout input[type="url"],
|
||||
.checkout-index-index .am-checkout input[type="tel"],
|
||||
.checkout-index-index .am-checkout input[type="search"],
|
||||
.checkout-index-index .am-checkout input[type="number"]:not(.qty),
|
||||
.checkout-index-index .am-checkout input[type="email"] {
|
||||
height: 42px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout select {
|
||||
height: 42px;
|
||||
padding: 0 44px 0 16px;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
background-color: #fff;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%235b625e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 16px center;
|
||||
background-size: 14px 8px;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout textarea {
|
||||
min-height: 96px;
|
||||
padding: 11px 14px;
|
||||
line-height: 1.5;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.am-checkout
|
||||
input:not([type="checkbox"]):not([type="radio"]):not(.qty):focus,
|
||||
.checkout-index-index .am-checkout select:focus,
|
||||
.checkout-index-index .am-checkout textarea:focus {
|
||||
border-color: #18aa59;
|
||||
box-shadow: 0 0 0 3px rgba(24, 170, 89, 0.12);
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.am-checkout
|
||||
input.mage-error:not([type="checkbox"]):not([type="radio"]),
|
||||
.checkout-index-index .am-checkout select.mage-error,
|
||||
.checkout-index-index .am-checkout textarea.mage-error {
|
||||
border-color: #d94b4b;
|
||||
box-shadow: 0 0 0 3px rgba(217, 75, 75, 0.1);
|
||||
}
|
||||
|
||||
/* New shipping address modal lives outside .am-checkout. */
|
||||
.checkout-index-index .new-shipping-address-modal .modal-inner-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border-radius: 18px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-header {
|
||||
flex: 0 0 auto;
|
||||
padding: 26px 32px 16px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-title {
|
||||
margin: 0;
|
||||
padding: 0 48px 14px 0;
|
||||
border-bottom: 1px solid #dce3df;
|
||||
color: #292d30;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .action-close {
|
||||
top: 16px;
|
||||
right: 18px;
|
||||
color: #7d8581;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-content {
|
||||
flex: 1 1 auto;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 6px 32px 26px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .esun-checkout-address-form {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field:not(.choice)
|
||||
> .label,
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field:not(.choice)
|
||||
> .control {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field:not(.choice)
|
||||
> .label {
|
||||
margin: 0 0 6px;
|
||||
color: #303437;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
input:not([type="checkbox"]):not([type="radio"]),
|
||||
.checkout-index-index .new-shipping-address-modal select {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 42px;
|
||||
padding: 0 16px;
|
||||
border: 1px solid #aeb5b1;
|
||||
border-radius: 12px;
|
||||
background-color: #fff;
|
||||
box-shadow: none;
|
||||
color: #303437;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal select {
|
||||
padding-right: 44px;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%235b625e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 16px center;
|
||||
background-size: 14px 8px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
input:not([type="checkbox"]):not([type="radio"]):focus,
|
||||
.checkout-index-index .new-shipping-address-modal select:focus {
|
||||
border-color: #18aa59;
|
||||
box-shadow: 0 0 0 3px rgba(24, 170, 89, 0.12);
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .field.choice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 9px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .field.choice .label {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-footer {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
padding: 18px 32px 22px;
|
||||
border-top: 1px solid #e2e7e4;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-footer .action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
min-width: 112px;
|
||||
height: 42px;
|
||||
margin: 0;
|
||||
padding: 0 22px;
|
||||
border-radius: 21px;
|
||||
box-shadow: none;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.modal-footer
|
||||
.action-hide-popup {
|
||||
order: 1;
|
||||
border: 1px solid #18aa59;
|
||||
background: #fff;
|
||||
color: #168b4b;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.modal-footer
|
||||
.action-save-address {
|
||||
order: 2;
|
||||
border: 1px solid #18aa59;
|
||||
background: #18aa59;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.modal-footer
|
||||
.action-hide-popup:hover,
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.modal-footer
|
||||
.action-hide-popup:focus {
|
||||
border-color: #148f4b;
|
||||
background: #f2fbf6;
|
||||
color: #148f4b;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.modal-footer
|
||||
.action-save-address:hover,
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.modal-footer
|
||||
.action-save-address:focus {
|
||||
border-color: #148f4b;
|
||||
background: #148f4b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout.-classic .checkout-block {
|
||||
border: 1px solid #dcefe4;
|
||||
border-radius: 14px;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout.-classic .checkout-block:hover {
|
||||
border-color: #cce8d8;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout.-classic .checkout-block:focus-within {
|
||||
border-color: #b8dfca;
|
||||
box-shadow: 0 6px 20px rgba(24, 170, 89, 0.1);
|
||||
}
|
||||
.opc-block-summary .mark .value {
|
||||
display: none;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.checkout-index-index .new-shipping-address-modal .modal-inner-wrap {
|
||||
left: 50%;
|
||||
width: min(860px, calc(100% - 48px));
|
||||
max-width: 860px;
|
||||
max-height: calc(100vh - 48px);
|
||||
margin: 24px 0 0;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-address-form .fieldset.address {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 18px 20px;
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field {
|
||||
grid-column: 1 / -1;
|
||||
width: auto;
|
||||
margin-bottom: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".firstname"],
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".lastname"] {
|
||||
grid-column: span 3;
|
||||
order: 10;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".company"] {
|
||||
order: 15;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field.street {
|
||||
order: 20;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".city"] {
|
||||
order: 30;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".country_id"],
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".region_id"],
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".region"],
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".postcode"] {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".country_id"] {
|
||||
order: 40;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".region_id"],
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".region"] {
|
||||
order: 41;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".postcode"] {
|
||||
order: 42;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field[name$=".telephone"] {
|
||||
grid-column: 1 / -1;
|
||||
order: 18;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field.choice {
|
||||
order: 100;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.checkout-index-index .modal-popup.new-shipping-address-modal {
|
||||
right: 0;
|
||||
left: 0;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.modal-popup.new-shipping-address-modal
|
||||
.modal-inner-wrap[class] {
|
||||
width: auto;
|
||||
height: calc(100dvh - 24px);
|
||||
min-height: 0;
|
||||
max-height: calc(100dvh - 24px);
|
||||
margin: 12px;
|
||||
border-radius: 16px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-header {
|
||||
padding: 20px 20px 12px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-title {
|
||||
padding: 0 40px 12px 0;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .action-close {
|
||||
top: 9px;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-content {
|
||||
padding: 4px 20px 20px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field {
|
||||
width: 100%;
|
||||
margin-bottom: 14px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.new-shipping-address-modal
|
||||
input:not([type="checkbox"]):not([type="radio"]),
|
||||
.checkout-index-index .new-shipping-address-modal select {
|
||||
height: 42px;
|
||||
border-radius: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-footer {
|
||||
gap: 10px;
|
||||
padding: 14px 20px 18px;
|
||||
}
|
||||
|
||||
.checkout-index-index .new-shipping-address-modal .modal-footer .action {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
padding: 0 14px;
|
||||
}
|
||||
|
||||
.checkout-index-index .opc-estimated-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout {
|
||||
width: 100%;
|
||||
}
|
||||
.checkout-index-index .am-checkout.-classic .checkout-block {
|
||||
margin: 0 0 16px;
|
||||
padding: 18px 14px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.checkout-index-index .esun-checkout-address-form .fieldset.address {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.esun-checkout-address-form
|
||||
.fieldset.address
|
||||
> .field {
|
||||
margin-bottom: 14px;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.amcheckout-main-container
|
||||
.amcheckout-step-container
|
||||
.field:not(.choice)
|
||||
> .label {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.checkout-index-index
|
||||
.amcheckout-main-container
|
||||
.amcheckout-step-container
|
||||
input:not([type="checkbox"]):not([type="radio"]),
|
||||
.checkout-index-index
|
||||
.amcheckout-main-container
|
||||
.amcheckout-step-container
|
||||
select,
|
||||
.checkout-index-index
|
||||
.amcheckout-main-container
|
||||
.amcheckout-step-container
|
||||
textarea {
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout input[type="text"],
|
||||
.checkout-index-index .am-checkout input[type="password"],
|
||||
.checkout-index-index .am-checkout input[type="url"],
|
||||
.checkout-index-index .am-checkout input[type="tel"],
|
||||
.checkout-index-index .am-checkout input[type="search"],
|
||||
.checkout-index-index .am-checkout input[type="number"]:not(.qty),
|
||||
.checkout-index-index .am-checkout input[type="email"],
|
||||
.checkout-index-index .am-checkout select {
|
||||
height: 42px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.checkout-index-index .am-checkout textarea {
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
.modal-popup.esun-test-mode-modal .modal-inner-wrap {
|
||||
background: linear-gradient(180deg, #f1faf5 0, #fff 190px);
|
||||
border: 1px solid #dcefe4;
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 24px 70px rgba(11, 45, 28, 0.2);
|
||||
box-sizing: border-box;
|
||||
margin: 0 auto;
|
||||
max-width: 520px;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
top: 50%;
|
||||
transform: translateY(-200vh);
|
||||
width: calc(100% - 40px);
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal._show .modal-inner-wrap {
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-header {
|
||||
padding: 42px 56px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-title {
|
||||
border: 0;
|
||||
color: #161916;
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-title::before {
|
||||
align-items: center;
|
||||
background: #e1f5e9;
|
||||
border: 1px solid #c8ead6;
|
||||
border-radius: 50%;
|
||||
color: #18aa59;
|
||||
content: "!";
|
||||
display: flex;
|
||||
font-size: 34px;
|
||||
font-weight: 700;
|
||||
height: 70px;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
margin: 0 auto 22px;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .action-close {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
color: #646b67;
|
||||
height: 36px;
|
||||
padding: 0;
|
||||
right: 18px;
|
||||
top: 18px;
|
||||
transition: color 160ms ease, transform 160ms ease;
|
||||
width: 36px;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .action-close:hover,
|
||||
.modal-popup.esun-test-mode-modal .action-close:focus {
|
||||
color: #18aa59;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-content {
|
||||
padding: 18px 48px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal__message {
|
||||
color: #505652;
|
||||
font-size: 16px;
|
||||
line-height: 1.7;
|
||||
margin: 0;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal .modal-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 28px 40px 40px;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal .modal-footer .action-primary {
|
||||
align-items: center;
|
||||
background: #18aa59;
|
||||
border: 1px solid #18aa59;
|
||||
border-radius: 999px;
|
||||
box-shadow: none;
|
||||
color: #fff;
|
||||
display: inline-flex;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
justify-content: center;
|
||||
line-height: 20px;
|
||||
margin: 0;
|
||||
min-height: 50px;
|
||||
min-width: 190px;
|
||||
padding: 14px 32px;
|
||||
text-transform: none;
|
||||
transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal .modal-footer .action-primary:hover,
|
||||
.esun-test-mode-modal .modal-footer .action-primary:focus,
|
||||
.esun-test-mode-modal .modal-footer .action-primary:active {
|
||||
background: #148f4b;
|
||||
border-color: #148f4b;
|
||||
color: #fff;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.modal-popup.esun-test-mode-modal.modal-slide {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-inner-wrap {
|
||||
height: auto;
|
||||
max-height: calc(100vh - 32px);
|
||||
position: absolute;
|
||||
width: calc(100% - 32px);
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-header {
|
||||
padding: 36px 42px 0;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-title {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-title::before {
|
||||
font-size: 29px;
|
||||
height: 60px;
|
||||
margin-bottom: 18px;
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.modal-popup.esun-test-mode-modal .modal-content {
|
||||
padding: 16px 24px 0;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal__message {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal .modal-footer {
|
||||
padding: 24px 24px 30px;
|
||||
}
|
||||
|
||||
.esun-test-mode-modal .modal-footer .action-primary {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.modal-popup.esun-test-mode-modal .action-close,
|
||||
.esun-test-mode-modal .modal-footer .action-primary {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Esun_Cart/js/model/coupon-service'
|
||||
], function ($, couponService) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $page = $(element),
|
||||
submitTimer;
|
||||
|
||||
$page.on('click', '[data-esun-qty-change]', function () {
|
||||
var $button = $(this),
|
||||
$input = $button.siblings('[data-role="cart-item-qty"]'),
|
||||
currentQty = parseFloat($input.val()) || 1,
|
||||
difference = parseFloat($button.attr('data-esun-qty-change')) || 0,
|
||||
nextQty = Math.max(1, currentQty + difference);
|
||||
|
||||
if (nextQty === currentQty) {
|
||||
return;
|
||||
}
|
||||
|
||||
$input.val(nextQty).trigger('change');
|
||||
window.clearTimeout(submitTimer);
|
||||
submitTimer = window.setTimeout(function () {
|
||||
$page.find('.action.update').trigger('click');
|
||||
}, 350);
|
||||
});
|
||||
|
||||
$page.on('submit', '[data-role="esun-coupon-form"]', function (event) {
|
||||
event.preventDefault();
|
||||
saveCoupon($(this), false);
|
||||
});
|
||||
|
||||
$page.on('click', '[data-role="esun-coupon-form"] .esun-coupon__remove', function (event) {
|
||||
event.preventDefault();
|
||||
saveCoupon($(this).closest('form'), true);
|
||||
});
|
||||
|
||||
$(document).on('esun:customerCouponApplied.esunCartPage', function () {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
function saveCoupon($form, remove) {
|
||||
var $message = $form.find('[data-role="esun-coupon-message"]'),
|
||||
$buttons = $form.find('button'),
|
||||
couponCode = $.trim($form.find('[name="coupon_code"]').val() || '');
|
||||
|
||||
if ($form.data('loading')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!remove && !couponCode) {
|
||||
$message
|
||||
.removeClass('is-success')
|
||||
.addClass('is-error')
|
||||
.text($.mage.__('Please enter a coupon code.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$form.data('loading', true).addClass('is-loading');
|
||||
$buttons.prop('disabled', true);
|
||||
$message.removeClass('is-success is-error').empty();
|
||||
|
||||
(remove ? couponService.remove() : couponService.apply(couponCode)).done(function (response) {
|
||||
if (response && response.success) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
$message
|
||||
.addClass('is-error')
|
||||
.text(response && response.message
|
||||
? response.message
|
||||
: $.mage.__('We could not update the coupon code.'));
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
$message
|
||||
.addClass('is-error')
|
||||
.text(response.message ||
|
||||
$.mage.__('We could not update the coupon code. Please try again.'));
|
||||
}).always(function () {
|
||||
$form.data('loading', false).removeClass('is-loading');
|
||||
$buttons.prop('disabled', false);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/url',
|
||||
'mage/cookies'
|
||||
], function ($, urlBuilder) {
|
||||
'use strict';
|
||||
|
||||
function save(code, remove) {
|
||||
return $.ajax({
|
||||
url: urlBuilder.build('esun_cart/coupon/save/'),
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
coupon_code: code || '',
|
||||
remove: remove ? 1 : 0,
|
||||
form_key: $.mage.cookies.get('form_key')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
apply: function (code) {
|
||||
return save(code, false);
|
||||
},
|
||||
|
||||
remove: function () {
|
||||
return save('', true);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
define([], function () {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var slider = element.querySelector('.esun-recommended-products__slider'),
|
||||
wrapper = element.querySelector('.esun-recommended-products__wrapper'),
|
||||
previous = element.querySelector('.esun-recommended-products__previous'),
|
||||
next = element.querySelector('.esun-recommended-products__next'),
|
||||
pointerId = null,
|
||||
startX = 0,
|
||||
startScrollLeft = 0,
|
||||
dragged = false,
|
||||
lastPointerNavigation = 0;
|
||||
|
||||
if (!slider || !wrapper || !previous || !next) {
|
||||
return;
|
||||
}
|
||||
|
||||
function getMaxScroll() {
|
||||
return Math.max(0, slider.scrollWidth - slider.clientWidth);
|
||||
}
|
||||
|
||||
function getStep() {
|
||||
var item = wrapper.querySelector('.esun-recommended-products__item'),
|
||||
styles = window.getComputedStyle(wrapper),
|
||||
gap = parseFloat(styles.columnGap || styles.gap) || 0;
|
||||
|
||||
return item ? item.getBoundingClientRect().width + gap : slider.clientWidth;
|
||||
}
|
||||
|
||||
function updateNavigation() {
|
||||
var maxScroll = getMaxScroll(),
|
||||
atStart = slider.scrollLeft <= 1,
|
||||
atEnd = slider.scrollLeft >= maxScroll - 1;
|
||||
|
||||
previous.disabled = atStart;
|
||||
next.disabled = atEnd;
|
||||
previous.classList.toggle('is-disabled', atStart);
|
||||
next.classList.toggle('is-disabled', atEnd);
|
||||
element.classList.toggle('has-overflow', maxScroll > 1);
|
||||
}
|
||||
|
||||
function move(direction) {
|
||||
var target = Math.max(0, Math.min(getMaxScroll(), slider.scrollLeft + direction * getStep()));
|
||||
|
||||
if (typeof slider.scrollTo === 'function') {
|
||||
slider.scrollTo({left: target, behavior: 'smooth'});
|
||||
} else {
|
||||
slider.scrollLeft = target;
|
||||
}
|
||||
}
|
||||
|
||||
function bindButton(button, direction) {
|
||||
button.addEventListener('pointerdown', function (event) {
|
||||
if (event.button !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
lastPointerNavigation = Date.now();
|
||||
move(direction);
|
||||
}, true);
|
||||
button.addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (Date.now() - lastPointerNavigation > 400) {
|
||||
move(direction);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
bindButton(previous, -1);
|
||||
bindButton(next, 1);
|
||||
slider.addEventListener('scroll', updateNavigation, {passive: true});
|
||||
slider.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
||||
event.preventDefault();
|
||||
move(event.key === 'ArrowLeft' ? -1 : 1);
|
||||
}
|
||||
});
|
||||
slider.addEventListener('pointerdown', function (event) {
|
||||
if (event.pointerType === 'touch' || event.button !== 0 ||
|
||||
event.target.closest('button, input, select, textarea')) {
|
||||
return;
|
||||
}
|
||||
|
||||
pointerId = event.pointerId;
|
||||
startX = event.clientX;
|
||||
startScrollLeft = slider.scrollLeft;
|
||||
dragged = false;
|
||||
slider.setPointerCapture(pointerId);
|
||||
slider.classList.add('is-dragging');
|
||||
});
|
||||
slider.addEventListener('pointermove', function (event) {
|
||||
if (event.pointerId !== pointerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
dragged = dragged || Math.abs(event.clientX - startX) > 4;
|
||||
slider.scrollLeft = startScrollLeft - (event.clientX - startX);
|
||||
});
|
||||
slider.addEventListener('pointerup', function (event) {
|
||||
if (event.pointerId === pointerId) {
|
||||
slider.releasePointerCapture(pointerId);
|
||||
pointerId = null;
|
||||
slider.classList.remove('is-dragging');
|
||||
}
|
||||
});
|
||||
slider.addEventListener('click', function (event) {
|
||||
if (dragged) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
dragged = false;
|
||||
}
|
||||
}, true);
|
||||
window.addEventListener('resize', updateNavigation);
|
||||
window.requestAnimationFrame(updateNavigation);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,117 @@
|
||||
define([], function () {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var slider = element.querySelector('.esun-recommended-products__slider'),
|
||||
wrapper = element.querySelector('.esun-recommended-products__wrapper'),
|
||||
previous = element.querySelector('.esun-recommended-products__previous'),
|
||||
next = element.querySelector('.esun-recommended-products__next'),
|
||||
pointerId = null,
|
||||
startX = 0,
|
||||
startScrollLeft = 0,
|
||||
dragged = false,
|
||||
pointerNavigation = null;
|
||||
|
||||
if (!slider || !wrapper || !previous || !next) {
|
||||
return;
|
||||
}
|
||||
|
||||
function getMaxScroll() {
|
||||
return Math.max(0, slider.scrollWidth - slider.clientWidth);
|
||||
}
|
||||
|
||||
function getStep() {
|
||||
var firstItem = wrapper.querySelector('.esun-recommended-products__item'),
|
||||
styles = window.getComputedStyle(wrapper),
|
||||
gap = parseFloat(styles.columnGap || styles.gap) || 0;
|
||||
|
||||
return firstItem ? firstItem.getBoundingClientRect().width + gap : slider.clientWidth;
|
||||
}
|
||||
|
||||
function updateNavigation() {
|
||||
var maxScroll = getMaxScroll(),
|
||||
atStart = slider.scrollLeft <= 1,
|
||||
atEnd = slider.scrollLeft >= maxScroll - 1;
|
||||
|
||||
previous.disabled = atStart;
|
||||
next.disabled = atEnd;
|
||||
previous.classList.toggle('is-disabled', atStart);
|
||||
next.classList.toggle('is-disabled', atEnd);
|
||||
element.classList.toggle('has-overflow', maxScroll > 1);
|
||||
}
|
||||
|
||||
function scroll(direction) {
|
||||
slider.scrollBy({
|
||||
left: direction * getStep(),
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
function bindNavigation(button, direction) {
|
||||
button.addEventListener('pointerdown', function (event) {
|
||||
if (event.button !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pointerNavigation = button;
|
||||
scroll(direction);
|
||||
}, true);
|
||||
button.addEventListener('click', function () {
|
||||
if (pointerNavigation === button) {
|
||||
pointerNavigation = null;
|
||||
return;
|
||||
}
|
||||
|
||||
scroll(direction);
|
||||
});
|
||||
}
|
||||
|
||||
bindNavigation(previous, -1);
|
||||
bindNavigation(next, 1);
|
||||
slider.addEventListener('scroll', updateNavigation, {passive: true});
|
||||
slider.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
||||
event.preventDefault();
|
||||
scroll(event.key === 'ArrowLeft' ? -1 : 1);
|
||||
}
|
||||
});
|
||||
slider.addEventListener('pointerdown', function (event) {
|
||||
if (event.pointerType === 'touch' || event.button !== 0 ||
|
||||
event.target.closest('button, input, select, textarea')) {
|
||||
return;
|
||||
}
|
||||
|
||||
pointerId = event.pointerId;
|
||||
startX = event.clientX;
|
||||
startScrollLeft = slider.scrollLeft;
|
||||
dragged = false;
|
||||
slider.setPointerCapture(pointerId);
|
||||
slider.classList.add('is-dragging');
|
||||
});
|
||||
slider.addEventListener('pointermove', function (event) {
|
||||
if (event.pointerId !== pointerId) {
|
||||
return;
|
||||
}
|
||||
if (Math.abs(event.clientX - startX) > 4) {
|
||||
dragged = true;
|
||||
}
|
||||
slider.scrollLeft = startScrollLeft - (event.clientX - startX);
|
||||
});
|
||||
slider.addEventListener('pointerup', function (event) {
|
||||
if (event.pointerId === pointerId) {
|
||||
slider.releasePointerCapture(pointerId);
|
||||
pointerId = null;
|
||||
slider.classList.remove('is-dragging');
|
||||
}
|
||||
});
|
||||
slider.addEventListener('click', function (event) {
|
||||
if (dragged) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
dragged = false;
|
||||
}
|
||||
}, true);
|
||||
window.addEventListener('resize', updateNavigation);
|
||||
window.requestAnimationFrame(updateNavigation);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/alert'
|
||||
], function ($, alert) {
|
||||
'use strict';
|
||||
|
||||
return function (config) {
|
||||
var buttonSelector = 'button.action.tocart, [data-role="esun-buy-now"], #top-cart-btn-checkout',
|
||||
formSelector = '[data-role="tocart-form"], #product_addtocart_form';
|
||||
|
||||
function showNotice() {
|
||||
var content = $('<p>', {
|
||||
'class': 'esun-test-mode-modal__message',
|
||||
text: config.message
|
||||
}).prop('outerHTML');
|
||||
|
||||
alert({
|
||||
modalClass: 'esun-test-mode-modal',
|
||||
title: config.title,
|
||||
content: content
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
if (event.target.closest(buttonSelector)) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
showNotice();
|
||||
}
|
||||
}, true);
|
||||
|
||||
document.addEventListener('submit', function (event) {
|
||||
if (event.target.matches(formSelector)) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
showNotice();
|
||||
}
|
||||
}, true);
|
||||
|
||||
if (new URLSearchParams(window.location.search).get('purchase_test_mode') === '1') {
|
||||
showNotice();
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
define([
|
||||
'uiComponent'
|
||||
], function (Component) {
|
||||
'use strict';
|
||||
|
||||
return Component.extend({
|
||||
defaults: {
|
||||
template: 'Esun_Cart/checkout/services'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this._super();
|
||||
this.services = window.checkoutConfig.esunCartServices || {};
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,519 @@
|
||||
define([
|
||||
'Magento_Checkout/js/view/minicart',
|
||||
'Magento_Customer/js/customer-data',
|
||||
'jquery',
|
||||
'ko',
|
||||
'Magento_Ui/js/modal/alert',
|
||||
'Magento_Ui/js/modal/confirm',
|
||||
'mage/url',
|
||||
'Esun_Cart/js/model/coupon-service',
|
||||
'Esun_Reward/js/model/reward-service',
|
||||
'mage/translate',
|
||||
'mage/cookies'
|
||||
], function (Minicart, customerData, $, ko, alert, confirm, urlBuilder, couponService, rewardService) {
|
||||
'use strict';
|
||||
|
||||
return Minicart.extend({
|
||||
initialize: function () {
|
||||
var result,
|
||||
self = this;
|
||||
|
||||
this.isCartSyncing = ko.observable(true);
|
||||
this.customer = customerData.get('customer');
|
||||
this.couponCodeInput = ko.observable('');
|
||||
this.appliedCouponCode = ko.observable('');
|
||||
this.couponMessage = ko.observable('');
|
||||
this.couponMessageType = ko.observable('');
|
||||
this.isCouponLoading = ko.observable(false);
|
||||
this.rewardPointsInput = ko.observable(0);
|
||||
this.rewardMessage = ko.observable('');
|
||||
this.rewardMessageType = ko.observable('');
|
||||
this.isRewardLoading = ko.observable(false);
|
||||
this.cartRefreshInProgress = false;
|
||||
this.cartRefreshPending = false;
|
||||
this.itemQtyUpdateInProgress = {};
|
||||
this.itemRemoveInProgress = {};
|
||||
this.lastCartRefreshAt = 0;
|
||||
result = this._super();
|
||||
|
||||
this.bindDrawerEvents();
|
||||
if (!this.openAfterAddRedirect()) {
|
||||
self.refreshCart(true);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
update: function (updatedCart) {
|
||||
this._super(updatedCart);
|
||||
this.applyCartState(updatedCart);
|
||||
|
||||
if (updatedCart && updatedCart.drawer_totals) {
|
||||
this.appliedCouponCode(updatedCart.drawer_totals.coupon_code || '');
|
||||
this.couponCodeInput(updatedCart.drawer_totals.coupon_code || '');
|
||||
}
|
||||
if (updatedCart && updatedCart.reward) {
|
||||
this.rewardPointsInput(Number(updatedCart.reward.applied_points || 0));
|
||||
}
|
||||
},
|
||||
|
||||
applyCartState: function (cart) {
|
||||
var hasItems = Boolean(
|
||||
cart && (
|
||||
Number(cart.summary_count) > 0 ||
|
||||
cart.items && cart.items.length
|
||||
)
|
||||
);
|
||||
|
||||
$('[data-block="minicart"]')
|
||||
.toggleClass('has-cart-items', hasItems)
|
||||
.toggleClass('has-no-cart-items', !hasItems);
|
||||
},
|
||||
|
||||
bindDrawerEvents: function () {
|
||||
var $minicart = $('[data-block="minicart"]'),
|
||||
self = this;
|
||||
|
||||
$minicart.off('.esunCartDrawer')
|
||||
.on('dropdowndialogopen.esunCartDrawer', function () {
|
||||
self.refreshCart(false);
|
||||
$('body').addClass('esun-cart-is-open');
|
||||
$minicart.find('.action.showcart').attr('aria-expanded', 'true');
|
||||
window.setTimeout(function () {
|
||||
$minicart.find('#btn-minicart-close').trigger('focus');
|
||||
}, 0);
|
||||
})
|
||||
.on('dropdowndialogclose.esunCartDrawer', function () {
|
||||
$('body').removeClass('esun-cart-is-open');
|
||||
$minicart.find('.action.showcart').attr('aria-expanded', 'false');
|
||||
$minicart.find('.action.showcart').trigger('focus');
|
||||
})
|
||||
.on('click.esunCartDrawer', '[data-role="esun-cart-backdrop"]', function () {
|
||||
self.closeMinicart();
|
||||
})
|
||||
.on('keydown.esunCartDrawer', '.esun-cart-drawer', function (event) {
|
||||
self.trapFocus(event, $(this));
|
||||
});
|
||||
|
||||
$(document).off('ajax:addToCart.esunCartDrawer')
|
||||
.on('ajax:addToCart.esunCartDrawer', function (event, data) {
|
||||
if (!self.isSuccessfulAddResponse(data && data.response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.refreshCart(true);
|
||||
window.setTimeout(function () {
|
||||
self.openMinicartAfterAdd();
|
||||
}, 150);
|
||||
})
|
||||
.off('ajax:removeFromCart.esunCartDrawer')
|
||||
.on('ajax:removeFromCart.esunCartDrawer', function () {
|
||||
self.refreshCart(true);
|
||||
})
|
||||
.off('esun:customerCouponApplied.esunCartDrawer')
|
||||
.on('esun:customerCouponApplied.esunCartDrawer', function (event, response) {
|
||||
self.couponCodeInput(response && response.coupon_code || '');
|
||||
self.appliedCouponCode(response && response.coupon_code || '');
|
||||
self.couponMessageType('success');
|
||||
self.couponMessage(response && response.message || $.mage.__('The coupon code was applied.'));
|
||||
self.refreshCart(true);
|
||||
});
|
||||
},
|
||||
|
||||
isSuccessfulAddResponse: function (response) {
|
||||
var messages;
|
||||
|
||||
response = response || {};
|
||||
messages = String(response.messages || '').toLowerCase();
|
||||
|
||||
return !response.backUrl &&
|
||||
response.success !== false &&
|
||||
!response.error &&
|
||||
!response.error_message &&
|
||||
messages.indexOf('message-error') === -1 &&
|
||||
messages.indexOf('message error') === -1 &&
|
||||
!(response.product && response.product.statusText);
|
||||
},
|
||||
|
||||
openMinicartAfterAdd: function () {
|
||||
var $minicart = $('[data-block="minicart"]'),
|
||||
$trigger = $minicart.find('.action.showcart');
|
||||
|
||||
if (!$minicart.length || !$trigger.length || $minicart.hasClass('active')) {
|
||||
return;
|
||||
}
|
||||
$trigger.trigger('click');
|
||||
},
|
||||
|
||||
openAfterAddRedirect: function () {
|
||||
var shouldCheck = false,
|
||||
countBeforeAdd = 0,
|
||||
self = this;
|
||||
|
||||
try {
|
||||
shouldCheck = window.sessionStorage.getItem('esunOpenMinicartAfterAdd') === '1';
|
||||
countBeforeAdd = Number(
|
||||
window.sessionStorage.getItem('esunCartCountBeforeAdd')
|
||||
) || 0;
|
||||
window.sessionStorage.removeItem('esunOpenMinicartAfterAdd');
|
||||
window.sessionStorage.removeItem('esunCartCountBeforeAdd');
|
||||
} catch (error) {
|
||||
shouldCheck = false;
|
||||
}
|
||||
|
||||
if (!shouldCheck) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.refreshCart(true, function (cart) {
|
||||
if (Number(cart && cart.summary_count) > countBeforeAdd) {
|
||||
window.setTimeout(function () {
|
||||
self.openMinicartAfterAdd();
|
||||
}, 150);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
refreshCart: function (force, onSuccess) {
|
||||
var self = this,
|
||||
now = Date.now(),
|
||||
request,
|
||||
safetyTimer;
|
||||
|
||||
if (this.cartRefreshInProgress) {
|
||||
if (force) {
|
||||
this.cartRefreshPending = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid a duplicate request when the drawer is opened immediately
|
||||
// after the initial page-level customer-data synchronization.
|
||||
if (!force && now - this.lastCartRefreshAt < 3000) {
|
||||
this.isCartSyncing(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.cartRefreshInProgress = true;
|
||||
this.isCartSyncing(true);
|
||||
$('[data-block="minicart"]').addClass('is-cart-syncing');
|
||||
|
||||
// Do not wait for Magento_Customer's global initializer here. The
|
||||
// custom theme does not output it on every page, which would leave
|
||||
// customerData.reload() queued forever.
|
||||
request = $.ajax({
|
||||
url: urlBuilder.build('customer/section/load/'),
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
data: {
|
||||
sections: 'cart',
|
||||
force_new_section_timestamp: true
|
||||
}
|
||||
});
|
||||
|
||||
safetyTimer = window.setTimeout(function () {
|
||||
self.cartRefreshInProgress = false;
|
||||
self.lastCartRefreshAt = Date.now();
|
||||
self.isCartSyncing(false);
|
||||
$('[data-block="minicart"]').removeClass('is-cart-syncing');
|
||||
}, 15000);
|
||||
|
||||
request.done(function (sections) {
|
||||
var cart = sections && sections.cart;
|
||||
|
||||
// Release the loading UI before notifying subscribers so a
|
||||
// renderer error cannot leave the drawer permanently loading.
|
||||
self.isCartSyncing(false);
|
||||
if (cart) {
|
||||
self.update(cart);
|
||||
$(document).trigger('esun:cartUpdated', [cart]);
|
||||
if (typeof onSuccess === 'function') {
|
||||
onSuccess(cart);
|
||||
}
|
||||
window.setTimeout(function () {
|
||||
self.initSidebar();
|
||||
}, 0);
|
||||
}
|
||||
}).always(function () {
|
||||
var shouldRefreshAgain = self.cartRefreshPending;
|
||||
|
||||
window.clearTimeout(safetyTimer);
|
||||
self.cartRefreshInProgress = false;
|
||||
self.cartRefreshPending = false;
|
||||
self.lastCartRefreshAt = Date.now();
|
||||
self.isCartSyncing(false);
|
||||
$('[data-block="minicart"]').removeClass('is-cart-syncing');
|
||||
|
||||
if (shouldRefreshAgain) {
|
||||
window.setTimeout(function () {
|
||||
self.refreshCart(true);
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
trapFocus: function (event, $drawer) {
|
||||
var $focusable,
|
||||
first,
|
||||
last;
|
||||
|
||||
if (event.key !== 'Tab') {
|
||||
return;
|
||||
}
|
||||
|
||||
$focusable = $drawer.find('a, button, input, select, [tabindex]')
|
||||
.filter(':visible:not(:disabled)');
|
||||
if (!$focusable.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
first = $focusable.get(0);
|
||||
last = $focusable.get($focusable.length - 1);
|
||||
|
||||
if (event.shiftKey && document.activeElement === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
} else if (!event.shiftKey && document.activeElement === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
},
|
||||
|
||||
getCartItems: function () {
|
||||
return this.getCartParamUnsanitizedHtml('items') || [];
|
||||
},
|
||||
|
||||
getDrawerTotals: function () {
|
||||
return this.getCartParamUnsanitizedHtml('drawer_totals') || {
|
||||
subtotal: '',
|
||||
discount: '',
|
||||
shipping: '',
|
||||
grand_total: '',
|
||||
has_shipping_estimate: false,
|
||||
shipping_description: '',
|
||||
coupon_code: ''
|
||||
};
|
||||
},
|
||||
|
||||
getReward: function () {
|
||||
return this.getCartParamUnsanitizedHtml('reward') || {
|
||||
logged_in: false, balance: 0, applied_points: 0, maximum: 1500, rate: 100
|
||||
};
|
||||
},
|
||||
|
||||
updateRewardTotals: function (response) {
|
||||
var totals = $.extend({}, this.getDrawerTotals());
|
||||
|
||||
totals.reward_discount = response.reward_discount || '';
|
||||
if (response.grand_total) {
|
||||
totals.grand_total = response.grand_total;
|
||||
}
|
||||
this.cart.drawer_totals(totals);
|
||||
},
|
||||
|
||||
saveRewardPoints: function () {
|
||||
var self = this, points = Math.max(0, parseInt(this.rewardPointsInput(), 10) || 0);
|
||||
if (this.isRewardLoading()) { return false; }
|
||||
this.isRewardLoading(true); this.rewardMessage(''); this.rewardMessageType('');
|
||||
rewardService.apply(points).done(function (response) {
|
||||
self.rewardMessageType('success'); self.rewardMessage(response.message || '');
|
||||
self.refreshCart(true, function () { self.updateRewardTotals(response); });
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {}; self.rewardMessageType('error'); self.rewardMessage(response.message || $.mage.__('Unable to apply reward points.'));
|
||||
}).always(function () { self.isRewardLoading(false); });
|
||||
return false;
|
||||
},
|
||||
|
||||
saveCoupon: function (remove) {
|
||||
var self = this,
|
||||
couponCode = $.trim(this.couponCodeInput());
|
||||
|
||||
if (this.isCouponLoading()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!remove && !couponCode) {
|
||||
this.couponMessageType('error');
|
||||
this.couponMessage($.mage.__('Please enter a coupon code.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
this.isCouponLoading(true);
|
||||
this.couponMessage('');
|
||||
this.couponMessageType('');
|
||||
|
||||
(remove ? couponService.remove() : couponService.apply(couponCode)).done(function (response) {
|
||||
if (!response || !response.success) {
|
||||
self.couponMessageType('error');
|
||||
self.couponMessage(response && response.message
|
||||
? response.message
|
||||
: $.mage.__('We could not update the coupon code.'));
|
||||
return;
|
||||
}
|
||||
|
||||
self.couponCodeInput(response.coupon_code || '');
|
||||
self.appliedCouponCode(response.coupon_code || '');
|
||||
self.couponMessageType('success');
|
||||
self.couponMessage(response.message || '');
|
||||
self.refreshCart(true);
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
self.couponMessageType('error');
|
||||
self.couponMessage(response.message ||
|
||||
$.mage.__('We could not update the coupon code. Please try again.'));
|
||||
}).always(function () {
|
||||
self.isCouponLoading(false);
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
getProgress: function () {
|
||||
return this.getCartParamUnsanitizedHtml('purchase_progress') || {
|
||||
message: '',
|
||||
progress_percent: 0,
|
||||
milestones: []
|
||||
};
|
||||
},
|
||||
|
||||
changeItemQty: function (itemId, difference) {
|
||||
var $input = $('#cart-item-' + itemId + '-qty'),
|
||||
quantity = parseFloat($input.val()) || 1,
|
||||
minimumQty = parseFloat($input.attr('min')) || 1,
|
||||
nextQuantity = Math.max(minimumQty, quantity + difference);
|
||||
|
||||
if (nextQuantity === quantity || this.itemQtyUpdateInProgress[itemId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
$input.val(nextQuantity);
|
||||
this.updateItemQty(itemId, nextQuantity, quantity, $input);
|
||||
},
|
||||
|
||||
updateItemQty: function (itemId, quantity, previousQuantity, $input) {
|
||||
var self = this,
|
||||
$qtyButtons = $input.closest('[data-role="qty-box"]')
|
||||
.find('.esun-cart-item__qty-button');
|
||||
|
||||
this.itemQtyUpdateInProgress[itemId] = true;
|
||||
$qtyButtons.prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: window.checkout.updateItemQtyUrl || urlBuilder.build('checkout/sidebar/updateItemQty/'),
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
item_id: itemId,
|
||||
item_qty: quantity,
|
||||
form_key: $.mage.cookies.get('form_key')
|
||||
}
|
||||
}).done(function (response) {
|
||||
if (response && response.success) {
|
||||
self.refreshCart(true);
|
||||
return;
|
||||
}
|
||||
|
||||
$input.val(previousQuantity);
|
||||
alert({
|
||||
content: response && response.error_message
|
||||
? response.error_message
|
||||
: $.mage.__('Unable to update the cart item quantity.')
|
||||
});
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
$input.val(previousQuantity);
|
||||
alert({
|
||||
content: response.error_message || response.message ||
|
||||
$.mage.__('Unable to update the cart item quantity.')
|
||||
});
|
||||
}).always(function () {
|
||||
delete self.itemQtyUpdateInProgress[itemId];
|
||||
$qtyButtons.prop('disabled', false);
|
||||
});
|
||||
},
|
||||
|
||||
removeItem: function (itemId) {
|
||||
var self = this;
|
||||
|
||||
if (this.itemRemoveInProgress[itemId]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
confirm({
|
||||
content: $.mage.__('Are you sure you would like to remove this item from the shopping cart?'),
|
||||
actions: {
|
||||
confirm: function () {
|
||||
self.performRemoveItem(itemId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
performRemoveItem: function (itemId) {
|
||||
var self = this;
|
||||
|
||||
this.itemRemoveInProgress[itemId] = true;
|
||||
$.ajax({
|
||||
url: window.checkout.removeItemUrl || urlBuilder.build('checkout/sidebar/removeItem/'),
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
item_id: itemId,
|
||||
form_key: $.mage.cookies.get('form_key')
|
||||
}
|
||||
}).done(function (response) {
|
||||
if (response && response.success) {
|
||||
self.removeItemFromView(itemId);
|
||||
self.refreshCart(true);
|
||||
return;
|
||||
}
|
||||
|
||||
alert({
|
||||
content: response && response.error_message
|
||||
? response.error_message
|
||||
: $.mage.__('Unable to remove the cart item.')
|
||||
});
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
alert({
|
||||
content: response.error_message || response.message ||
|
||||
$.mage.__('Unable to remove the cart item.')
|
||||
});
|
||||
}).always(function () {
|
||||
delete self.itemRemoveInProgress[itemId];
|
||||
});
|
||||
},
|
||||
|
||||
removeItemFromView: function (itemId) {
|
||||
var items = this.getCartItems(),
|
||||
removedQuantity = 0,
|
||||
remainingItems = $.grep(items, function (item) {
|
||||
if (Number(item.item_id) === Number(itemId)) {
|
||||
removedQuantity += Number(item.qty) || 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}),
|
||||
summaryCount = Math.max(
|
||||
0,
|
||||
Number(this.getCartParamUnsanitizedHtml('summary_count') || 0) - removedQuantity
|
||||
),
|
||||
cartSnapshot = {
|
||||
items: remainingItems,
|
||||
summary_count: summaryCount
|
||||
};
|
||||
|
||||
this.update(cartSnapshot);
|
||||
$(document).trigger('esun:cartUpdated', [cartSnapshot]);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
<div class="esun-checkout-services">
|
||||
<section class="esun-checkout-service esun-checkout-service--payment">
|
||||
<h2 data-bind="i18n: 'Payment & Security'"></h2>
|
||||
<div data-bind="html: services.paymentSecurity"></div>
|
||||
</section>
|
||||
|
||||
<div class="esun-checkout-service--delivery esun-product-accordion">
|
||||
<details class="esun-product-accordion__item" open>
|
||||
<summary class="esun-product-accordion__summary">
|
||||
<span data-bind="i18n: 'Delivery and Shipping'"></span>
|
||||
</summary>
|
||||
<div class="esun-product-accordion__content"
|
||||
data-bind="html: services.deliveryShipping"></div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,270 @@
|
||||
<!--
|
||||
/**
|
||||
* eSUN cart drawer content.
|
||||
*/
|
||||
-->
|
||||
<div class="esun-cart-drawer__contents">
|
||||
<header class="esun-cart-drawer__header">
|
||||
<div class="esun-cart-drawer__title-wrap">
|
||||
<span class="esun-cart-drawer__icon" aria-hidden="true"></span>
|
||||
<strong id="esun-cart-title" class="esun-cart-drawer__title" translate="'My Shopping Cart'"></strong>
|
||||
<span class="items-total esun-cart-drawer__count">
|
||||
(<span text="getCartParam('summary_count') || 0"></span>)
|
||||
</span>
|
||||
</div>
|
||||
<button type="button"
|
||||
id="btn-minicart-close"
|
||||
class="action close"
|
||||
data-action="close"
|
||||
data-bind="attr: {title: $t('Close')}, click: closeMinicart">
|
||||
<span translate="'Close'"></span>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- ko if: getCartParam('vat_prompt') && getCartParam('vat_prompt').show -->
|
||||
<div class="cart_list_tips">
|
||||
<span translate="'If you are an EU VAT registered business, please contact Customer Service to'"></span>
|
||||
<a data-bind="attr: {href: getCartParam('vat_prompt').apply_url}" translate="'Apply for Tax Exemption'"></a>
|
||||
<span translate="'and make your purchases through the B2B account to apply the appropriate tax exemption provisions.'"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="esun-cart-empty">
|
||||
<strong translate="'Your shopping cart is empty.'"></strong>
|
||||
<a class="action primary" data-bind="attr: {href: shoppingCartUrl}" translate="'Continue Shopping'"></a>
|
||||
</div>
|
||||
|
||||
<section class="esun-cart-items-panel">
|
||||
<ol id="mini-cart"
|
||||
class="minicart-items"
|
||||
data-bind="foreach: {data: getCartItems(), as: 'item'}">
|
||||
<li class="product-item" data-role="product-item">
|
||||
<div class="product">
|
||||
<span class="product-image-container">
|
||||
<span class="product-image-wrapper">
|
||||
<img class="product-image-photo"
|
||||
data-bind="attr: {
|
||||
src: item.product_image.src,
|
||||
alt: item.product_image.alt,
|
||||
width: item.product_image.width,
|
||||
height: item.product_image.height
|
||||
}"/>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<div class="product-item-details">
|
||||
<div class="esun-cart-item__heading">
|
||||
<!-- ko if: item.is_esun_free_gift -->
|
||||
<span class="product-item-name" data-bind="html: item.product_name"></span>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: item.is_esun_free_gift -->
|
||||
<a class="product-item-name"
|
||||
data-bind="attr: {href: item.product_url},
|
||||
html: item.product_name"></a>
|
||||
<!-- /ko -->
|
||||
<!-- ko if: item.is_esun_free_gift -->
|
||||
<span class="esun-free-gift-label" data-bind="i18n: 'Free Gift'"></span>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: item.is_esun_free_gift -->
|
||||
<a href="#"
|
||||
class="action esun-cart-item__remove"
|
||||
data-bind="attr: {
|
||||
'data-cart-item': item.item_id,
|
||||
title: $t('Remove item'),
|
||||
'aria-label': $t('Remove item')
|
||||
}, click: $parent.removeItem.bind($parent, item.item_id)">
|
||||
<span translate="'Remove item'"></span>
|
||||
</a>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
|
||||
<!-- ko if: item.options && item.options.length -->
|
||||
<div class="product options">
|
||||
<!-- ko foreach: item.options -->
|
||||
<div class="esun-cart-item__option">
|
||||
<span class="label" data-bind="text: label + ':'"></span>
|
||||
<span class="values" data-bind="html: value"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="esun-cart-item__bottom">
|
||||
<!-- ko if: item.is_esun_free_gift -->
|
||||
<div class="esun-cart-item__qty esun-cart-item__qty--locked">
|
||||
<span data-bind="i18n: 'Qty'"></span>:
|
||||
<strong data-bind="text: item.qty"></strong>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: item.is_esun_free_gift -->
|
||||
<div class="esun-cart-item__qty" data-role="qty-box">
|
||||
<button type="button"
|
||||
class="esun-cart-item__qty-button"
|
||||
data-bind="click: function () {$parent.changeItemQty(item.item_id, -1)},
|
||||
disable: Number(item.qty) <= Number(item.min_sale_qty || 1),
|
||||
attr: {'aria-label': $t('Decrease quantity')}">−</button>
|
||||
<input type="number"
|
||||
class="item-qty cart-item-qty"
|
||||
readonly
|
||||
data-bind="attr: {
|
||||
id: 'cart-item-' + item.item_id + '-qty',
|
||||
'data-cart-item': item.item_id,
|
||||
'data-item-qty': item.qty,
|
||||
min: item.min_sale_qty || 1,
|
||||
'aria-label': $t('Quantity')
|
||||
}, value: item.qty"/>
|
||||
<button type="button"
|
||||
class="esun-cart-item__qty-button"
|
||||
data-bind="click: function () {$parent.changeItemQty(item.item_id, 1)},
|
||||
attr: {'aria-label': $t('Increase quantity')}">+</button>
|
||||
<button type="button"
|
||||
class="update-cart-item"
|
||||
style="display: none"
|
||||
data-bind="attr: {
|
||||
id: 'update-cart-item-' + item.item_id,
|
||||
'data-cart-item': item.item_id
|
||||
}"
|
||||
translate="'Update'">
|
||||
</button>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="esun-cart-item__price">
|
||||
<strong data-bind="html: item.line_total || item.product_price"></strong>
|
||||
<!-- ko if: item.original_price -->
|
||||
<span class="old-price" data-bind="html: item.original_price"></span>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section class="esun-cart-totals" data-bind="with: getDrawerTotals()">
|
||||
<div class="esun-cart-total-row subtotal">
|
||||
<span translate="'Subtotal'"></span>
|
||||
<span class="price" data-bind="html: $data.subtotal || ''"></span>
|
||||
</div>
|
||||
<div class="esun-cart-total-row">
|
||||
<span translate="'Discount'"></span>
|
||||
<span data-bind="html: $data.discount || ''"></span>
|
||||
</div>
|
||||
<!-- ko if: $data.reward_discount -->
|
||||
<div class="esun-cart-total-row">
|
||||
<span>
|
||||
<span translate="'Points Discount'"></span>
|
||||
(<span data-bind="text: $parent.getReward().applied_points"></span>
|
||||
<span translate="'points'"></span>)
|
||||
</span>
|
||||
<span data-bind="html: $data.reward_discount"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<div class="esun-cart-total-row">
|
||||
<span translate="'Estimated Shipping'"></span>
|
||||
<!-- ko if: $data.has_shipping_estimate -->
|
||||
<span data-bind="html: $data.shipping || '', attr: {title: $data.shipping_description || ''}"></span>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: $data.has_shipping_estimate -->
|
||||
<span class="esun-cart-total-row__pending" translate="'Calculated at checkout'"></span>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
<div class="esun-cart-total-row esun-cart-total-row--grand">
|
||||
<strong translate="'Total'"></strong>
|
||||
<strong data-bind="html: $data.grand_total || ''"></strong>
|
||||
</div>
|
||||
<div class="esun-coupon esun-coupon--mini">
|
||||
<div class="esun-coupon__title" translate="'Discount Code'"></div>
|
||||
<form class="esun-coupon__form"
|
||||
data-bind="visible: !$parent.appliedCouponCode(),
|
||||
submit: function () { return $parent.saveCoupon(false); }">
|
||||
<label class="esun-coupon__label" for="esun-mini-coupon-code">
|
||||
<span translate="'Enter discount code'"></span>
|
||||
</label>
|
||||
<div class="esun-coupon__controls">
|
||||
<input class="input-text esun-coupon__input"
|
||||
id="esun-mini-coupon-code"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
maxlength="255"
|
||||
data-bind="value: $parent.couponCodeInput,
|
||||
disable: $parent.isCouponLoading,
|
||||
attr: {placeholder: $t('Enter discount code')}"/>
|
||||
<button class="action esun-coupon__button"
|
||||
type="submit"
|
||||
data-bind="disable: $parent.isCouponLoading">
|
||||
<span translate="'Apply'"></span>
|
||||
</button>
|
||||
<button class="action esun-coupon__picker-button"
|
||||
type="button"
|
||||
aria-haspopup="dialog"
|
||||
data-role="open-coupon-picker">
|
||||
<span translate="'My Coupons'"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="esun-coupon__applied"
|
||||
data-bind="visible: $parent.appliedCouponCode">
|
||||
<span>
|
||||
<span data-bind="text: $t('Applied:')"></span>
|
||||
<strong data-bind="text: $parent.appliedCouponCode"></strong>
|
||||
</span>
|
||||
<button class="action esun-coupon__remove"
|
||||
type="button"
|
||||
data-bind="click: function () { $parent.saveCoupon(true); },
|
||||
disable: $parent.isCouponLoading">
|
||||
<span translate="'Cancel'"></span>
|
||||
</button>
|
||||
<button class="action esun-coupon__picker-button"
|
||||
type="button"
|
||||
aria-haspopup="dialog"
|
||||
data-role="open-coupon-picker">
|
||||
<span translate="'My Coupons'"></span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- ko if: $parent.couponMessage -->
|
||||
<div class="esun-coupon__message"
|
||||
aria-live="polite"
|
||||
data-bind="text: $parent.couponMessage,
|
||||
css: 'is-' + $parent.couponMessageType()"></div>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
<div class="esun-coupon esun-coupon--mini esun-reward-use esun-reward-use--mini">
|
||||
<div class="esun-coupon__title" translate="'Use Points'"></div>
|
||||
<!-- ko if: $parent.getReward().logged_in -->
|
||||
<p class="esun-reward-use__balance"><span data-bind="i18n: 'Available balance:'"></span> <strong data-bind="text: $parent.getReward().balance"></strong> <span data-bind="i18n: 'points'"></span></p>
|
||||
<form data-bind="submit: function () { return $parent.saveRewardPoints(); }">
|
||||
<div class="esun-coupon__controls">
|
||||
<label class="esun-coupon__label" for="esun-mini-reward-points" data-bind="i18n: 'Points to use'"></label>
|
||||
<input id="esun-mini-reward-points" class="input-text esun-coupon__input" type="number" min="0" data-bind="value: $parent.rewardPointsInput, attr: {max: Math.min(Number($parent.getReward().balance), Number($parent.getReward().maximum))}, disable: $parent.isRewardLoading"/>
|
||||
<button class="action esun-coupon__button" type="submit" data-bind="disable: $parent.isRewardLoading"><span data-bind="i18n: 'Apply'"></span></button>
|
||||
</div>
|
||||
<p class="note"><span data-bind="text: $parent.getReward().rate"></span> <span data-bind="i18n: 'points = $1. Maximum'"></span> <span data-bind="text: $parent.getReward().maximum"></span> <span data-bind="i18n: 'points per order.'"></span></p>
|
||||
<!-- ko if: $parent.rewardMessage --><div data-bind="text: $parent.rewardMessage, css: 'is-' + $parent.rewardMessageType()"></div><!-- /ko -->
|
||||
</form>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: $parent.getReward().logged_in --><p><a href="/customer/account/login/" data-bind="i18n: 'Sign in to use points.'"></a></p><!-- /ko -->
|
||||
</div>
|
||||
<button id="top-cart-btn-checkout"
|
||||
type="button"
|
||||
class="action primary checkout"
|
||||
data-action="close"
|
||||
translate="'Proceed to Checkout'">
|
||||
</button>
|
||||
<a class="action viewcart esun-cart-viewcart"
|
||||
data-bind="attr: {href: $parent.shoppingCartUrl}"
|
||||
translate="'My Shopping Cart'">
|
||||
</a>
|
||||
</section>
|
||||
|
||||
<!-- ko if: isCartSyncing() -->
|
||||
<div class="esun-cart-empty esun-cart-loading" role="status">
|
||||
<span class="esun-cart-loading__spinner" aria-hidden="true"></span>
|
||||
<strong translate="'Loading your cart…'"></strong>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
||||
<each args="getRegion('sign-in-popup')" render=""></each>
|
||||
</div>
|
||||
@@ -0,0 +1,88 @@
|
||||
<!--
|
||||
/**
|
||||
* eSUN cart drawer item.
|
||||
*/
|
||||
-->
|
||||
<li class="product-item" data-role="product-item">
|
||||
<div class="product">
|
||||
<span class="product-image-container">
|
||||
<span class="product-image-wrapper">
|
||||
<img class="product-image-photo"
|
||||
data-bind="attr: {src: product_image.src, alt: product_image.alt, width: product_image.width, height: product_image.height}"/>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<div class="product-item-details">
|
||||
<!-- ko if: is_esun_free_gift -->
|
||||
<span class="product-item-name" data-bind="html: product_name"></span>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: is_esun_free_gift -->
|
||||
<a class="product-item-name"
|
||||
data-bind="attr: {href: product_url}, html: product_name, click: $parents[1].closeMinicart"></a>
|
||||
<!-- /ko -->
|
||||
|
||||
<!-- ko if: is_esun_free_gift -->
|
||||
<span class="esun-free-gift-label" data-bind="i18n: 'Free Gift'"></span>
|
||||
<!-- /ko -->
|
||||
|
||||
<!-- ko if: options && options.length -->
|
||||
<div class="product options" data-bind="foreach: options">
|
||||
<span class="label" data-bind="text: label + ':'"></span>
|
||||
<span class="values" data-bind="html: value"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="esun-cart-item__bottom">
|
||||
<!-- ko if: is_esun_free_gift -->
|
||||
<div class="esun-cart-item__qty esun-cart-item__qty--locked">
|
||||
<span data-bind="i18n: 'Qty'"></span>:
|
||||
<strong data-bind="text: qty"></strong>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: is_esun_free_gift -->
|
||||
<div class="esun-cart-item__qty" data-role="qty-box">
|
||||
<button type="button"
|
||||
class="esun-cart-item__qty-button"
|
||||
data-bind="click: function () {$parents[1].changeItemQty(item_id, -1)},
|
||||
disable: Number(qty) <= Number(min_sale_qty || 1),
|
||||
attr: {'aria-label': $t('Decrease quantity')}">−</button>
|
||||
<input type="number"
|
||||
class="item-qty cart-item-qty"
|
||||
readonly
|
||||
data-bind="attr: {
|
||||
id: 'cart-item-' + item_id + '-qty',
|
||||
'data-cart-item': item_id,
|
||||
'data-item-qty': qty,
|
||||
min: min_sale_qty || 1,
|
||||
'aria-label': $t('Quantity')
|
||||
}, value: qty"/>
|
||||
<button type="button"
|
||||
class="esun-cart-item__qty-button"
|
||||
data-bind="click: function () {$parents[1].changeItemQty(item_id, 1)}, attr: {'aria-label': $t('Increase quantity')}">+</button>
|
||||
<button type="button"
|
||||
class="update-cart-item"
|
||||
style="display: none"
|
||||
data-bind="attr: {id: 'update-cart-item-' + item_id, 'data-cart-item': item_id}"
|
||||
translate="'Update'">
|
||||
</button>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="esun-cart-item__price">
|
||||
<strong data-bind="html: line_total || product_price"></strong>
|
||||
<!-- ko if: original_price -->
|
||||
<span class="old-price" data-bind="html: original_price"></span>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ko ifnot: is_esun_free_gift -->
|
||||
<a href="#"
|
||||
class="action delete"
|
||||
data-bind="attr: {'data-cart-item': item_id, title: $t('Remove item'), 'aria-label': $t('Remove item')}">
|
||||
<span translate="'Remove'"></span>
|
||||
</a>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</li>
|
||||
Reference in New Issue
Block a user