init
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceBlock name="main.swatches_visual">
|
||||
<arguments>
|
||||
<argument name="view_model" xsi:type="object">Esun\Catalog\ViewModel\Adminhtml\ColorOptionSwatchConfig</argument>
|
||||
</arguments>
|
||||
<action method="setTemplate">
|
||||
<argument name="template" xsi:type="string">Esun_Catalog::catalog/product/attribute/visual.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\CertificationType\EditBlock"
|
||||
name="esun.catalog.certification.type.edit"
|
||||
template="Esun_Catalog::certification_type/edit.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\CertificationType\ListBlock"
|
||||
name="esun.catalog.certification.type.list"
|
||||
template="Esun_Catalog::certification_type/list.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<update handle="esun_catalog_certificationtype_edit"/>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\ColorOption\EditBlock"
|
||||
name="esun.catalog.color.option.edit"
|
||||
template="Esun_Catalog::color_option/edit.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\ColorOption\ListBlock"
|
||||
name="esun.catalog.color.option.list"
|
||||
template="Esun_Catalog::color_option/list.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\ColorOption\EditBlock"
|
||||
name="esun.catalog.color.option.new"
|
||||
template="Esun_Catalog::color_option/edit.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\Faq\EditBlock"
|
||||
name="esun.catalog.faq.edit"
|
||||
template="Esun_Catalog::faq/edit.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\Faq\ListBlock"
|
||||
name="esun.catalog.faq.list"
|
||||
template="Esun_Catalog::faq/list.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<update handle="esun_catalog_faq_edit"/>
|
||||
</page>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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_Catalog::css/mix-step-pricing.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\MixStepPricing\Form" name="esun.mix.step.pricing.delete">
|
||||
<arguments>
|
||||
<argument name="mode" xsi:type="string">delete</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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_Catalog::css/mix-step-pricing.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\MixStepPricing\Form" name="esun.mix.step.pricing.import">
|
||||
<arguments>
|
||||
<argument name="mode" xsi:type="string">import</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\ProductRecommendation\ImportForm"
|
||||
name="esun.product.recommendation.import"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\SpecificationBrand\EditBlock"
|
||||
name="esun.catalog.specification.brand.edit"
|
||||
template="Esun_Catalog::specification_brand/edit.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<uiComponent name="esun_specification_brand_listing"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<update handle="esun_catalog_specificationbrand_edit"/>
|
||||
</page>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Adminhtml\SpecificationImport\EditBlock"
|
||||
name="esun.catalog.specification.import.edit"
|
||||
template="Esun_Catalog::specification_import/edit.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<uiComponent name="esun_specification_import_listing"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<update handle="esun_catalog_specificationimport_edit"/>
|
||||
</page>
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $block \Esun\Catalog\Block\Adminhtml\Attribute\Edit\Options\Visual
|
||||
* @var $escaper \Magento\Framework\Escaper
|
||||
*/
|
||||
$stores = $block->getStoresSortedBySortOrder();
|
||||
$viewModel = $block->getData('view_model');
|
||||
$jsonConfig = $viewModel instanceof \Esun\Catalog\ViewModel\Adminhtml\ColorOptionSwatchConfig
|
||||
? $viewModel->enrichJsonConfig((string)$block->getJsonConfig())
|
||||
: (string)$block->getJsonConfig();
|
||||
$isColorAttribute = $viewModel instanceof \Esun\Catalog\ViewModel\Adminhtml\ColorOptionSwatchConfig
|
||||
&& $viewModel->isColorAttribute((int)$block->getRequest()->getParam('attribute_id'));
|
||||
?>
|
||||
<fieldset class="admin__fieldset fieldset">
|
||||
<legend class="legend">
|
||||
<span><?= $escaper->escapeHtml(__('Manage Swatch (Values of Your Attribute)')) ?></span>
|
||||
</legend><br />
|
||||
<div class="admin__control-table-wrapper" id="swatch-visual-options-panel">
|
||||
<table class="data-table clearfix" cellspacing="0">
|
||||
<thead>
|
||||
<tr id="swatch-visual-options-table">
|
||||
<th class="col-draggable"></th>
|
||||
<th class="col-default"><span><?= $escaper->escapeHtml(__('Is Default')) ?></span></th>
|
||||
<th><span><?= $escaper->escapeHtml(__('Swatch')) ?></span></th>
|
||||
<?php foreach ($stores as $_store): ?>
|
||||
<th<?= ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID) ? ' class="_required"' : '' ?>>
|
||||
<span><?= $escaper->escapeHtml($_store->getName()) ?></span>
|
||||
</th>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($isColorAttribute): ?>
|
||||
<th><span><?= $escaper->escapeHtml(__('Hot Sale')) ?></span></th>
|
||||
<?php endif; ?>
|
||||
<th><span><?= $escaper->escapeHtml(__('Swatch Colors')) ?></span></th>
|
||||
<th><span><?= $escaper->escapeHtml(__('Color Ball Image')) ?></span></th>
|
||||
<?php $colTotal = count($stores) * 2 + 5 + (int)$isColorAttribute; ?>
|
||||
<th class="col-delete"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-role="swatch-visual-options-container" class="ignore-validate"></tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="<?= (int)$colTotal ?>">
|
||||
<input type="hidden" class="required-visual-swatch-entry" name="visual_swatch_validation"/>
|
||||
<input type="hidden" class="required-visual-swatch-unique" name="visual_swatch_validation_unique"/>
|
||||
<input type="hidden" name="reset_is-default_option"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="<?= (int)$colTotal ?>" class="col-actions-add">
|
||||
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
|
||||
<button id="add_new_swatch_visual_option_button"
|
||||
title="<?= $escaper->escapeHtml(__('Add Swatch')) ?>"
|
||||
type="button" class="action- scalable add">
|
||||
<span><?= $escaper->escapeHtml(__('Add Swatch')) ?></span>
|
||||
</button>
|
||||
|
||||
<button id="reset_default_swatch_visual_option_button"
|
||||
title="<?= $escaper->escapeHtml(__('Reset Is Default')) ?>"
|
||||
type="button" class="action- scalable reset">
|
||||
<span><?= $escaper->escapeHtml(__('Reset Is Default')) ?></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<input type="hidden" id="swatch-visual-option-count-check" value="" />
|
||||
</div>
|
||||
<style>
|
||||
.esun-color-option-col {
|
||||
min-width: 190px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.esun-color-option-col .note {
|
||||
color: #777;
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.esun-color-ball-preview {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.esun-color-ball-preview img {
|
||||
border: 1px solid #d6d6d6;
|
||||
border-radius: 50%;
|
||||
height: 42px;
|
||||
object-fit: contain;
|
||||
width: 42px;
|
||||
}
|
||||
</style>
|
||||
<script id="swatch-visual-row-template" type="text/x-magento-template">
|
||||
<tr>
|
||||
<td class="col-draggable">
|
||||
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
|
||||
<div data-role="draggable-handle" class="draggable-handle"
|
||||
title="<?= $escaper->escapeHtml(__('Sort Option')) ?>"></div>
|
||||
<?php endif; ?>
|
||||
<input data-role="order" type="hidden" name="optionvisual[order][<%- data.id %>]" value="<%- data.sort_order %>" <?= ($block->getReadOnly() || $block->canManageOptionDefaultOnly()) ? ' disabled="disabled"' : '' ?>/>
|
||||
</td>
|
||||
<td class="col-default">
|
||||
<input class="input-radio" type="<%- data.intype %>" name="defaultvisual[]" value="<%- data.id %>" <%- data.checked %><?= ($block->getReadOnly()) ? ' disabled="disabled"' : '' ?>/>
|
||||
</td>
|
||||
<td class="swatches-visual-col col-default <%- data.empty_class %>">
|
||||
<input id="swatch_visual_value_<%- data.id %>" type="hidden" name="swatchvisual[value][<%- data.id %>]" value="<%- data.defaultswatch0 %>" />
|
||||
<div class="swatch_window" id="swatch_window_option_<%- data.id %>" style="<%- data.swatch0 %>"></div>
|
||||
<div class="swatch_sub-menu_container" id="swatch_container_option_<%- data.id %>">
|
||||
<div class="swatch_row position-relative">
|
||||
<div class="swatch_row_name colorpicker_handler">
|
||||
<p><?= $escaper->escapeHtml(__('Choose a color')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swatch_row">
|
||||
<div class="swatch_row_name btn_choose_file_upload" id="swatch_choose_file_option_<%- data.id %>">
|
||||
<p><?= $escaper->escapeHtml(__('Upload a file')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swatch_row">
|
||||
<div class="swatch_row_name btn_remove_swatch">
|
||||
<p><?= $escaper->escapeHtml(__('Clear')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<?php foreach ($stores as $_store): ?>
|
||||
<td class="swatch-col-<%- data.id %>">
|
||||
<input name="optionvisual[value][<%- data.id %>][<?= (int)$_store->getId() ?>]"
|
||||
value="<%- data.store<?= (int) $_store->getId() ?> %>"
|
||||
class="input-text<?= ($_store->getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID) ? ' required-option required-unique' : '' ?>"
|
||||
type="text" <?= ($block->getReadOnly() || $block->canManageOptionDefaultOnly()) ? ' disabled="disabled"' : '' ?>/>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($isColorAttribute): ?>
|
||||
<td class="col-default">
|
||||
<input type="hidden"
|
||||
name="esun_color_option[<%- data.id %>][is_hot_sale]"
|
||||
value="0" />
|
||||
<input class="admin__control-checkbox"
|
||||
id="esun-color-hot-sale-<%- data.id %>"
|
||||
type="checkbox"
|
||||
name="esun_color_option[<%- data.id %>][is_hot_sale]"
|
||||
value="1"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Hot Sale')) ?>"
|
||||
<% if (data.esun_is_hot_sale) { %>checked="checked"<% } %>
|
||||
<?= ($block->getReadOnly() || $block->canManageOptionDefaultOnly()) ? ' disabled="disabled"' : '' ?> />
|
||||
<label for="esun-color-hot-sale-<%- data.id %>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('Hot Sale')) ?>"></label>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="esun-color-option-col">
|
||||
<input class="input-text"
|
||||
type="text"
|
||||
name="esun_color_option[<%- data.id %>][swatch_colors]"
|
||||
value="<%- data.esun_swatch_colors %>"
|
||||
placeholder="#FF0000,#FFD800,#18A957" />
|
||||
<span class="note"><?= $escaper->escapeHtml(__('Used only for the product-page color swatch selector.')) ?></span>
|
||||
</td>
|
||||
<td class="esun-color-option-col">
|
||||
<input type="hidden" name="esun_color_option[<%- data.id %>][ball_image]" value="<%- data.esun_ball_image %>" data-role="esun-ball-image-existing" />
|
||||
<input type="hidden" name="esun_color_option[<%- data.id %>][ball_image_base64]" value="<%- data.esun_ball_image_base64 %>" data-role="esun-ball-image-base64" />
|
||||
<input type="hidden" name="esun_color_option[<%- data.id %>][ball_image_name]" value="<%- data.esun_ball_image_name %>" data-role="esun-ball-image-name" />
|
||||
<input type="hidden" name="esun_color_option[<%- data.id %>][delete_ball_image]" value="<%- data.esun_delete_ball_image %>" data-role="esun-delete-ball-image" />
|
||||
<input type="file" class="admin__control-file esun-color-ball-input" accept=".jpg,.jpeg,.png,.gif,.webp" />
|
||||
<div class="esun-color-ball-preview" data-role="esun-ball-preview" <% if (!data.esun_ball_image_url) { %>style="display:none"<% } %>>
|
||||
<img src="<%- data.esun_ball_image_url %>" alt="" data-role="esun-ball-preview-image" />
|
||||
<button type="button" class="action-default esun-color-ball-remove">
|
||||
<span><?= $escaper->escapeHtml(__('Remove')) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<span class="note"><?= $escaper->escapeHtml(__('Used only in Available Colors.')) ?></span>
|
||||
</td>
|
||||
<td id="delete_button_swatch_container_<%- data.id %>" class="col-delete">
|
||||
<input type="hidden" class="delete-flag" name="optionvisual[delete][<%- data.id %>]" value="" />
|
||||
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
|
||||
<button title="<?= $escaper->escapeHtml(__('Delete')) ?>" type="button"
|
||||
class="action- scalable delete delete-option">
|
||||
<span><?= $escaper->escapeHtml(__('Delete')) ?></span>
|
||||
</button>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Swatches/js/visual": <?= /* @noEscape */ $jsonConfig ?> ,
|
||||
"Esun_Catalog/js/color-option-swatch-admin": {},
|
||||
"Magento_Catalog/catalog/product/attribute/unique-validate": {
|
||||
"element": "required-visual-swatch-unique",
|
||||
"message": "<?= $escaper->escapeHtml(__("The value of Admin must be unique.")) ?>"
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\CertificationType\EditBlock $block */
|
||||
$type = $block->getTypeModel();
|
||||
$icon = (string)$type->getData('icon');
|
||||
?>
|
||||
<div class="page-main-actions">
|
||||
<div class="page-actions">
|
||||
<a class="action-secondary" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
|
||||
<?= $block->escapeHtml(__('Back')) ?>
|
||||
</a>
|
||||
<button class="action-primary" type="submit" form="esun-certification-type-form">
|
||||
<?= $block->escapeHtml(__('Save Certification Type')) ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="esun-certification-type-form"
|
||||
class="admin__fieldset"
|
||||
action="<?= $block->escapeUrl($block->getSaveUrl()) ?>"
|
||||
method="post"
|
||||
enctype="multipart/form-data">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="type_id" value="<?= (int)$type->getId() ?>">
|
||||
|
||||
<div class="admin__field _required">
|
||||
<label class="admin__field-label" for="certification-name">
|
||||
<span><?= $block->escapeHtml(__('Certification Type Name')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="certification-name"
|
||||
class="admin__control-text required-entry"
|
||||
type="text"
|
||||
name="name"
|
||||
value="<?= $block->escapeHtmlAttr((string)$type->getData('name')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="certification-icon">
|
||||
<span><?= $block->escapeHtml(__('Icon')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<?php if ($icon !== ''): ?>
|
||||
<p>
|
||||
<img src="<?= $block->escapeUrl($block->getIconUrl($icon)) ?>"
|
||||
alt=""
|
||||
style="height:70px;max-width:120px;object-fit:contain;">
|
||||
</p>
|
||||
<label>
|
||||
<input type="checkbox" name="delete_icon" value="1">
|
||||
<?= $block->escapeHtml(__('Delete current icon')) ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<input id="certification-icon"
|
||||
class="admin__control-file"
|
||||
type="file"
|
||||
name="icon"
|
||||
accept=".jpg,.jpeg,.png,.gif,.webp,.svg">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="certification-status">
|
||||
<span><?= $block->escapeHtml(__('Status')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<select id="certification-status" class="admin__control-select" name="status">
|
||||
<option value="1"<?= (int)$type->getData('status') !== 0 ? ' selected' : '' ?>>
|
||||
<?= $block->escapeHtml(__('Enabled')) ?>
|
||||
</option>
|
||||
<option value="0"<?= (int)$type->getData('status') === 0 ? ' selected' : '' ?>>
|
||||
<?= $block->escapeHtml(__('Disabled')) ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="certification-sort-order">
|
||||
<span><?= $block->escapeHtml(__('Sort Order')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="certification-sort-order"
|
||||
class="admin__control-text"
|
||||
type="number"
|
||||
name="sort_order"
|
||||
value="<?= (int)$type->getData('sort_order') ?>">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\CertificationType\ListBlock $block */
|
||||
$types = $block->getTypes();
|
||||
?>
|
||||
<div class="page-main-actions">
|
||||
<div class="page-actions">
|
||||
<a class="action-primary" href="<?= $block->escapeUrl($block->getNewUrl()) ?>">
|
||||
<?= $block->escapeHtml(__('Add Certification Type')) ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="data-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('ID')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Icon')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Certification Type Name')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Status')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Sort Order')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Action')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($types->getSize()): ?>
|
||||
<?php foreach ($types as $type): ?>
|
||||
<tr>
|
||||
<td><?= (int)$type->getId() ?></td>
|
||||
<td>
|
||||
<?php if ((string)$type->getData('icon') !== ''): ?>
|
||||
<img src="<?= $block->escapeUrl($block->getIconUrl((string)$type->getData('icon'))) ?>"
|
||||
alt=""
|
||||
style="height:44px;max-width:80px;object-fit:contain;">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= $block->escapeHtml((string)$type->getData('name')) ?></td>
|
||||
<td><?= $block->escapeHtml((int)$type->getData('status') === 1 ? __('Enabled') : __('Disabled')) ?></td>
|
||||
<td><?= (int)$type->getData('sort_order') ?></td>
|
||||
<td>
|
||||
<a href="<?= $block->escapeUrl($block->getEditUrl((int)$type->getId())) ?>">
|
||||
<?= $block->escapeHtml(__('Edit')) ?>
|
||||
</a>
|
||||
|
|
||||
<a href="<?= $block->escapeUrl($block->getDeleteUrl((int)$type->getId())) ?>"
|
||||
onclick="return confirm('<?= $block->escapeJs(__('Are you sure you want to delete this certification type?')) ?>');">
|
||||
<?= $block->escapeHtml(__('Delete')) ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="6"><?= $block->escapeHtml(__('No certification types found.')) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\ColorOption\EditBlock $block */
|
||||
$item = $block->getItem();
|
||||
$ballImage = (string)$item->getData('ball_image');
|
||||
?>
|
||||
<div class="page-main-actions">
|
||||
<div class="page-actions">
|
||||
<a class="action-secondary" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
|
||||
<?= $block->escapeHtml(__('Back')) ?>
|
||||
</a>
|
||||
<button class="action-primary" type="submit" form="esun-color-option-form">
|
||||
<?= $block->escapeHtml(__('Save Color Option')) ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="esun-color-option-form"
|
||||
class="admin__fieldset"
|
||||
action="<?= $block->escapeUrl($block->getSaveUrl()) ?>"
|
||||
method="post"
|
||||
enctype="multipart/form-data">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="entity_id" value="<?= (int)$item->getId() ?>">
|
||||
|
||||
<div class="admin__field _required">
|
||||
<label class="admin__field-label" for="color-option-id">
|
||||
<span><?= $block->escapeHtml(__('Color Option')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<select id="color-option-id" class="admin__control-select required-entry" name="option_id">
|
||||
<option value=""><?= $block->escapeHtml(__('-- Please Select --')) ?></option>
|
||||
<?php foreach ($block->getColorOptions() as $option): ?>
|
||||
<?php $optionId = (int)$option['value']; ?>
|
||||
<option value="<?= $optionId ?>"<?= (int)$item->getData('option_id') === $optionId ? ' selected' : '' ?>>
|
||||
<?= $block->escapeHtml((string)$option['label']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="color-display-name">
|
||||
<span><?= $block->escapeHtml(__('Display Name')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="color-display-name"
|
||||
class="admin__control-text"
|
||||
type="text"
|
||||
name="display_name"
|
||||
value="<?= $block->escapeHtmlAttr((string)$item->getData('display_name')) ?>">
|
||||
<div class="admin__field-note">
|
||||
<?= $block->escapeHtml(__('Leave empty to use the Magento color option label.')) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="color-swatch-colors">
|
||||
<span><?= $block->escapeHtml(__('Swatch Colors')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="color-swatch-colors"
|
||||
class="admin__control-text"
|
||||
type="text"
|
||||
name="swatch_colors"
|
||||
value="<?= $block->escapeHtmlAttr((string)$item->getData('swatch_colors')) ?>"
|
||||
placeholder="#FF0000,#FFD800,#18A957">
|
||||
<div class="admin__field-note">
|
||||
<?= $block->escapeHtml(__('Comma-separated hex colors. These are used only for the product-page color swatch selector.')) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="color-ball-image">
|
||||
<span><?= $block->escapeHtml(__('Color Ball Image')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<?php if ($ballImage !== ''): ?>
|
||||
<p>
|
||||
<img src="<?= $block->escapeUrl($block->getImageUrl($ballImage)) ?>"
|
||||
alt=""
|
||||
style="height:80px;width:80px;object-fit:contain;">
|
||||
</p>
|
||||
<label>
|
||||
<input type="checkbox" name="delete_ball_image" value="1">
|
||||
<?= $block->escapeHtml(__('Delete current image')) ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<input id="color-ball-image"
|
||||
class="admin__control-file"
|
||||
type="file"
|
||||
name="ball_image"
|
||||
accept=".jpg,.jpeg,.png,.gif,.webp">
|
||||
<div class="admin__field-note">
|
||||
<?= $block->escapeHtml(__('This image is used only in the Available Colors section.')) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="color-is-hot-sale">
|
||||
<span><?= $block->escapeHtml(__('Hot Sale')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input type="hidden" name="is_hot_sale" value="0">
|
||||
<input id="color-is-hot-sale"
|
||||
class="admin__control-checkbox"
|
||||
type="checkbox"
|
||||
name="is_hot_sale"
|
||||
value="1"<?= (int)$item->getData('is_hot_sale') === 1 ? ' checked' : '' ?>>
|
||||
<label for="color-is-hot-sale">
|
||||
<span><?= $block->escapeHtml(__('Show this color as a Hot Sale color in category filters.')) ?></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="color-status">
|
||||
<span><?= $block->escapeHtml(__('Status')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<select id="color-status" class="admin__control-select" name="status">
|
||||
<option value="1"<?= (int)$item->getData('status') !== 0 ? ' selected' : '' ?>>
|
||||
<?= $block->escapeHtml(__('Enabled')) ?>
|
||||
</option>
|
||||
<option value="0"<?= (int)$item->getData('status') === 0 ? ' selected' : '' ?>>
|
||||
<?= $block->escapeHtml(__('Disabled')) ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label" for="color-sort-order">
|
||||
<span><?= $block->escapeHtml(__('Sort Order')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="color-sort-order"
|
||||
class="admin__control-text"
|
||||
type="number"
|
||||
name="sort_order"
|
||||
value="<?= (int)$item->getData('sort_order') ?>">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\ColorOption\ListBlock $block */
|
||||
$items = $block->getItems();
|
||||
?>
|
||||
<div class="page-main-actions">
|
||||
<div class="page-actions">
|
||||
<a class="action-primary" href="<?= $block->escapeUrl($block->getNewUrl()) ?>">
|
||||
<?= $block->escapeHtml(__('Add Color Option')) ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="data-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('ID')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Color Option')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Display Name')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Swatch Colors')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Color Ball')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Hot Sale')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Status')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Sort Order')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Action')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($items->getSize()): ?>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php
|
||||
$swatchColors = array_filter(array_map('trim', explode(',', (string)$item->getData('swatch_colors'))));
|
||||
$ballImage = (string)$item->getData('ball_image');
|
||||
?>
|
||||
<tr>
|
||||
<td><?= (int)$item->getId() ?></td>
|
||||
<td><?= $block->escapeHtml($block->getColorOptionLabel((int)$item->getData('option_id'))) ?></td>
|
||||
<td><?= $block->escapeHtml((string)$item->getData('display_name')) ?></td>
|
||||
<td>
|
||||
<?php foreach ($swatchColors as $color): ?>
|
||||
<span title="<?= $block->escapeHtmlAttr($color) ?>"
|
||||
style="display:inline-block;width:22px;height:22px;border:1px solid #ccc;border-radius:50%;background:<?= $block->escapeHtmlAttr($color) ?>;"></span>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($ballImage !== ''): ?>
|
||||
<img src="<?= $block->escapeUrl($block->getImageUrl($ballImage)) ?>"
|
||||
alt=""
|
||||
style="height:44px;width:44px;object-fit:contain;">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= $block->escapeHtml((int)$item->getData('is_hot_sale') === 1 ? __('Yes') : __('No')) ?></td>
|
||||
<td><?= $block->escapeHtml((int)$item->getData('status') === 1 ? __('Enabled') : __('Disabled')) ?></td>
|
||||
<td><?= (int)$item->getData('sort_order') ?></td>
|
||||
<td>
|
||||
<a href="<?= $block->escapeUrl($block->getEditUrl((int)$item->getId())) ?>">
|
||||
<?= $block->escapeHtml(__('Edit')) ?>
|
||||
</a>
|
||||
|
|
||||
<a href="<?= $block->escapeUrl($block->getDeleteUrl((int)$item->getId())) ?>"
|
||||
onclick="return confirm('<?= $block->escapeJs(__('Are you sure you want to delete this color option?')) ?>');">
|
||||
<?= $block->escapeHtml(__('Delete')) ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="9"><?= $block->escapeHtml(__('No color options found.')) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\Faq\EditBlock $block */
|
||||
$faq = $block->getFaqModel();
|
||||
$selectedStores = array_map('intval', explode(',', (string)($faq->getData('store_ids') ?: '0')));
|
||||
?>
|
||||
<form method="post" action="<?= $block->escapeUrl($block->getSaveUrl()) ?>">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="faq_id" value="<?= (int)$faq->getId() ?>">
|
||||
<div class="page-main-actions"><div class="page-actions">
|
||||
<a class="action-secondary" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
|
||||
<span><?= $block->escapeHtml(__('Back')) ?></span>
|
||||
</a>
|
||||
<button class="action-primary" type="submit"><span><?= $block->escapeHtml(__('Save FAQ')) ?></span></button>
|
||||
</div></div>
|
||||
<fieldset class="admin__fieldset">
|
||||
<div class="admin__field _required">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Title')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<input class="admin__control-text" type="text" name="title" required
|
||||
value="<?= $block->escapeHtmlAttr((string)$faq->getData('title')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Stores')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<select class="admin__control-multiselect" name="store_ids[]" multiple size="8">
|
||||
<?php foreach ($block->getStoreOptions() as $group): ?>
|
||||
<?php if (isset($group['value']) && is_array($group['value'])): ?>
|
||||
<optgroup label="<?= $block->escapeHtmlAttr((string)$group['label']) ?>">
|
||||
<?php foreach ($group['value'] as $store): ?>
|
||||
<option value="<?= (int)$store['value'] ?>" <?= in_array((int)$store['value'], $selectedStores, true) ? 'selected' : '' ?>>
|
||||
<?= $block->escapeHtml((string)$store['label']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php else: ?>
|
||||
<option value="<?= (int)$group['value'] ?>" <?= in_array((int)$group['value'], $selectedStores, true) ? 'selected' : '' ?>>
|
||||
<?= $block->escapeHtml((string)$group['label']) ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Content')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<?= /* @noEscape */ $block->getContentEditorHtml() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Status')) ?></span></label>
|
||||
<div class="admin__field-control"><select class="admin__control-select" name="status">
|
||||
<option value="1" <?= !$faq->getId() || (int)$faq->getData('status') === 1 ? 'selected' : '' ?>><?= $block->escapeHtml(__('Enabled')) ?></option>
|
||||
<option value="0" <?= $faq->getId() && (int)$faq->getData('status') === 0 ? 'selected' : '' ?>><?= $block->escapeHtml(__('Disabled')) ?></option>
|
||||
</select></div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Sort Order')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<input class="admin__control-text" type="number" name="sort_order"
|
||||
value="<?= (int)$faq->getData('sort_order') ?>">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\Faq\ListBlock $block */
|
||||
?>
|
||||
<div class="page-main-actions">
|
||||
<div class="page-actions">
|
||||
<a class="action-primary" href="<?= $block->escapeUrl($block->getNewUrl()) ?>">
|
||||
<span><?= $block->escapeHtml(__('Add FAQ')) ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<table class="data-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('ID')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Title')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Stores')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Status')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Sort Order')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Actions')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($block->getFaqs() as $faq): ?>
|
||||
<tr>
|
||||
<td><?= (int)$faq->getId() ?></td>
|
||||
<td><?= $block->escapeHtml((string)$faq->getData('title')) ?></td>
|
||||
<td><?= $block->escapeHtml((string)$faq->getData('store_ids')) ?></td>
|
||||
<td><?= $block->escapeHtml((int)$faq->getData('status') ? __('Enabled') : __('Disabled')) ?></td>
|
||||
<td><?= (int)$faq->getData('sort_order') ?></td>
|
||||
<td>
|
||||
<a href="<?= $block->escapeUrl($block->getEditUrl((int)$faq->getId())) ?>"><?= $block->escapeHtml(__('Edit')) ?></a>
|
||||
|
|
||||
<a href="<?= $block->escapeUrl($block->getDeleteUrl((int)$faq->getId())) ?>"
|
||||
onclick="return confirm('<?= $block->escapeJs(__('Delete this FAQ?')) ?>')">
|
||||
<?= $block->escapeHtml(__('Delete')) ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \Esun\Catalog\Block\Adminhtml\MixStepPricing\Form $block
|
||||
* @var \Magento\Framework\Escaper $escaper
|
||||
*/
|
||||
$state = $block->getValidationState();
|
||||
$stats = (array)($state['stats'] ?? []);
|
||||
$preview = (array)($state['preview'] ?? []);
|
||||
$invalidPreview = (array)($state['invalid_preview'] ?? []);
|
||||
$isDelete = $block->isDelete();
|
||||
?>
|
||||
<div class="admin__fieldset-wrapper">
|
||||
<div class="admin__fieldset-wrapper-title">
|
||||
<strong class="title">
|
||||
<span><?= $escaper->escapeHtml($isDelete ? __('Batch Delete') : __('Batch Import')) ?></span>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="admin__fieldset-wrapper-content">
|
||||
<fieldset class="admin__fieldset">
|
||||
<div class="admin__field">
|
||||
<div class="admin__field-control">
|
||||
<p>
|
||||
<?php if ($isDelete): ?>
|
||||
<?= $escaper->escapeHtml(__('Deletes all Mix Step Pricing for each sku + website across every Store View.')) ?>
|
||||
<?php else: ?>
|
||||
<?= $escaper->escapeHtml(__('Replaces the complete Mix Step Pricing tier set for each sku + website across every Store View.')) ?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<p>
|
||||
<a class="action-secondary" href="<?= $escaper->escapeUrl($block->getTemplateUrl()) ?>">
|
||||
<span><?= $escaper->escapeHtml(__('Download Excel Template')) ?></span>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action="<?= $escaper->escapeUrl($block->getValidateUrl()) ?>" method="post" enctype="multipart/form-data">
|
||||
<input name="form_key" type="hidden" value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>"/>
|
||||
<div class="admin__field required">
|
||||
<label class="admin__field-label" for="mix-step-pricing-file">
|
||||
<span><?= $escaper->escapeHtml(__('Excel File')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="mix-step-pricing-file" class="admin__control-file" type="file"
|
||||
name="excel_file" accept=".xlsx,.xls" required/>
|
||||
<div class="note"><?= $escaper->escapeHtml(__('The file is validated before any data is changed.')) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__actions">
|
||||
<button class="action-primary" type="submit">
|
||||
<span><?= $escaper->escapeHtml(__('Validate File')) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($state): ?>
|
||||
<div class="admin__fieldset-wrapper">
|
||||
<div class="admin__fieldset-wrapper-title">
|
||||
<strong class="title"><span><?= $escaper->escapeHtml(__('Validation Preview')) ?></span></strong>
|
||||
</div>
|
||||
<div class="admin__fieldset-wrapper-content">
|
||||
<fieldset class="admin__fieldset">
|
||||
<p>
|
||||
<?= $escaper->escapeHtml(__(
|
||||
'%1 valid data rows; %2 sku + website groups; %3 Store View writes.',
|
||||
(int)($stats['valid_rows'] ?? 0),
|
||||
(int)($stats['groups'] ?? 0),
|
||||
(int)($stats['store_view_writes'] ?? 0)
|
||||
)) ?>
|
||||
</p>
|
||||
<?php if ($preview): ?>
|
||||
<div class="admin__data-grid-wrap">
|
||||
<table class="data-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Excel Row')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('SKU')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Website')) ?></th>
|
||||
<?php if (!$isDelete): ?>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Combined Qty From')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Pricing Method')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Discount % / Unit Price')) ?></th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($preview as $item): ?>
|
||||
<tr class="data-row">
|
||||
<td><?= $escaper->escapeHtml((string)($item['row'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['sku'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['website'] ?? '')) ?></td>
|
||||
<?php if (!$isDelete): ?>
|
||||
<td><?= $escaper->escapeHtml((string)($item['combined_qty_from'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['pricing_method'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['value'] ?? '')) ?></td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($state['preview_truncated'])): ?>
|
||||
<p class="note"><?= $escaper->escapeHtml(__('Preview is limited to the first 100 valid rows.')) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($invalidPreview): ?>
|
||||
<div class="mix-step-pricing-invalid-data">
|
||||
<h3><?= $escaper->escapeHtml(__('Invalid Data')) ?></h3>
|
||||
<p>
|
||||
<?= $escaper->escapeHtml(__('%1 invalid rows.', (int)($stats['invalid_rows'] ?? 0))) ?>
|
||||
</p>
|
||||
<div class="admin__data-grid-wrap">
|
||||
<table class="data-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Excel Row')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('SKU')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Website')) ?></th>
|
||||
<?php if (!$isDelete): ?>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Combined Qty From')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Pricing Method')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Discount % / Unit Price')) ?></th>
|
||||
<?php endif; ?>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Reason')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($invalidPreview as $item): ?>
|
||||
<tr class="data-row">
|
||||
<td><?= $escaper->escapeHtml((string)($item['row'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['sku'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['website'] ?? '')) ?></td>
|
||||
<?php if (!$isDelete): ?>
|
||||
<td><?= $escaper->escapeHtml((string)($item['combined_qty_from'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['pricing_method'] ?? '')) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)($item['value'] ?? '')) ?></td>
|
||||
<?php endif; ?>
|
||||
<td><?= $escaper->escapeHtml((string)($item['reason'] ?? '')) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php if (!empty($state['invalid_preview_truncated'])): ?>
|
||||
<p class="note">
|
||||
<?= $escaper->escapeHtml(__('Invalid data is limited to the first 100 rows.')) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($state['valid'])): ?>
|
||||
<form action="<?= $escaper->escapeUrl($block->getRunUrl()) ?>" method="post">
|
||||
<input name="form_key" type="hidden" value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>"/>
|
||||
<?php if ($isDelete): ?>
|
||||
<div class="admin__field required">
|
||||
<div class="admin__field-control">
|
||||
<input id="confirm-delete-all-tiers" type="checkbox" name="confirm_delete" value="1" required/>
|
||||
<label for="confirm-delete-all-tiers">
|
||||
<?= $escaper->escapeHtml(__('I understand this permanently deletes all tiers for every listed sku + website.')) ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<button class="<?= $isDelete ? 'action-delete' : 'action-primary' ?>" type="submit">
|
||||
<span><?= $escaper->escapeHtml($isDelete ? __('Delete Validated Prices') : __('Import Validated Prices')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \Esun\Catalog\Block\Adminhtml\ProductRecommendation\ImportForm $block
|
||||
* @var \Magento\Framework\Escaper $escaper
|
||||
*/
|
||||
$state = $block->getValidationState();
|
||||
$stats = (array)($state['stats'] ?? []);
|
||||
$preview = (array)($state['preview'] ?? []);
|
||||
?>
|
||||
<div class="admin__fieldset-wrapper">
|
||||
<div class="admin__fieldset-wrapper-title">
|
||||
<strong class="title"><span><?= $escaper->escapeHtml(__('Excel Import')) ?></span></strong>
|
||||
</div>
|
||||
<div class="admin__fieldset-wrapper-content">
|
||||
<fieldset class="admin__fieldset">
|
||||
<p><?= $escaper->escapeHtml(__('Each source SKU + website group completely replaces its existing recommendation set. Partial changes must be made on the product edit page.')) ?></p>
|
||||
<p><a class="action-secondary" href="<?= $escaper->escapeUrl($block->getTemplateUrl()) ?>">
|
||||
<span><?= $escaper->escapeHtml(__('Download Excel Template')) ?></span>
|
||||
</a></p>
|
||||
<form action="<?= $escaper->escapeUrl($block->getValidateUrl()) ?>" method="post" enctype="multipart/form-data">
|
||||
<input name="form_key" type="hidden" value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>"/>
|
||||
<div class="admin__field required">
|
||||
<label class="admin__field-label" for="product-recommendation-file">
|
||||
<span><?= $escaper->escapeHtml(__('Excel File')) ?></span>
|
||||
</label>
|
||||
<div class="admin__field-control">
|
||||
<input id="product-recommendation-file" class="admin__control-file" type="file"
|
||||
name="excel_file" accept=".xlsx,.xls" required/>
|
||||
<div class="note"><?= $escaper->escapeHtml(__('The file is validated before any data is changed.')) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="action-primary" type="submit"><span><?= $escaper->escapeHtml(__('Validate File')) ?></span></button>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($state): ?>
|
||||
<div class="admin__fieldset-wrapper">
|
||||
<div class="admin__fieldset-wrapper-title">
|
||||
<strong class="title"><span><?= $escaper->escapeHtml(__('Replacement Preview')) ?></span></strong>
|
||||
</div>
|
||||
<div class="admin__fieldset-wrapper-content">
|
||||
<fieldset class="admin__fieldset">
|
||||
<p><?= $escaper->escapeHtml(__(
|
||||
'%1 rows define %2 product + website sets containing %3 recommendations.',
|
||||
(int)($stats['rows'] ?? 0),
|
||||
(int)($stats['groups'] ?? 0),
|
||||
(int)($stats['recommendations'] ?? 0)
|
||||
)) ?></p>
|
||||
<?php if ($preview): ?>
|
||||
<div class="admin__data-grid-wrap"><table class="data-grid">
|
||||
<thead><tr>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Source SKU')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Website')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Recommended SKUs (display order)')) ?></th>
|
||||
<th class="data-grid-th"><?= $escaper->escapeHtml(__('Count')) ?></th>
|
||||
</tr></thead>
|
||||
<tbody><?php foreach ($preview as $item): ?><tr class="data-row">
|
||||
<td><?= $escaper->escapeHtml((string)$item['source_sku']) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)$item['website']) ?></td>
|
||||
<td><?= $escaper->escapeHtml((string)$item['recommended_skus']) ?></td>
|
||||
<td><?= (int)$item['count'] ?></td>
|
||||
</tr><?php endforeach; ?></tbody>
|
||||
</table></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($state['preview_truncated'])): ?>
|
||||
<p class="note"><?= $escaper->escapeHtml(__('Preview is limited to the first 100 groups.')) ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($state['valid'])): ?>
|
||||
<form action="<?= $escaper->escapeUrl($block->getRunUrl()) ?>" method="post">
|
||||
<input name="form_key" type="hidden" value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>"/>
|
||||
<button class="action-primary" type="submit">
|
||||
<span><?= $escaper->escapeHtml(__('Import and Replace Recommendations')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\SpecificationBrand\EditBlock $block */
|
||||
$brand = $block->getBrand();
|
||||
$logo = (string)$brand->getData('brand_logo');
|
||||
?>
|
||||
<form method="post" action="<?= $block->escapeUrl($block->getSaveUrl()) ?>" enctype="multipart/form-data">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="brand_id" value="<?= (int)$brand->getId() ?>">
|
||||
<div class="page-main-actions"><div class="page-actions">
|
||||
<a class="action-secondary" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
|
||||
<span><?= $block->escapeHtml(__('Back')) ?></span>
|
||||
</a>
|
||||
<button class="action-primary" type="submit"><span><?= $block->escapeHtml(__('Save Brand')) ?></span></button>
|
||||
</div></div>
|
||||
<fieldset class="admin__fieldset">
|
||||
<div class="admin__field _required">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Brand Name')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<input class="admin__control-text" type="text" name="brand_name" required
|
||||
value="<?= $block->escapeHtmlAttr((string)$brand->getData('brand_name')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Brand Logo')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<?php if ($logo !== ''): ?>
|
||||
<div style="margin-bottom:1.5rem">
|
||||
<img src="<?= $block->escapeUrl($block->getMediaUrl($logo)) ?>"
|
||||
alt=""
|
||||
style="display:block;max-width:16rem;max-height:8rem;margin-bottom:1rem;border:1px solid #d6d6d6;background:#fff;padding:.5rem">
|
||||
<label>
|
||||
<input type="checkbox" name="delete_logo" value="1">
|
||||
<?= $block->escapeHtml(__('Delete current logo')) ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="brand_logo" accept="image/jpeg,image/png,image/gif,image/webp,image/svg+xml">
|
||||
<p class="note"><?= $block->escapeHtml(__('Allowed: JPG, PNG, GIF, WebP and SVG.')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Product Specific')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<select class="admin__control-select" name="is_product_specific">
|
||||
<option value="1" <?= (int)$brand->getData('is_product_specific') !== 0 ? 'selected' : '' ?>>
|
||||
<?= $block->escapeHtml(__('Yes - match files by product name')) ?>
|
||||
</option>
|
||||
<option value="0" <?= (int)$brand->getData('is_product_specific') === 0 ? 'selected' : '' ?>>
|
||||
<?= $block->escapeHtml(__('No - files are common for all products')) ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Status')) ?></span></label>
|
||||
<div class="admin__field-control"><select class="admin__control-select" name="status">
|
||||
<option value="1" <?= !$brand->getId() || (int)$brand->getData('status') === 1 ? 'selected' : '' ?>><?= $block->escapeHtml(__('Enabled')) ?></option>
|
||||
<option value="0" <?= $brand->getId() && (int)$brand->getData('status') === 0 ? 'selected' : '' ?>><?= $block->escapeHtml(__('Disabled')) ?></option>
|
||||
</select></div>
|
||||
</div>
|
||||
<div class="admin__field">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Sort Order')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<input class="admin__control-text" type="number" name="sort_order"
|
||||
value="<?= (int)$brand->getData('sort_order') ?>">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Adminhtml\SpecificationImport\EditBlock $block */
|
||||
$import = $block->getImport();
|
||||
?>
|
||||
<form method="post" action="<?= $block->escapeUrl($block->getSaveUrl()) ?>" enctype="multipart/form-data">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="import_id" value="<?= (int)$import->getId() ?>">
|
||||
<div class="page-main-actions"><div class="page-actions">
|
||||
<a class="action-secondary" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
|
||||
<span><?= $block->escapeHtml(__('Back')) ?></span>
|
||||
</a>
|
||||
<button class="action-primary" type="submit"><span><?= $block->escapeHtml(__('Save and Import ZIP')) ?></span></button>
|
||||
</div></div>
|
||||
<fieldset class="admin__fieldset">
|
||||
<div class="admin__field _required">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Brand')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<select class="admin__control-select" name="brand_id" required>
|
||||
<option value=""><?= $block->escapeHtml(__('Please select')) ?></option>
|
||||
<?php foreach ($block->getBrands() as $brand): ?>
|
||||
<option value="<?= (int)$brand->getId() ?>"
|
||||
<?= (int)$import->getData('brand_id') === (int)$brand->getId() ? 'selected' : '' ?>>
|
||||
<?= $block->escapeHtml((string)$brand->getData('brand_name')) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<p class="note">
|
||||
<a href="<?= $block->escapeUrl($block->getBrandUrl()) ?>" target="_blank" rel="noopener">
|
||||
<?= $block->escapeHtml(__('Create a new brand')) ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin__field <?= $import->getId() ? '' : '_required' ?>">
|
||||
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Specifications ZIP')) ?></span></label>
|
||||
<div class="admin__field-control">
|
||||
<?php if ((string)$import->getData('archive_file') !== ''): ?>
|
||||
<p>
|
||||
<a href="<?= $block->escapeUrl($block->getMediaUrl((string)$import->getData('archive_file'))) ?>"
|
||||
target="_blank"
|
||||
rel="noopener">
|
||||
<?= $block->escapeHtml(basename((string)$import->getData('archive_file'))) ?>
|
||||
</a>
|
||||
</p>
|
||||
<p class="note"><?= $block->escapeHtml(__('Uploading a new ZIP replaces all existing parsed files for this brand.')) ?></p>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="archive_file" accept=".zip" <?= $import->getId() ? '' : 'required' ?>>
|
||||
<p class="note"><?= $block->escapeHtml(__('Only ZIP files are supported. The ZIP should contain Brand / Model / specification files.')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">esun_specification_brand_listing.esun_specification_brand_listing_data_source</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<buttons>
|
||||
<button name="add">
|
||||
<url path="esun_catalog/specificationbrand/new"/>
|
||||
<class>primary</class>
|
||||
<label translate="true">Add Brand</label>
|
||||
</button>
|
||||
</buttons>
|
||||
<spinner>esun_specification_brand_columns</spinner>
|
||||
<deps>
|
||||
<dep>esun_specification_brand_listing.esun_specification_brand_listing_data_source</dep>
|
||||
</deps>
|
||||
</settings>
|
||||
<dataSource name="esun_specification_brand_listing_data_source" component="Magento_Ui/js/grid/provider">
|
||||
<settings>
|
||||
<storageConfig>
|
||||
<param name="indexField" xsi:type="string">brand_id</param>
|
||||
</storageConfig>
|
||||
<updateUrl path="mui/index/render"/>
|
||||
</settings>
|
||||
<aclResource>Esun_Catalog::specification_brands</aclResource>
|
||||
<dataProvider class="Esun\Catalog\Ui\DataProvider\SpecificationBrand\ListingDataProvider"
|
||||
name="esun_specification_brand_listing_data_source">
|
||||
<settings>
|
||||
<requestFieldName>id</requestFieldName>
|
||||
<primaryFieldName>brand_id</primaryFieldName>
|
||||
</settings>
|
||||
</dataProvider>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings>
|
||||
<sticky>true</sticky>
|
||||
</settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<filterSearch name="fulltext"/>
|
||||
<filters name="listing_filters"/>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="esun_specification_brand_columns">
|
||||
<column name="brand_id">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<sorting>desc</sorting>
|
||||
<label translate="true">ID</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="logo"
|
||||
class="Esun\Catalog\Ui\Component\Listing\Column\SpecificationBrandLogo"
|
||||
component="Magento_Ui/js/grid/columns/thumbnail">
|
||||
<settings>
|
||||
<altField>brand_name</altField>
|
||||
<hasPreview>1</hasPreview>
|
||||
<label translate="true">Logo</label>
|
||||
<sortable>false</sortable>
|
||||
<filter>false</filter>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="brand_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Brand Name</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="is_product_specific" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Source\BooleanOptions"/>
|
||||
<filter>select</filter>
|
||||
<dataType>select</dataType>
|
||||
<label translate="true">Product Specific</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="status" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Source\BooleanOptions"/>
|
||||
<filter>select</filter>
|
||||
<dataType>select</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="sort_order">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Sort Order</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="updated_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">
|
||||
<settings>
|
||||
<filter>dateRange</filter>
|
||||
<dataType>date</dataType>
|
||||
<label translate="true">Updated</label>
|
||||
</settings>
|
||||
</column>
|
||||
<actionsColumn name="actions" class="Esun\Catalog\Ui\Component\Listing\Column\SpecificationBrandActions">
|
||||
<settings>
|
||||
<indexField>brand_id</indexField>
|
||||
<resizeEnabled>false</resizeEnabled>
|
||||
<resizeDefaultWidth>110</resizeDefaultWidth>
|
||||
</settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">esun_specification_import_listing.esun_specification_import_listing_data_source</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<buttons>
|
||||
<button name="add">
|
||||
<url path="esun_catalog/specificationimport/new"/>
|
||||
<class>primary</class>
|
||||
<label translate="true">Upload ZIP</label>
|
||||
</button>
|
||||
</buttons>
|
||||
<spinner>esun_specification_import_columns</spinner>
|
||||
<deps>
|
||||
<dep>esun_specification_import_listing.esun_specification_import_listing_data_source</dep>
|
||||
</deps>
|
||||
</settings>
|
||||
<dataSource name="esun_specification_import_listing_data_source" component="Magento_Ui/js/grid/provider">
|
||||
<settings>
|
||||
<storageConfig>
|
||||
<param name="indexField" xsi:type="string">file_id</param>
|
||||
</storageConfig>
|
||||
<updateUrl path="mui/index/render"/>
|
||||
</settings>
|
||||
<aclResource>Esun_Catalog::specification_imports</aclResource>
|
||||
<dataProvider class="Esun\Catalog\Ui\DataProvider\SpecificationFile\ListingDataProvider"
|
||||
name="esun_specification_import_listing_data_source">
|
||||
<settings>
|
||||
<requestFieldName>id</requestFieldName>
|
||||
<primaryFieldName>file_id</primaryFieldName>
|
||||
</settings>
|
||||
</dataProvider>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings>
|
||||
<sticky>true</sticky>
|
||||
</settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<filterSearch name="fulltext"/>
|
||||
<filters name="listing_filters"/>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="esun_specification_import_columns">
|
||||
<column name="file_id">
|
||||
<settings>
|
||||
<filter>textRange</filter>
|
||||
<sorting>desc</sorting>
|
||||
<label translate="true">ID</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="brand_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Brand</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="model_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Model</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="file_name">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">File Name</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="is_product_specific" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Source\BooleanOptions"/>
|
||||
<filter>select</filter>
|
||||
<dataType>select</dataType>
|
||||
<label translate="true">Product Specific</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">
|
||||
<settings>
|
||||
<filter>dateRange</filter>
|
||||
<dataType>date</dataType>
|
||||
<label translate="true">Created</label>
|
||||
</settings>
|
||||
</column>
|
||||
<actionsColumn name="actions" class="Esun\Catalog\Ui\Component\Listing\Column\SpecificationImportActions">
|
||||
<settings>
|
||||
<indexField>file_id</indexField>
|
||||
<resizeEnabled>false</resizeEnabled>
|
||||
<resizeDefaultWidth>110</resizeDefaultWidth>
|
||||
</settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
@@ -0,0 +1,593 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<settings>
|
||||
<buttons>
|
||||
<button name="preview" class="Esun\Catalog\Block\Adminhtml\Product\Edit\Button\Preview"/>
|
||||
</buttons>
|
||||
</settings>
|
||||
|
||||
<fieldset name="esun_product_detail_content" sortOrder="95">
|
||||
<settings>
|
||||
<label translate="true">Product Detail Content</label>
|
||||
<collapsible>true</collapsible>
|
||||
<opened>false</opened>
|
||||
<dataScope>data.product</dataScope>
|
||||
</settings>
|
||||
|
||||
<dynamicRows name="esun_industry_applications" component="Magento_Ui/js/dynamic-rows/dynamic-rows" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<additionalClasses>
|
||||
<class name="admin__field-wide">true</class>
|
||||
</additionalClasses>
|
||||
<label translate="true">Industry Applications</label>
|
||||
<addButtonLabel translate="true">Add Application</addButtonLabel>
|
||||
<dndConfig>
|
||||
<param name="enabled" xsi:type="boolean">true</param>
|
||||
</dndConfig>
|
||||
<componentType>dynamicRows</componentType>
|
||||
</settings>
|
||||
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="isTemplate" xsi:type="boolean">true</item>
|
||||
<item name="is_collection" xsi:type="boolean">true</item>
|
||||
<item name="componentType" xsi:type="string">container</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="enabled" formElement="checkbox" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">1</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="number">0</map>
|
||||
<map name="true" xsi:type="number">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="position" formElement="input" sortOrder="20">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Sort Order</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="label" formElement="input" sortOrder="30">
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Label</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="icon" formElement="imageUploader" sortOrder="40">
|
||||
<settings>
|
||||
<elementTmpl>ui/form/element/uploader/image</elementTmpl>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Icon</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<imageUploader>
|
||||
<settings>
|
||||
<uploaderConfig>
|
||||
<param xsi:type="url" name="url" path="esun_catalog/product_image/upload"/>
|
||||
</uploaderConfig>
|
||||
<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
|
||||
<openDialogTitle>Media Gallery</openDialogTitle>
|
||||
<allowedExtensions>jpg jpeg gif png webp</allowedExtensions>
|
||||
<maxFileSize>4194304</maxFileSize>
|
||||
</settings>
|
||||
</imageUploader>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="image" formElement="imageUploader" sortOrder="50">
|
||||
<settings>
|
||||
<elementTmpl>ui/form/element/uploader/image</elementTmpl>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Large Image</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<imageUploader>
|
||||
<settings>
|
||||
<uploaderConfig>
|
||||
<param xsi:type="url" name="url" path="esun_catalog/product_image/upload"/>
|
||||
</uploaderConfig>
|
||||
<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
|
||||
<openDialogTitle>Media Gallery</openDialogTitle>
|
||||
<allowedExtensions>jpg jpeg gif png webp</allowedExtensions>
|
||||
<maxFileSize>8388608</maxFileSize>
|
||||
</settings>
|
||||
</imageUploader>
|
||||
</formElements>
|
||||
</field>
|
||||
<actionDelete name="action_delete" sortOrder="90">
|
||||
<settings>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</actionDelete>
|
||||
</container>
|
||||
</dynamicRows>
|
||||
|
||||
<dynamicRows name="esun_detail_gallery" component="Magento_Ui/js/dynamic-rows/dynamic-rows" sortOrder="20">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<additionalClasses>
|
||||
<class name="admin__field-wide">true</class>
|
||||
</additionalClasses>
|
||||
<label translate="true">Detail Gallery</label>
|
||||
<notice translate="true">Upload images for the Gallery section. Images are stored under media/esun/catalog/product-detail.</notice>
|
||||
<addButtonLabel translate="true">Add Gallery Image</addButtonLabel>
|
||||
<componentType>dynamicRows</componentType>
|
||||
</settings>
|
||||
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="isTemplate" xsi:type="boolean">true</item>
|
||||
<item name="is_collection" xsi:type="boolean">true</item>
|
||||
<item name="componentType" xsi:type="string">container</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="enabled" formElement="checkbox" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">1</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="number">0</map>
|
||||
<map name="true" xsi:type="number">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="position" formElement="input" sortOrder="20">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Sort Order</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="label" formElement="input" sortOrder="30">
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Alt Text</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="image" formElement="imageUploader" sortOrder="40">
|
||||
<settings>
|
||||
<elementTmpl>ui/form/element/uploader/image</elementTmpl>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Image</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<imageUploader>
|
||||
<settings>
|
||||
<uploaderConfig>
|
||||
<param xsi:type="url" name="url" path="esun_catalog/product_image/upload"/>
|
||||
</uploaderConfig>
|
||||
<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
|
||||
<openDialogTitle>Media Gallery</openDialogTitle>
|
||||
<allowedExtensions>jpg jpeg gif png webp</allowedExtensions>
|
||||
<maxFileSize>8388608</maxFileSize>
|
||||
</settings>
|
||||
</imageUploader>
|
||||
</formElements>
|
||||
</field>
|
||||
<actionDelete name="action_delete" sortOrder="90">
|
||||
<settings>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</actionDelete>
|
||||
</container>
|
||||
</dynamicRows>
|
||||
|
||||
<dynamicRows name="esun_creative_video_ids" component="Magento_Ui/js/dynamic-rows/dynamic-rows" sortOrder="30">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<additionalClasses>
|
||||
<class name="admin__field-wide">true</class>
|
||||
</additionalClasses>
|
||||
<label translate="true">Creative Videos</label>
|
||||
<notice translate="true">Select enabled videos from Esun Video Management. Cover images are loaded automatically from the video record.</notice>
|
||||
<addButtonLabel translate="true">Add Video</addButtonLabel>
|
||||
<componentType>dynamicRows</componentType>
|
||||
</settings>
|
||||
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="isTemplate" xsi:type="boolean">true</item>
|
||||
<item name="is_collection" xsi:type="boolean">true</item>
|
||||
<item name="componentType" xsi:type="string">container</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="enabled" formElement="checkbox" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">1</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="number">0</map>
|
||||
<map name="true" xsi:type="number">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="position" formElement="input" sortOrder="20">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Sort Order</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="video_id" formElement="select" sortOrder="30">
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Video</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<select>
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Config\Source\VideoOptions"/>
|
||||
</settings>
|
||||
</select>
|
||||
</formElements>
|
||||
</field>
|
||||
<actionDelete name="action_delete" sortOrder="90">
|
||||
<settings>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</actionDelete>
|
||||
</container>
|
||||
</dynamicRows>
|
||||
|
||||
<dynamicRows name="esun_certification_downloads" component="Magento_Ui/js/dynamic-rows/dynamic-rows" sortOrder="40">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<additionalClasses>
|
||||
<class name="admin__field-wide">true</class>
|
||||
</additionalClasses>
|
||||
<label translate="true">Certification Download</label>
|
||||
<notice translate="true">Upload PDF, Word (DOC/DOCX), ZIP, RAR, or 7Z certification files for the Download section.</notice>
|
||||
<addButtonLabel translate="true">Add Certification</addButtonLabel>
|
||||
<componentType>dynamicRows</componentType>
|
||||
</settings>
|
||||
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="isTemplate" xsi:type="boolean">true</item>
|
||||
<item name="is_collection" xsi:type="boolean">true</item>
|
||||
<item name="componentType" xsi:type="string">container</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="enabled" formElement="checkbox" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">1</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="number">0</map>
|
||||
<map name="true" xsi:type="number">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="position" formElement="input" sortOrder="20">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Sort Order</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="type_id" formElement="select" sortOrder="30">
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Certification Type</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<select>
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Config\Source\CertificationTypeOptions"/>
|
||||
</settings>
|
||||
</select>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="file" formElement="fileUploader" sortOrder="40">
|
||||
<settings>
|
||||
<elementTmpl>ui/form/element/uploader/uploader</elementTmpl>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Certification File</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<fileUploader>
|
||||
<settings>
|
||||
<uploaderConfig>
|
||||
<param xsi:type="url" name="url" path="esun_catalog/product_certification/upload"/>
|
||||
</uploaderConfig>
|
||||
<allowedExtensions>pdf doc docx zip rar 7z</allowedExtensions>
|
||||
<maxFileSize>52428800</maxFileSize>
|
||||
<isMultipleFiles>false</isMultipleFiles>
|
||||
</settings>
|
||||
</fileUploader>
|
||||
</formElements>
|
||||
</field>
|
||||
<actionDelete name="action_delete" sortOrder="90">
|
||||
<settings>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</actionDelete>
|
||||
</container>
|
||||
</dynamicRows>
|
||||
|
||||
<dynamicRows name="esun_product_faqs" component="Magento_Ui/js/dynamic-rows/dynamic-rows" sortOrder="50">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<additionalClasses>
|
||||
<class name="admin__field-wide">true</class>
|
||||
</additionalClasses>
|
||||
<label translate="true">Product FAQs</label>
|
||||
<notice translate="true">These FAQs are merged with public Product FAQ records.</notice>
|
||||
<addButtonLabel translate="true">Add FAQ</addButtonLabel>
|
||||
<componentType>dynamicRows</componentType>
|
||||
</settings>
|
||||
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="isTemplate" xsi:type="boolean">true</item>
|
||||
<item name="is_collection" xsi:type="boolean">true</item>
|
||||
<item name="componentType" xsi:type="string">container</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="enabled" formElement="checkbox" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">1</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="number">0</map>
|
||||
<map name="true" xsi:type="number">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="position" formElement="input" sortOrder="20">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Sort Order</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="title" formElement="input" sortOrder="30">
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Question</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="content" template="ui/form/field" formElement="wysiwyg" sortOrder="40">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="wysiwygConfigData" xsi:type="array">
|
||||
<item name="is_pagebuilder_enabled" xsi:type="boolean">true</item>
|
||||
<item name="pagebuilder_button" xsi:type="boolean">true</item>
|
||||
<item name="add_variables" xsi:type="boolean">false</item>
|
||||
<item name="add_widgets" xsi:type="boolean">true</item>
|
||||
<item name="add_images" xsi:type="boolean">true</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Answer</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<wysiwyg>
|
||||
<settings>
|
||||
<wysiwyg>true</wysiwyg>
|
||||
</settings>
|
||||
</wysiwyg>
|
||||
</formElements>
|
||||
</field>
|
||||
<actionDelete name="action_delete" sortOrder="90">
|
||||
<settings>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</actionDelete>
|
||||
</container>
|
||||
</dynamicRows>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="esun_mix_step_pricing" sortOrder="94">
|
||||
<settings>
|
||||
<label translate="true">Mix Step Pricing</label>
|
||||
<collapsible>true</collapsible>
|
||||
<opened>false</opened>
|
||||
<dataScope>data.product</dataScope>
|
||||
</settings>
|
||||
|
||||
<dynamicRows name="esun_mix_step_prices" component="Magento_Ui/js/dynamic-rows/dynamic-rows" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<additionalClasses>
|
||||
<class name="admin__field-wide">true</class>
|
||||
</additionalClasses>
|
||||
<label translate="true">Parent-level Mix Tiers</label>
|
||||
<notice translate="true">Percentage discounts preserve price differences between variants. Fixed unit prices make every eligible variant use the same price.</notice>
|
||||
<addButtonLabel translate="true">Add Mix Tier</addButtonLabel>
|
||||
<componentType>dynamicRows</componentType>
|
||||
</settings>
|
||||
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="isTemplate" xsi:type="boolean">true</item>
|
||||
<item name="is_collection" xsi:type="boolean">true</item>
|
||||
<item name="componentType" xsi:type="string">container</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="enabled" formElement="checkbox" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">1</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enabled</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="number">0</map>
|
||||
<map name="true" xsi:type="number">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="customer_group_id" formElement="select" sortOrder="20">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Customer Group</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<select>
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Config\Source\MixCustomerGroupOptions"/>
|
||||
</settings>
|
||||
</select>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="qty" formElement="input" sortOrder="30">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Combined Qty From</label>
|
||||
<validation>
|
||||
<rule name="required-entry" xsi:type="boolean">true</rule>
|
||||
<rule name="validate-digits" xsi:type="boolean">true</rule>
|
||||
<rule name="validate-greater-than-zero" xsi:type="boolean">true</rule>
|
||||
</validation>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="price_type" formElement="select" sortOrder="40">
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Pricing Method</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<select>
|
||||
<settings>
|
||||
<options class="Esun\Catalog\Model\Config\Source\MixPriceTypeOptions"/>
|
||||
</settings>
|
||||
</select>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="value" formElement="input" sortOrder="50">
|
||||
<settings>
|
||||
<dataType>number</dataType>
|
||||
<label translate="true">Discount % / Unit Price</label>
|
||||
<validation>
|
||||
<rule name="required-entry" xsi:type="boolean">true</rule>
|
||||
<rule name="validate-number" xsi:type="boolean">true</rule>
|
||||
<rule name="validate-greater-than-zero" xsi:type="boolean">true</rule>
|
||||
</validation>
|
||||
</settings>
|
||||
</field>
|
||||
<actionDelete name="action_delete" sortOrder="90">
|
||||
<settings>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</actionDelete>
|
||||
</container>
|
||||
</dynamicRows>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="esun_product_recommendations" sortOrder="96">
|
||||
<settings>
|
||||
<label translate="true">Recommended Products</label>
|
||||
<collapsible>true</collapsible>
|
||||
<opened>false</opened>
|
||||
<dataScope>data.product</dataScope>
|
||||
</settings>
|
||||
<field name="esun_recommendations" formElement="textarea" sortOrder="10">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="source" xsi:type="string">product</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>text</dataType>
|
||||
<label translate="true">Recommended Products</label>
|
||||
<notice translate="true">Enter one SKU per line, or separate SKUs with commas. The order is the display order. All Store Views sets the default; store view changes apply to the entire website. An empty custom list shows no recommendations.</notice>
|
||||
</settings>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,24 @@
|
||||
.mix-step-pricing-invalid-data {
|
||||
border: 1px solid #e22626;
|
||||
margin-top: 2rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.mix-step-pricing-invalid-data h3,
|
||||
.mix-step-pricing-invalid-data > p {
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.mix-step-pricing-invalid-data .data-grid-th {
|
||||
background: #b71c1c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.mix-step-pricing-invalid-data .data-row td {
|
||||
background: #fff5f5;
|
||||
}
|
||||
|
||||
.mix-step-pricing-invalid-data .data-row td:last-child {
|
||||
color: #c62828;
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function () {
|
||||
function readFile($input, file) {
|
||||
var reader = new FileReader(),
|
||||
$row = $input.closest('tr'),
|
||||
$preview = $row.find('[data-role="esun-ball-preview"]'),
|
||||
$image = $row.find('[data-role="esun-ball-preview-image"]');
|
||||
|
||||
reader.onload = function (event) {
|
||||
$row.find('[data-role="esun-ball-image-base64"]').val(String(event.target.result || ''));
|
||||
$row.find('[data-role="esun-ball-image-name"]').val(file.name || 'color-ball.png');
|
||||
$row.find('[data-role="esun-delete-ball-image"]').val('');
|
||||
$image.attr('src', String(event.target.result || ''));
|
||||
$preview.show();
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
$(document).on('change', '.esun-color-ball-input', function () {
|
||||
var file = this.files && this.files.length ? this.files[0] : null;
|
||||
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
readFile($(this), file);
|
||||
});
|
||||
|
||||
$(document).on('click', '.esun-color-ball-remove', function () {
|
||||
var $row = $(this).closest('tr');
|
||||
|
||||
$row.find('[data-role="esun-ball-image-existing"]').val('');
|
||||
$row.find('[data-role="esun-ball-image-base64"]').val('');
|
||||
$row.find('[data-role="esun-ball-image-name"]').val('');
|
||||
$row.find('[data-role="esun-delete-ball-image"]').val('1');
|
||||
$row.find('.esun-color-ball-input').val('');
|
||||
$row.find('[data-role="esun-ball-preview-image"]').attr('src', '');
|
||||
$row.find('[data-role="esun-ball-preview"]').hide();
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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_Customer::css/iconfont.css"/>
|
||||
<css src="Esun_Catalog::css/product-wishlist.css"/>
|
||||
<css src="Esun_Catalog::css/special-campaign.css"/>
|
||||
<css src="Esun_Catalog::css/product-recommendations-slider.css"/>
|
||||
<css src="Esun_Catalog::css/product-recommendations-card-v4.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Esun\Catalog\Block\Product\SpecialCampaign"
|
||||
name="product.info.special.campaign"
|
||||
template="Esun_Catalog::product/special-campaign.phtml"/>
|
||||
|
||||
<block class="Magento\Framework\View\Element\Template"
|
||||
name="esun.catalog.configurable.price.state"
|
||||
template="Esun_Catalog::product/configurable-price-state.phtml"/>
|
||||
</referenceContainer>
|
||||
<referenceContainer name="product.info.stock.sku" remove="true"/>
|
||||
<referenceBlock name="page.main.title" remove="true"/>
|
||||
<referenceBlock name="product.info.overview" remove="true"/>
|
||||
<referenceBlock name="product.info.description" remove="true"/>
|
||||
<referenceBlock name="product.attributes" remove="true"/>
|
||||
<referenceBlock name="reviews.tab" remove="true"/>
|
||||
<referenceBlock name="product.attributes.wrapper" remove="true"/>
|
||||
<referenceBlock name="product.attributes.exclude.pagebuilder" remove="true"/>
|
||||
<referenceBlock name="product.reviews.wrapper" remove="true"/>
|
||||
<referenceBlock name="product.info.product_additional_data.wrapper" remove="true"/>
|
||||
<referenceBlock name="catalog.product.related" remove="true"/>
|
||||
<referenceBlock name="product.info.details" template="Esun_Catalog::product/details.phtml">
|
||||
<block class="Magento\Catalog\Block\Product\View\Description"
|
||||
name="esun.product.info.product.overview"
|
||||
as="product_overview"
|
||||
template="Magento_Catalog::product/view/attribute.phtml"
|
||||
group="detailed_info">
|
||||
<arguments>
|
||||
<argument name="at_call" xsi:type="string">getProductOverview</argument>
|
||||
<argument name="at_code" xsi:type="string">product_overview</argument>
|
||||
<argument name="css_class" xsi:type="string">product-overview</argument>
|
||||
<argument name="at_label" xsi:type="string">none</argument>
|
||||
<argument name="title" translate="true" xsi:type="string">Product Overview</argument>
|
||||
<argument name="sort_order" xsi:type="string">10</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
<block class="Magento\Cms\Block\Block"
|
||||
name="esun.product.info.delivery.shipping"
|
||||
as="delivery_shipping"
|
||||
group="detailed_info">
|
||||
<arguments>
|
||||
<argument name="block_id" xsi:type="string">esun_product_delivery_shipping</argument>
|
||||
<argument name="title" translate="true" xsi:type="string">Delivery and Shipping</argument>
|
||||
<argument name="sort_order" xsi:type="string">20</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
<block class="Magento\Cms\Block\Block"
|
||||
name="esun.product.info.payment.security"
|
||||
as="payment_security"
|
||||
group="detailed_info">
|
||||
<arguments>
|
||||
<argument name="block_id" xsi:type="string">esun_product_payment_security</argument>
|
||||
<argument name="title" translate="true" xsi:type="string">Payment & Security</argument>
|
||||
<argument name="sort_order" xsi:type="string">30</argument>
|
||||
</arguments>
|
||||
</block>
|
||||
</referenceBlock>
|
||||
<move element="product.info.special.campaign" destination="product.info.main" before="-"/>
|
||||
|
||||
<referenceContainer name="content.aside">
|
||||
<block class="Esun\Catalog\Block\Product\DetailContent"
|
||||
name="esun.product.detail.content"
|
||||
template="Esun_Catalog::product/detail/content.phtml"
|
||||
before="esun.product.reviews">
|
||||
<block class="Esun\Catalog\Block\Product\DownloadSpecifications"
|
||||
name="esun.product.detail.download.specifications"
|
||||
as="download_specifications"
|
||||
template="Esun_Catalog::product/detail/download-specifications.phtml"/>
|
||||
<block class="Esun\Catalog\Block\Product\AvailableColors"
|
||||
name="esun.product.detail.available.colors"
|
||||
as="available_colors"
|
||||
template="Esun_Catalog::product/detail/available-colors.phtml"/>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,7 @@
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Esun_Catalog/js/configurable-price-state": {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
?>
|
||||
<div class="esun-product-service esun-product-service--delivery">
|
||||
<ul>
|
||||
<li><?= $block->escapeHtml(__('Shipping: $ 5.99, Free Shipping Over $ 99.00')) ?></li>
|
||||
<li><a href="<?= $block->escapeUrl($block->getUrl('shipping-policy')) ?>"><?= $block->escapeHtml(__('To United States Via FedEX/USPS')) ?></a></li>
|
||||
<li><?= $block->escapeHtml(__('Estimated Delivery Time: Standard Shipping')) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Product\AvailableColors $block */
|
||||
$availableColorOptions = $block->getColorOptions();
|
||||
?>
|
||||
<?php if ($availableColorOptions): ?>
|
||||
<section class="esun-product-detail-section available-colors"
|
||||
id="available-colors"
|
||||
data-mage-init='{"Esun_Catalog/js/product-color-options":<?= /* @noEscape */ $block->getColorSwatchConfigJson($availableColorOptions) ?>}'>
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('Available Colors')) ?></h2>
|
||||
<div class="esun-available-colors-layout">
|
||||
<div class="esun-available-colors">
|
||||
<?php foreach ($availableColorOptions as $colorOption): ?>
|
||||
<?php
|
||||
$ballImageUrl = (string)($colorOption['ball_image_url'] ?? '');
|
||||
$swatchColors = is_array($colorOption['swatch_colors'] ?? null) ? $colorOption['swatch_colors'] : [];
|
||||
$gradientStops = [];
|
||||
if ($swatchColors) {
|
||||
$step = 100 / count($swatchColors);
|
||||
foreach (array_values($swatchColors) as $index => $color) {
|
||||
$gradientStops[] = $color . ' ' . round($index * $step, 4) . '% ' . round(($index + 1) * $step, 4) . '%';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<figure class="esun-available-colors__item">
|
||||
<span class="esun-available-colors__visual" tabindex="0">
|
||||
<?php if ($ballImageUrl !== ''): ?>
|
||||
<img src="<?= $block->escapeUrl($ballImageUrl) ?>"
|
||||
alt="<?= $block->escapeHtmlAttr((string)$colorOption['label']) ?>">
|
||||
<?php else: ?>
|
||||
<span class="esun-available-colors__fallback"
|
||||
style="<?= $gradientStops ? 'background: conic-gradient(' . $block->escapeHtmlAttr(implode(',', $gradientStops)) . ');' : '' ?>"></span>
|
||||
<?php endif; ?>
|
||||
<span class="esun-available-colors__overlay" aria-hidden="true"></span>
|
||||
<span class="esun-available-colors__tooltip">
|
||||
<?= $block->escapeHtml((string)$colorOption['label']) ?>
|
||||
</span>
|
||||
</span>
|
||||
</figure>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="esun-available-colors-list">
|
||||
<?php foreach ($availableColorOptions as $colorOption): ?>
|
||||
<?php foreach (($colorOption['colors'] ?? []) as $color): ?>
|
||||
<?php $hexValue = strtoupper((string)($color['hex'] ?? '')); ?>
|
||||
<div class="esun-available-colors-list__row">
|
||||
<span class="esun-available-colors-list__swatch"
|
||||
style="background: <?= $block->escapeHtmlAttr($hexValue) ?>"></span>
|
||||
<span class="esun-available-colors-list__name">
|
||||
<?= $block->escapeHtml((string)($color['name'] ?? '')) ?>
|
||||
</span>
|
||||
<span class="esun-available-colors-list__hex">
|
||||
<?= $block->escapeHtml($hexValue) ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Product\DetailContent $block */
|
||||
$descriptionHtml = trim($block->getDescriptionHtml());
|
||||
$industryItems = $block->getIndustryApplications();
|
||||
$galleryImages = $block->getDetailGalleryImages();
|
||||
$creativeVideos = $block->getCreativeVideos();
|
||||
$printingParameters = $block->getPrintingParameters();
|
||||
$certificationDownloads = $block->getCertificationDownloads();
|
||||
$downloadSpecificationsHtml = trim($block->getChildHtml('download_specifications'));
|
||||
$availableColorsHtml = trim($block->getChildHtml('available_colors'));
|
||||
$faqs = $block->getFaqs();
|
||||
$hasDownload = $certificationDownloads || $downloadSpecificationsHtml !== '';
|
||||
?>
|
||||
<?php if ($descriptionHtml || $industryItems || $galleryImages || $creativeVideos || $printingParameters || $hasDownload || $availableColorsHtml || $faqs): ?>
|
||||
<div class="esun-product-detail-content">
|
||||
<?php if ($descriptionHtml): ?>
|
||||
<section class="esun-product-detail-section product-overview-content" id="overview">
|
||||
<?= /* @noEscape */ $descriptionHtml ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($industryItems || $galleryImages || $creativeVideos || $printingParameters || $hasDownload || $availableColorsHtml || $faqs): ?>
|
||||
<div class="esun-product-dynamic-sections">
|
||||
<?php if ($industryItems): ?>
|
||||
<section class="esun-product-detail-section industry-applications" id="industry-applications">
|
||||
<?php $firstIndustryItem = $industryItems[0] ?? []; ?>
|
||||
<div class="esun-industry-applications"
|
||||
data-mage-init='{"Esun_Catalog/js/industry-applications":{}}'>
|
||||
<div class="esun-industry-applications__stage">
|
||||
<?php if (!empty($firstIndustryItem['image'])): ?>
|
||||
<img class="esun-industry-applications__image"
|
||||
src="<?= $block->escapeUrl($block->getMediaUrl((string)$firstIndustryItem['image'])) ?>"
|
||||
alt="<?= $block->escapeHtmlAttr((string)($firstIndustryItem['label'] ?? '')) ?>"
|
||||
data-role="industry-large-image">
|
||||
<?php endif; ?>
|
||||
<h2 class="product-section-title esun-industry-applications__title">
|
||||
<?= $block->escapeHtml(__('Industry Applications')) ?>
|
||||
</h2>
|
||||
<div class="esun-industry-applications__nav" role="tablist">
|
||||
<?php foreach ($industryItems as $index => $item): ?>
|
||||
<?php
|
||||
$largeImage = !empty($item['image']) ? $block->getMediaUrl((string)$item['image']) : '';
|
||||
$label = (string)($item['label'] ?? '');
|
||||
?>
|
||||
<button class="esun-industry-applications__trigger<?= $index === 0 ? ' is-active' : '' ?>"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected="<?= $index === 0 ? 'true' : 'false' ?>"
|
||||
data-large-image="<?= $block->escapeUrl($largeImage) ?>"
|
||||
data-large-alt="<?= $block->escapeHtmlAttr($label) ?>">
|
||||
<?php if (!empty($item['icon'])): ?>
|
||||
<img class="esun-industry-applications__icon"
|
||||
src="<?= $block->escapeUrl($block->getMediaUrl((string)$item['icon'])) ?>"
|
||||
alt="">
|
||||
<?php endif; ?>
|
||||
<?php if ($label !== ''): ?>
|
||||
<span><?= $block->escapeHtml($label) ?></span>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($galleryImages): ?>
|
||||
<section class="esun-product-detail-section detail-gallery" id="detail-gallery">
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('Gallery')) ?></h2>
|
||||
<div class="esun-detail-gallery" data-mage-init='{"Esun_Catalog/js/drag-scroll":{}}'>
|
||||
<?php foreach ($galleryImages as $image): ?>
|
||||
<img src="<?= $block->escapeUrl($image['url']) ?>"
|
||||
alt="<?= $block->escapeHtmlAttr($image['label']) ?>">
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($creativeVideos): ?>
|
||||
<section class="esun-product-detail-section creative-videos" id="creative-videos">
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('Create Anything You Imagining')) ?></h2>
|
||||
<div class="esun-creative-videos" data-mage-init='{"Esun_Catalog/js/creative-videos":{}}'>
|
||||
<?php foreach ($creativeVideos as $video): ?>
|
||||
<div class="esun-creative-videos__item">
|
||||
<img src="<?= $block->escapeUrl($video['cover_url']) ?>" alt="">
|
||||
<video muted playsinline preload="metadata" src="<?= $block->escapeUrl($video['video_url']) ?>"></video>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($printingParameters): ?>
|
||||
<section class="esun-product-detail-section printing-parameter" id="printing-parameter">
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('Printing Parameter')) ?></h2>
|
||||
<div class="esun-printing-parameter">
|
||||
<?php foreach ($printingParameters as $groupName => $group): ?>
|
||||
<?php
|
||||
$items = is_array($group['items'] ?? null) ? $group['items'] : [];
|
||||
$iconUrl = $block->getPrintingParameterIconUrl((string)($group['icon'] ?? ''));
|
||||
if (!$items) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<div class="esun-printing-parameter__group">
|
||||
<h3 class="esun-printing-parameter__group-title">
|
||||
<?php if ($iconUrl): ?>
|
||||
<img src="<?= $block->escapeUrl($iconUrl) ?>" alt="">
|
||||
<?php endif; ?>
|
||||
<span><?= $block->escapeHtml((string)$groupName) ?></span>
|
||||
</h3>
|
||||
<div class="esun-printing-parameter__items esun-printing-parameter__items--count-<?= (int)min(count($items), 4) ?>">
|
||||
<?php foreach ($items as $label => $value): ?>
|
||||
<div class="esun-printing-parameter__item">
|
||||
<div class="esun-printing-parameter__label"><?= $block->escapeHtml((string)$label) ?></div>
|
||||
<div class="esun-printing-parameter__value"><?= /* @noEscape */ nl2br($block->escapeHtml((string)$value)) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($hasDownload): ?>
|
||||
<?php $defaultDownloadTab = $certificationDownloads ? 'certification' : 'specifications'; ?>
|
||||
<section class="esun-product-detail-section download" id="download"
|
||||
data-mage-init='{"Esun_Catalog/js/download-tabs":{}}'>
|
||||
<div class="esun-download__head">
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('Download')) ?></h2>
|
||||
<div class="esun-download__tabs" role="tablist" aria-label="<?= $block->escapeHtmlAttr(__('Download')) ?>">
|
||||
<?php if ($certificationDownloads): ?>
|
||||
<button class="esun-download__tab<?= $defaultDownloadTab === 'certification' ? ' is-active' : '' ?>"
|
||||
type="button"
|
||||
data-download-tab="certification">
|
||||
<?= $block->escapeHtml(__('Certification')) ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($downloadSpecificationsHtml !== ''): ?>
|
||||
<button class="esun-download__tab<?= $defaultDownloadTab === 'specifications' ? ' is-active' : '' ?>"
|
||||
type="button"
|
||||
data-download-tab="specifications">
|
||||
<?= $block->escapeHtml(__('Download Specifications')) ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($certificationDownloads): ?>
|
||||
<div class="esun-download__panel<?= $defaultDownloadTab === 'certification' ? ' is-active' : '' ?>"
|
||||
data-download-panel="certification">
|
||||
<div class="esun-certification-downloads">
|
||||
<?php foreach ($certificationDownloads as $download): ?>
|
||||
<a class="esun-certification-downloads__item"
|
||||
href="<?= $block->escapeUrl($download['file_url']) ?>"
|
||||
download="<?= $block->escapeHtmlAttr($download['file_name']) ?>">
|
||||
<?php if (!empty($download['icon_url'])): ?>
|
||||
<span class="esun-certification-downloads__icon">
|
||||
<img src="<?= $block->escapeUrl($download['icon_url']) ?>"
|
||||
alt="">
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<span class="esun-certification-downloads__name">
|
||||
<?= $block->escapeHtml($download['name']) ?>
|
||||
</span>
|
||||
<span class="esun-certification-downloads__text">
|
||||
<?= $block->escapeHtml(__('Download')) ?>
|
||||
</span>
|
||||
<span class="esun-certification-downloads__button" aria-hidden="true"></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($downloadSpecificationsHtml !== ''): ?>
|
||||
<div class="esun-download__panel<?= $defaultDownloadTab === 'specifications' ? ' is-active' : '' ?>"
|
||||
data-download-panel="specifications">
|
||||
<?= /* @noEscape */ $downloadSpecificationsHtml ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= /* @noEscape */ $availableColorsHtml ?>
|
||||
|
||||
<?php if ($faqs): ?>
|
||||
<section class="esun-product-detail-section faq" id="faq">
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('FAQ')) ?></h2>
|
||||
<div class="esun-product-faq">
|
||||
<?php foreach ($faqs as $faq): ?>
|
||||
<details class="esun-product-faq__item">
|
||||
<summary><?= $block->escapeHtml($faq['title']) ?></summary>
|
||||
<div class="esun-product-faq__content"><?= /* @noEscape */ $faq['content'] ?></div>
|
||||
</details>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/** @var \Esun\Catalog\Block\Product\DownloadSpecifications $block */
|
||||
if (!$block->hasSpecifications()) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="esun-download-specifications"
|
||||
data-mage-init='{"Esun_Catalog/js/download-specifications":<?= /* @noEscape */ $block->getConfigJson() ?>}'>
|
||||
<div class="esun-download-specifications__filters">
|
||||
<label class="esun-download-specifications__field">
|
||||
<span><?= $block->escapeHtml(__('Brand')) ?></span>
|
||||
<select data-role="spec-brand">
|
||||
<option value=""><?= $block->escapeHtml(__('All Brands')) ?></option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="esun-download-specifications__field">
|
||||
<span><?= $block->escapeHtml(__('Model')) ?></span>
|
||||
<select data-role="spec-model">
|
||||
<option value=""><?= $block->escapeHtml(__('All Models')) ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="esun-download-specifications__count">
|
||||
<span><?= $block->escapeHtml(__('Download List')) ?></span>
|
||||
<strong data-role="spec-count">0</strong>
|
||||
</div>
|
||||
<div class="esun-download-specifications__empty" data-role="spec-empty">
|
||||
<span class="esun-download-specifications__empty-icon"></span>
|
||||
<strong><?= $block->escapeHtml(__('Find your printer driver')) ?></strong>
|
||||
<p><?= $block->escapeHtml(__('Select a brand or printer model to browse available downloads.')) ?></p>
|
||||
</div>
|
||||
<div class="esun-download-specifications__list" data-role="spec-list"></div>
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Catalog\Block\Product\View\Details $block */
|
||||
?>
|
||||
<?php if ($detailedInfoGroup = $block->getGroupSortedChildNames('detailed_info', 'getChildHtml')): ?>
|
||||
<div class="product info detailed esun-product-details">
|
||||
<?php $layout = $block->getLayout(); ?>
|
||||
<div class="esun-product-accordion">
|
||||
<?php foreach ($detailedInfoGroup as $name): ?>
|
||||
<?php
|
||||
$html = $layout->renderElement($name);
|
||||
if (!$html || !trim($html)) {
|
||||
continue;
|
||||
}
|
||||
$alias = $layout->getElementAlias($name);
|
||||
if (in_array($alias, ['additional', 'reviews'], true)) {
|
||||
continue;
|
||||
}
|
||||
$label = $block->getChildData($alias, 'title');
|
||||
$isOpen = $alias !== 'product_overview';
|
||||
?>
|
||||
<details class="esun-product-accordion__item"<?= $isOpen ? ' open' : '' ?>>
|
||||
<summary class="esun-product-accordion__summary">
|
||||
<span><?= $block->escapeHtml($label) ?></span>
|
||||
</summary>
|
||||
<div class="esun-product-accordion__content" id="<?= $block->escapeHtmlAttr($alias) ?>">
|
||||
<?= /* @noEscape */ $html ?>
|
||||
</div>
|
||||
</details>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Magento\Framework\View\Element\Template $block */
|
||||
?>
|
||||
<div class="esun-product-service esun-product-service--payment">
|
||||
<div class="esun-payment-methods__label"><?= $block->escapeHtml(__('Payment Methods')) ?></div>
|
||||
<div class="esun-payment-methods" aria-label="<?= $block->escapeHtmlAttr(__('Payment Methods')) ?>">
|
||||
<span>PayPal</span>
|
||||
<span>Apple Pay</span>
|
||||
<span>Google Pay</span>
|
||||
<span>Klarna</span>
|
||||
<span>VISA</span>
|
||||
<span>Mastercard</span>
|
||||
<span>Maestro</span>
|
||||
<span>JCB</span>
|
||||
<span>AmEx</span>
|
||||
<span>Diners Club</span>
|
||||
<span>Discover</span>
|
||||
</div>
|
||||
<p><?= $block->escapeHtml(__('Your Payment Information Is Processed Securely. We Do Not Store Credit Card Details Nor Have Access To Your Credit Card Information.')) ?></p>
|
||||
</div>
|
||||
ITEM DIAMETER
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var \Esun\Catalog\Block\Product\PurchaseProgress $block */
|
||||
$config = $block->getConfig();
|
||||
$mixEnabled = !empty($config['mixEnabled']);
|
||||
$mixConfig = is_array($config['mix'] ?? null) ? $config['mix'] : [];
|
||||
$initialProductConfig = $block->getInitialProductConfig($config);
|
||||
$initialMilestones = $mixEnabled ? [] : ($initialProductConfig ? $block->getInitialMilestones($initialProductConfig) : []);
|
||||
$initialQty = max(1, (int)$block->getData('initial_qty'));
|
||||
$initialProgressPercent = $block->getInitialProgressPercent($initialMilestones, $initialQty);
|
||||
?>
|
||||
<?php if (!empty($config['products'])): ?>
|
||||
<div class="esun-purchase-progress" data-role="esun-purchase-progress">
|
||||
<?php if ($mixEnabled): ?>
|
||||
<div class="esun-purchase-progress__heading">
|
||||
<strong><?= $block->escapeHtml(__('Mix variants, save more')) ?></strong>
|
||||
<span data-role="mix-message"><?= $block->escapeHtml(__('Choose quantities below to unlock a mix price.')) ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="esun-purchase-progress__graph">
|
||||
<div class="esun-purchase-progress__track"
|
||||
data-role="progress-track"
|
||||
style="--esun-progress-width: <?= $block->escapeHtmlAttr((string)$initialProgressPercent) ?>%"></div>
|
||||
<div class="esun-purchase-progress__steps" data-role="progress-steps">
|
||||
<?php foreach ($initialMilestones as $milestone): ?>
|
||||
<?php
|
||||
$qty = (int)($milestone['qty'] ?? 0);
|
||||
$percentage = $milestone['percentage'] ?? null;
|
||||
?>
|
||||
<div class="esun-purchase-progress__step">
|
||||
<span class="esun-purchase-progress__marker"></span>
|
||||
<span class="esun-purchase-progress__value">
|
||||
<?= $block->escapeHtml($block->formatAmount((float)($milestone['price'] ?? 0))) ?>
|
||||
</span>
|
||||
<span class="esun-purchase-progress__label">
|
||||
<?= $block->escapeHtml(__('%1 pcs', $qty)) ?><?= $percentage ? $block->escapeHtml(' ' . (float)$percentage . '% off') : '' ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($mixEnabled): ?>
|
||||
<?php $mixItems = is_array($mixConfig['items'] ?? null) ? $mixConfig['items'] : []; ?>
|
||||
<section class="esun-mix-builder" data-role="esun-mix-builder">
|
||||
<input type="hidden" name="mix_mode" value="add" data-role="mix-mode"/>
|
||||
<div class="esun-mix-builder__items" data-role="mix-items" hidden>
|
||||
<?php foreach ($mixItems as $item): ?>
|
||||
<input type="hidden"
|
||||
name="mix_items[<?= $block->escapeHtmlAttr((string)$item['id']) ?>]"
|
||||
value="0"
|
||||
data-role="mix-item-qty"
|
||||
data-configured="0"
|
||||
data-child-id="<?= $block->escapeHtmlAttr((string)$item['id']) ?>"
|
||||
data-options="<?= $block->escapeHtmlAttr((string)json_encode($item['options'] ?? [])) ?>"
|
||||
data-base-price="<?= $block->escapeHtmlAttr((string)$item['basePrice']) ?>"/>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="esun-mix-builder__summary" aria-live="polite">
|
||||
<span>
|
||||
<strong><?= $block->escapeHtml(__('Mix selection')) ?></strong>
|
||||
<small data-role="mix-selection-summary"><?= $block->escapeHtml(__('Choose a color, then set its quantity.')) ?></small>
|
||||
</span>
|
||||
<span>
|
||||
<del data-role="mix-base-total"></del>
|
||||
<strong data-role="mix-final-total"><?= $block->escapeHtml($block->formatAmount(0)) ?></strong>
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"[data-role=esun-purchase-progress]": {
|
||||
"Esun_Catalog/js/purchase-progress": <?= /* @noEscape */ $block->getJsonConfig() ?>
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/** @var \Esun\Catalog\Block\Product\RecommendedProducts $block */
|
||||
$items = $block->getRecommendedItems();
|
||||
?>
|
||||
<?php if ($items): ?>
|
||||
<section class="esun-recommended-products" id="recommended-products"
|
||||
data-mage-init='{"Esun_Catalog/js/recommendations-carousel":{}}'>
|
||||
<div class="esun-recommended-products__heading">
|
||||
<h2 class="product-section-title"><?= $block->escapeHtml(__('You may need-Cost Savings:')) ?></h2>
|
||||
<div class="esun-recommended-products__navigation" aria-label="<?= $block->escapeHtmlAttr(__('Recommendation navigation')) ?>">
|
||||
<button class="esun-recommended-products__previous" type="button" aria-label="<?= $block->escapeHtmlAttr(__('Previous products')) ?>">‹</button>
|
||||
<button class="esun-recommended-products__next" type="button" aria-label="<?= $block->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);
|
||||
?>
|
||||
<article class="esun-recommended-products__item">
|
||||
<a class="esun-recommended-products__image"
|
||||
href="<?= $block->escapeUrl($productUrl) ?>"
|
||||
aria-label="<?= $block->escapeHtmlAttr($item->getName()) ?>">
|
||||
<?= /* @noEscape */ $block->getImage($item, 'recommended_products_list')->toHtml() ?>
|
||||
</a>
|
||||
<div class="esun-recommended-products__body">
|
||||
<h3 class="esun-recommended-products__name">
|
||||
<a href="<?= $block->escapeUrl($productUrl) ?>">
|
||||
<?= $block->escapeHtml($item->getName()) ?>
|
||||
</a>
|
||||
</h3>
|
||||
<div class="esun-recommended-products__footer">
|
||||
<div class="esun-recommended-products__summary">
|
||||
<div class="esun-recommended-products__prices">
|
||||
<span class="esun-recommended-products__final-price">
|
||||
<?= $block->escapeHtml($block->getFormattedFinalPrice($item)) ?>
|
||||
</span>
|
||||
<?php if ($block->hasOldPrice($item)): ?>
|
||||
<span class="esun-recommended-products__old-price">
|
||||
<?= $block->escapeHtml($block->getFormattedRegularPrice($item)) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($discountPercent !== null): ?>
|
||||
<span class="esun-recommended-products__discount">
|
||||
<?= (int)$discountPercent ?>% <?= $block->escapeHtml(__('OFF')) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="esun-recommended-products__actions">
|
||||
<a class="esun-recommended-products__cart"
|
||||
href="<?= $block->escapeUrl($productUrl) ?>"
|
||||
aria-label="<?= $block->escapeHtmlAttr(__('View product')) ?>">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" />
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $block \Esun\Catalog\Block\Product\SpecialCampaign
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
$campaignItems = $block->getCampaignConfig();
|
||||
$defaultItem = $campaignItems ? reset($campaignItems) : null;
|
||||
$productName = $block->getProductName();
|
||||
$shortDescriptionHtml = $block->getShortDescriptionHtml();
|
||||
?>
|
||||
<div class="product-campaign-summary">
|
||||
<?php if ($defaultItem): ?>
|
||||
<div class="product-special-campaign" data-role="product-special-campaign">
|
||||
<img
|
||||
class="product-special-campaign__icon"
|
||||
src="<?= $block->escapeUrl($block->getViewFileUrl('Esun_Catalog::images/spring-sale-tag.png')) ?>"
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div class="product-special-campaign__title">
|
||||
<?= $block->escapeHtml(__('Stock Up For Spring')) ?>
|
||||
</div>
|
||||
<div class="product-special-campaign__countdown" data-role="campaign-countdown">
|
||||
<span><strong data-role="campaign-days">0</strong><?= $block->escapeHtml(__('Days')) ?></span>
|
||||
<span><strong data-role="campaign-hours">0</strong><?= $block->escapeHtml(__('Hours')) ?></span>
|
||||
<span><strong data-role="campaign-minutes">0</strong><?= $block->escapeHtml(__('Minutes')) ?></span>
|
||||
<span><strong data-role="campaign-seconds">0</strong><?= $block->escapeHtml(__('Second')) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($productName !== ''): ?>
|
||||
<div class="page-title-wrapper product product-campaign-summary__title-wrapper">
|
||||
<h1 class="page-title">
|
||||
<span class="base" data-ui-id="page-title-wrapper" itemprop="name">
|
||||
<?= $block->escapeHtml($productName) ?>
|
||||
</span>
|
||||
</h1>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($shortDescriptionHtml !== ''): ?>
|
||||
<div class="product attribute overview product-campaign-summary__overview">
|
||||
<div class="value" itemprop="description"><?= /* @noEscape */ $shortDescriptionHtml ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($defaultItem): ?>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"[data-role=product-special-campaign]": {
|
||||
"Esun_Catalog/js/product-special-campaign": {
|
||||
"items": <?= /* @noEscape */ json_encode($campaignItems) ?>
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Product-page AJAX wishlist action.
|
||||
*
|
||||
* @var \Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist $block
|
||||
*/
|
||||
$product = $block->getProduct();
|
||||
$buttonId = 'esun-product-wishlist-' . (int) $product->getId();
|
||||
?>
|
||||
<?php if ($block->isWishListAllowed()) : ?>
|
||||
<button type="button"
|
||||
id="<?= $block->escapeHtmlAttr($buttonId) ?>"
|
||||
class="esun-product-wishlist"
|
||||
data-post='<?= /* @noEscape */ $block->getWishlistParams() ?>'
|
||||
data-action="add-to-wishlist"
|
||||
aria-label="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"
|
||||
aria-pressed="false"
|
||||
title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
|
||||
<i class="iconfont icon-favorite6" aria-hidden="true"></i>
|
||||
<span class="esun-product-wishlist__label"><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
|
||||
</button>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"body": {
|
||||
"addToWishlist": <?= /* @noEscape */ $block->getWishlistOptionsJson() ?>
|
||||
},
|
||||
"#<?= $block->escapeJs($buttonId) ?>": {
|
||||
"Esun_Catalog/js/product-wishlist": {
|
||||
"loginUrl": "<?= $block->escapeUrl($block->getUrl('customer/account/login')) ?>",
|
||||
"statusUrl": "<?= $block->escapeUrl($block->getUrl('wishlist/status/index')) ?>",
|
||||
"productId": <?= (int) $product->getId() ?>
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,73 @@
|
||||
.catalog-product-view .esun-recommended-products__body {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__summary {
|
||||
align-items: center;
|
||||
column-gap: 32px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) max-content;
|
||||
justify-content: normal;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__prices {
|
||||
flex: none;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__final-price,
|
||||
.catalog-product-view .esun-recommended-products__old-price,
|
||||
.catalog-product-view .esun-recommended-products__discount {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__discount {
|
||||
justify-self: end;
|
||||
margin-left: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex: 0 0 56% !important;
|
||||
max-width: 56%;
|
||||
width: 56% !important;
|
||||
grid-template-columns: minmax(180px, 40%) minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) and (max-width: 1199px) {
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex: 0 0 68% !important;
|
||||
max-width: 68%;
|
||||
width: 68% !important;
|
||||
grid-template-columns: minmax(160px, 38%) minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex: 0 0 86% !important;
|
||||
max-width: 86%;
|
||||
width: 86% !important;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__summary {
|
||||
column-gap: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 479px) {
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex-basis: 92% !important;
|
||||
max-width: 92%;
|
||||
width: 92% !important;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__summary {
|
||||
column-gap: 20px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
.catalog-product-view .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%;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__slider::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__slider.is-dragging {
|
||||
cursor: grabbing;
|
||||
scroll-behavior: auto;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__wrapper {
|
||||
align-items: stretch;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
gap: 24px;
|
||||
transform: none !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex: 0 0 calc((100% - 24px) / 2);
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__previous.is-disabled,
|
||||
.catalog-product-view .esun-recommended-products__next.is-disabled,
|
||||
.catalog-product-view .esun-recommended-products__previous:disabled,
|
||||
.catalog-product-view .esun-recommended-products__next:disabled {
|
||||
cursor: default;
|
||||
opacity: .35;
|
||||
}
|
||||
|
||||
@media (max-width: 1199px) {
|
||||
.catalog-product-view .esun-recommended-products__wrapper {
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex-basis: 61%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.catalog-product-view .esun-recommended-products__wrapper {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex-basis: 74%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 479px) {
|
||||
.catalog-product-view .esun-recommended-products__wrapper {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-recommended-products__item {
|
||||
flex-basis: 92%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
.catalog-product-view .esun-product-review-actions {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
margin: 0 0 18px;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-review-actions .product-reviews-summary.esun-review-summary {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-wishlist {
|
||||
align-items: center;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
color: #333;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
padding: 2px;
|
||||
position: relative;
|
||||
margin-top: -20px;
|
||||
transition: color .2s ease;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-wishlist:hover,
|
||||
.catalog-product-view .esun-product-wishlist:focus {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
color: #e53935;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-wishlist.is-active {
|
||||
color: #e53935;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-wishlist.is-loading {
|
||||
cursor: wait;
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-wishlist .iconfont {
|
||||
display: block;
|
||||
font-size: 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.catalog-product-view .esun-product-wishlist__label {
|
||||
clip: rect(0, 0, 0, 0);
|
||||
clip-path: inset(50%);
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
width: 1px;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+7
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
|
||||
<circle cx="12" cy="12" r="9"/>
|
||||
<path d="M12 8h.01"/>
|
||||
<path d="M11 12h1v5h1"/>
|
||||
<path d="M4.5 12h2"/>
|
||||
<path d="M17.5 12h2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 320 B |
+6
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
|
||||
<path d="M12 3 21 8v8l-9 5-9-5V8l9-5Z"/>
|
||||
<path d="M12 3v18"/>
|
||||
<path d="m3 8 9 5 9-5"/>
|
||||
<path d="m6.5 17.9 11-12"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 309 B |
+6
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
|
||||
<path d="M8 3h8"/>
|
||||
<path d="M10 3v5l-5 9a3 3 0 0 0 2.6 4.5h8.8A3 3 0 0 0 19 17l-5-9V3"/>
|
||||
<path d="M8 15h8"/>
|
||||
<path d="M9 19h6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 323 B |
+8
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
|
||||
<path d="M7 8h10"/>
|
||||
<path d="M7 14h10"/>
|
||||
<path d="M9 20h6"/>
|
||||
<path d="M6 4h12v4H6z"/>
|
||||
<path d="M6 8 4 20h16L18 8"/>
|
||||
<path d="M10 17h4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 335 B |
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
@@ -0,0 +1,37 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/translate'
|
||||
], function ($, $t) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $button = $(element),
|
||||
$form = $(config.formSelector || '#product_addtocart_form'),
|
||||
checkoutUrl = config.checkoutUrl || '/checkout',
|
||||
defaultText = $.trim($button.text()) || $t('Buy Now');
|
||||
|
||||
if (!$form.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$button.on('click', function () {
|
||||
if ($button.prop('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof $form.validation === 'function') {
|
||||
$form.validation();
|
||||
if (!$form.validation('isValid')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$button.addClass('disabled').prop('disabled', true).find('span').text($t('Adding...'));
|
||||
$form.find('input[name="return_url"]').val(checkoutUrl);
|
||||
$form.trigger('submit');
|
||||
setTimeout(function () {
|
||||
$button.removeClass('disabled').prop('disabled', false).find('span').text(defaultText);
|
||||
}, 3000);
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,304 @@
|
||||
define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function () {
|
||||
var priceBoxSelector = '.product-info-main [data-role="priceBox"]',
|
||||
oldPriceSelector = '.product-info-main .sly-old-price',
|
||||
discountBadgeSelector = '.product-info-main .esun-price-discount-badge',
|
||||
swatchSelector = '.swatch-opt',
|
||||
isSyncing = false,
|
||||
isApplyingDefaultSelection = false;
|
||||
|
||||
function selectFirstAvailableOptions() {
|
||||
var $productInfo = $('.product-info-main'),
|
||||
foundControls = false;
|
||||
|
||||
if (!$productInfo.length || isApplyingDefaultSelection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
isApplyingDefaultSelection = true;
|
||||
$productInfo.find('.swatch-attribute').each(function () {
|
||||
var $attribute = $(this),
|
||||
$selected = $attribute.find('.swatch-option.selected').first(),
|
||||
$firstAvailable;
|
||||
|
||||
foundControls = true;
|
||||
if ($selected.length || $attribute.find('.super-attribute-select').val()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$firstAvailable = $attribute.find('.swatch-option')
|
||||
.not('.disabled, [aria-disabled="true"], .esun-out-of-stock-option')
|
||||
.filter(':visible')
|
||||
.first();
|
||||
|
||||
if (!$firstAvailable.length) {
|
||||
$firstAvailable = $attribute.find('.swatch-option')
|
||||
.not('.disabled, [aria-disabled="true"], [data-option-empty="true"]')
|
||||
.filter(':visible')
|
||||
.first();
|
||||
}
|
||||
|
||||
if ($firstAvailable.length) {
|
||||
$firstAvailable.trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$productInfo.find('.super-attribute-select').each(function () {
|
||||
var $select = $(this),
|
||||
$firstAvailable;
|
||||
|
||||
foundControls = true;
|
||||
if ($select.closest('.swatch-attribute').length || $select.val()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$firstAvailable = $select.find('option')
|
||||
.filter(function () {
|
||||
return this.value && !this.disabled && !$(this).hasClass('esun-out-of-stock-option');
|
||||
})
|
||||
.first();
|
||||
|
||||
if (!$firstAvailable.length) {
|
||||
$firstAvailable = $select.find('option')
|
||||
.filter(function () {
|
||||
return this.value && !this.disabled;
|
||||
})
|
||||
.first();
|
||||
}
|
||||
|
||||
if ($firstAvailable.length) {
|
||||
$select.val($firstAvailable.val()).trigger('change');
|
||||
}
|
||||
});
|
||||
isApplyingDefaultSelection = false;
|
||||
|
||||
return foundControls;
|
||||
}
|
||||
|
||||
function initializeDefaultSelection() {
|
||||
[0, 100, 300, 700].forEach(function (delay) {
|
||||
window.setTimeout(selectFirstAvailableOptions, delay);
|
||||
});
|
||||
}
|
||||
|
||||
function getSwatchWidget() {
|
||||
var $swatch = $(swatchSelector);
|
||||
|
||||
return $swatch.data('mageSwatchRenderer') || $swatch.data('mage-SwatchRenderer');
|
||||
}
|
||||
|
||||
function getJsonConfig() {
|
||||
var swatchWidget = getSwatchWidget();
|
||||
|
||||
return swatchWidget && swatchWidget.options && swatchWidget.options.jsonConfig;
|
||||
}
|
||||
|
||||
function getSelectedProductIdFromSwatches() {
|
||||
var jsonConfig = getJsonConfig(),
|
||||
selectedOptions = {},
|
||||
matchedProductId = null;
|
||||
|
||||
if (!jsonConfig || !jsonConfig.index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$('.swatch-attribute').each(function () {
|
||||
var $attribute = $(this),
|
||||
attributeId = $attribute.attr('attribute-id') || $attribute.data('attribute-id'),
|
||||
optionId = $attribute.find('.swatch-option.selected').attr('option-id') ||
|
||||
$attribute.find('.swatch-option.selected').data('option-id') ||
|
||||
$attribute.find('.super-attribute-select').val();
|
||||
|
||||
if (attributeId && optionId) {
|
||||
selectedOptions[attributeId] = String(optionId);
|
||||
}
|
||||
});
|
||||
|
||||
$.each(jsonConfig.index, function (productId, productOptions) {
|
||||
var isMatch = true;
|
||||
|
||||
$.each(selectedOptions, function (attributeId, optionId) {
|
||||
if (String(productOptions[attributeId]) !== optionId) {
|
||||
isMatch = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (isMatch && Object.keys(selectedOptions).length) {
|
||||
matchedProductId = productId;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return matchedProductId;
|
||||
}
|
||||
|
||||
function getSelectedProductId() {
|
||||
var selectedProduct = $('[name="selected_configurable_option"]').val(),
|
||||
swatchWidget;
|
||||
|
||||
if (selectedProduct) {
|
||||
return selectedProduct;
|
||||
}
|
||||
|
||||
swatchWidget = getSwatchWidget();
|
||||
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
|
||||
selectedProduct = swatchWidget.getProductId();
|
||||
if (selectedProduct) {
|
||||
return selectedProduct;
|
||||
}
|
||||
}
|
||||
|
||||
return getSelectedProductIdFromSwatches();
|
||||
}
|
||||
|
||||
function hasCompleteSwatchSelection() {
|
||||
var $attributes = $('.swatch-attribute');
|
||||
|
||||
if (!$attributes.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $attributes.filter(function () {
|
||||
return $(this).find('.swatch-option.selected').length ||
|
||||
$(this).find('.super-attribute-select').val();
|
||||
}).length === $attributes.length;
|
||||
}
|
||||
|
||||
function shouldShowOldPrice() {
|
||||
return Boolean(getSelectedProductId() || hasCompleteSwatchSelection());
|
||||
}
|
||||
|
||||
function getSelectedPrices() {
|
||||
var selectedProductId = getSelectedProductId(),
|
||||
jsonConfig = getJsonConfig();
|
||||
|
||||
if (!selectedProductId || !jsonConfig || !jsonConfig.optionPrices) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonConfig.optionPrices[selectedProductId] || null;
|
||||
}
|
||||
|
||||
function getDiscountPercent() {
|
||||
var prices = getSelectedPrices(),
|
||||
oldPrice = prices && prices.oldPrice && Number(prices.oldPrice.amount),
|
||||
finalPrice = prices && prices.finalPrice && Number(prices.finalPrice.amount);
|
||||
|
||||
if (!oldPrice || !finalPrice || finalPrice >= oldPrice) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Math.round((oldPrice - finalPrice) / oldPrice * 100);
|
||||
}
|
||||
|
||||
function getDiscountBadge($oldPrice) {
|
||||
var $badge = $(discountBadgeSelector);
|
||||
|
||||
if (!$badge.length && $oldPrice.length) {
|
||||
$badge = $('<span/>', {
|
||||
'class': 'esun-price-discount-badge',
|
||||
'aria-hidden': 'true'
|
||||
});
|
||||
$oldPrice.after($badge);
|
||||
}
|
||||
|
||||
return $badge;
|
||||
}
|
||||
|
||||
function showDiscountBadge($badge, text) {
|
||||
if ($badge.text() !== text) {
|
||||
$badge.text(text);
|
||||
}
|
||||
|
||||
$badge.css('display', 'inline-flex').show();
|
||||
}
|
||||
|
||||
function syncOldPriceState() {
|
||||
var $oldPrice = $(oldPriceSelector),
|
||||
$badge = getDiscountBadge($oldPrice),
|
||||
discountPercent = getDiscountPercent();
|
||||
|
||||
if (isSyncing) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSyncing = true;
|
||||
|
||||
if (shouldShowOldPrice()) {
|
||||
$oldPrice.removeClass('no-display').css('display', 'inline-block').show();
|
||||
if (discountPercent) {
|
||||
showDiscountBadge($badge, discountPercent + '% OFF');
|
||||
} else {
|
||||
$badge.hide();
|
||||
}
|
||||
isSyncing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
$oldPrice.hide().addClass('no-display').css('display', 'none');
|
||||
$badge.hide();
|
||||
isSyncing = false;
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
window.setTimeout(syncOldPriceState, 80);
|
||||
window.setTimeout(syncOldPriceState, 250);
|
||||
window.setTimeout(syncOldPriceState, 500);
|
||||
}
|
||||
|
||||
function watchPriceBox() {
|
||||
var productInfo = document.querySelector('.product-info-main'),
|
||||
observer;
|
||||
|
||||
if (!productInfo || !window.MutationObserver) {
|
||||
return;
|
||||
}
|
||||
|
||||
observer = new MutationObserver(function (mutations) {
|
||||
var ignoreMutation = Array.prototype.every.call(mutations || [], function (mutation) {
|
||||
var target = mutation.target;
|
||||
|
||||
return target && (
|
||||
$(target).closest(discountBadgeSelector).length ||
|
||||
$(target).is(discountBadgeSelector)
|
||||
);
|
||||
});
|
||||
|
||||
if (ignoreMutation) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSyncing) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(productInfo, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class', 'style'],
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
|
||||
refresh();
|
||||
watchPriceBox();
|
||||
initializeDefaultSelection();
|
||||
|
||||
$(document).on(
|
||||
'configurable.initialized.esunDefaultOption swatch.initialized.esunDefaultOption',
|
||||
initializeDefaultSelection
|
||||
);
|
||||
|
||||
$(document).on(
|
||||
'click change updatePrice priceUpdated configurable.initialized swatch.initialized',
|
||||
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"], .price-box, ' + priceBoxSelector,
|
||||
refresh
|
||||
);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
$(element).find('.esun-creative-videos__item').each(function () {
|
||||
var item = this,
|
||||
video = item.querySelector('video');
|
||||
|
||||
if (!video) {
|
||||
return;
|
||||
}
|
||||
|
||||
item.addEventListener('mouseenter', function () {
|
||||
video.currentTime = 0;
|
||||
video.play().catch(function () {});
|
||||
item.classList.add('is-playing');
|
||||
});
|
||||
item.addEventListener('mouseleave', function () {
|
||||
video.pause();
|
||||
item.classList.remove('is-playing');
|
||||
});
|
||||
item.addEventListener('click', function () {
|
||||
if (video.paused) {
|
||||
video.play().catch(function () {});
|
||||
item.classList.add('is-playing');
|
||||
} else {
|
||||
video.pause();
|
||||
item.classList.remove('is-playing');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,129 @@
|
||||
define(['jquery', 'mage/translate'], function ($, $t) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $root = $(element),
|
||||
items = config.items || [],
|
||||
archives = config.archives || [],
|
||||
brands = config.brands || [],
|
||||
modelsByBrand = config.modelsByBrand || {},
|
||||
$brand = $root.find('[data-role="spec-brand"]'),
|
||||
$model = $root.find('[data-role="spec-model"]'),
|
||||
$count = $root.find('[data-role="spec-count"]'),
|
||||
$empty = $root.find('[data-role="spec-empty"]'),
|
||||
$list = $root.find('[data-role="spec-list"]');
|
||||
|
||||
function renderBrands() {
|
||||
$.each(brands, function (_, brandItem) {
|
||||
$('<option/>', {
|
||||
value: brandItem.id,
|
||||
text: brandItem.name
|
||||
}).appendTo($brand);
|
||||
});
|
||||
}
|
||||
|
||||
function renderModels() {
|
||||
var brandId = $brand.val(),
|
||||
models = brandId ? (modelsByBrand[brandId] || []) : [];
|
||||
|
||||
if (!brandId) {
|
||||
$.each(modelsByBrand, function (_, brandModels) {
|
||||
$.each(brandModels, function (_, modelName) {
|
||||
if ($.inArray(modelName, models) === -1) {
|
||||
models.push(modelName);
|
||||
}
|
||||
});
|
||||
});
|
||||
models.sort();
|
||||
}
|
||||
|
||||
$model.empty().append($('<option/>', {
|
||||
value: '',
|
||||
text: $t('All Models')
|
||||
}));
|
||||
$.each(models, function (_, modelName) {
|
||||
$('<option/>', {
|
||||
value: modelName,
|
||||
text: modelName
|
||||
}).appendTo($model);
|
||||
});
|
||||
}
|
||||
|
||||
function filterItems() {
|
||||
var brandId = $brand.val(),
|
||||
modelName = $model.val(),
|
||||
results;
|
||||
|
||||
if (!brandId && !modelName) {
|
||||
return archives.slice();
|
||||
}
|
||||
|
||||
results = $.grep(items, function (item) {
|
||||
return (!brandId || String(item.brand_id) === String(brandId)) &&
|
||||
(!modelName || item.model_name === modelName);
|
||||
});
|
||||
|
||||
if (brandId) {
|
||||
results = $.grep(archives, function (archive) {
|
||||
return String(archive.brand_id) === String(brandId);
|
||||
}).concat(results);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function renderList() {
|
||||
var results = filterItems();
|
||||
|
||||
$count.text(results.length);
|
||||
$list.empty();
|
||||
$empty.toggle(results.length === 0);
|
||||
$list.toggle(results.length > 0);
|
||||
|
||||
$.each(results, function (_, item) {
|
||||
var $item = $('<a/>', {
|
||||
'class': 'esun-download-specifications__item',
|
||||
href: item.file_url,
|
||||
download: item.file_name
|
||||
}),
|
||||
$logo = $('<span/>', {'class': 'esun-download-specifications__logo'}),
|
||||
$body = $('<span/>', {'class': 'esun-download-specifications__body'}),
|
||||
$meta = $('<span/>', {'class': 'esun-download-specifications__meta'}),
|
||||
$info = $('<span/>', {'class': 'esun-download-specifications__info'}),
|
||||
$action = $('<span/>', {'class': 'esun-download-specifications__action'});
|
||||
|
||||
if (item.brand_logo_url) {
|
||||
$('<img/>', {src: item.brand_logo_url, alt: ''}).appendTo($logo);
|
||||
}
|
||||
|
||||
$('<span/>', {'class': 'esun-download-specifications__brand', text: item.brand_name}).appendTo($meta);
|
||||
if (item.model_name) {
|
||||
$('<span/>', {'class': 'esun-download-specifications__model', text: item.model_name}).appendTo($meta);
|
||||
}
|
||||
$('<strong/>', {text: item.file_name}).appendTo($body);
|
||||
$('<span/>', {text: item.file_size_label}).appendTo($info);
|
||||
if (item.file_date) {
|
||||
$('<span/>', {text: item.file_date}).appendTo($info);
|
||||
}
|
||||
$('<span/>', {
|
||||
'class': 'esun-download-specifications__download-text',
|
||||
text: $t('Download')
|
||||
}).appendTo($action);
|
||||
$('<span/>', {'class': 'esun-download-specifications__download-icon'}).appendTo($action);
|
||||
|
||||
$body.prepend($meta).append($info);
|
||||
$item.append($logo, $body, $action).appendTo($list);
|
||||
});
|
||||
}
|
||||
|
||||
renderBrands();
|
||||
renderModels();
|
||||
renderList();
|
||||
|
||||
$brand.on('change', function () {
|
||||
renderModels();
|
||||
renderList();
|
||||
});
|
||||
$model.on('change', renderList);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $root = $(element);
|
||||
|
||||
$root.on('click', '[data-download-tab]', function () {
|
||||
var tab = $(this).data('download-tab');
|
||||
|
||||
$root.find('[data-download-tab]').removeClass('is-active');
|
||||
$(this).addClass('is-active');
|
||||
$root.find('[data-download-panel]').removeClass('is-active');
|
||||
$root.find('[data-download-panel="' + tab + '"]').addClass('is-active');
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $scroller = $(element),
|
||||
isDown = false,
|
||||
didDrag = false,
|
||||
startX = 0,
|
||||
scrollLeft = 0;
|
||||
|
||||
$scroller.on('mousedown', function (event) {
|
||||
isDown = true;
|
||||
didDrag = false;
|
||||
startX = event.pageX - $scroller.offset().left;
|
||||
scrollLeft = $scroller.scrollLeft();
|
||||
$scroller.addClass('is-dragging');
|
||||
});
|
||||
|
||||
$(document).on('mouseup.esunDragScroll', function () {
|
||||
isDown = false;
|
||||
$scroller.removeClass('is-dragging');
|
||||
});
|
||||
|
||||
$scroller.on('mouseleave', function () {
|
||||
isDown = false;
|
||||
$scroller.removeClass('is-dragging');
|
||||
});
|
||||
|
||||
$scroller.on('mousemove', function (event) {
|
||||
var x,
|
||||
walk;
|
||||
|
||||
if (!isDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
x = event.pageX - $scroller.offset().left;
|
||||
walk = x - startX;
|
||||
|
||||
if (Math.abs(walk) > 4) {
|
||||
didDrag = true;
|
||||
}
|
||||
|
||||
$scroller.scrollLeft(scrollLeft - walk);
|
||||
});
|
||||
|
||||
$scroller.on('click', 'a, img', function (event) {
|
||||
if (didDrag) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $root = $(element),
|
||||
$image = $root.find('[data-role="industry-large-image"]').first();
|
||||
|
||||
$root.on('click', '.esun-industry-applications__trigger', function () {
|
||||
var $trigger = $(this),
|
||||
imageUrl = $trigger.data('large-image'),
|
||||
imageAlt = $trigger.data('large-alt') || '';
|
||||
|
||||
if (!imageUrl || !$image.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$image.attr({
|
||||
src: imageUrl,
|
||||
alt: imageAlt
|
||||
});
|
||||
|
||||
$root.find('.esun-industry-applications__trigger')
|
||||
.removeClass('is-active')
|
||||
.attr('aria-selected', 'false');
|
||||
$trigger.addClass('is-active').attr('aria-selected', 'true');
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config) {
|
||||
var options = config.options || {};
|
||||
|
||||
function buildGradient(colors) {
|
||||
var step;
|
||||
|
||||
if (!colors || !colors.length) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (colors.length === 1) {
|
||||
return colors[0];
|
||||
}
|
||||
|
||||
step = 100 / colors.length;
|
||||
|
||||
return 'conic-gradient(' + $.map(colors, function (color, index) {
|
||||
return color + ' ' + (index * step) + '% ' + ((index + 1) * step) + '%';
|
||||
}).join(',') + ')';
|
||||
}
|
||||
|
||||
function applySwatches() {
|
||||
$.each(options, function (optionId, item) {
|
||||
var gradient = buildGradient(item.colors || []),
|
||||
$swatch;
|
||||
|
||||
if (!gradient) {
|
||||
return;
|
||||
}
|
||||
|
||||
$swatch = $('.swatch-attribute.color .swatch-option[option-id="' + optionId + '"], ' +
|
||||
'.swatch-attribute.color .swatch-option[data-option-id="' + optionId + '"]');
|
||||
|
||||
$swatch
|
||||
.addClass('esun-multi-color-swatch')
|
||||
.css({
|
||||
'background': gradient,
|
||||
'background-image': gradient
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
applySwatches();
|
||||
$(document).on('swatch.initialized configurable.initialized contentUpdated', applySwatches);
|
||||
setTimeout(applySwatches, 300);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Catalog/product/view/validation',
|
||||
'Magento_Customer/js/customer-data'
|
||||
], function ($, validation, customerData) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $form = $(element),
|
||||
submitting = false,
|
||||
isMixForm = Boolean($form.find('[data-role="esun-mix-builder"]').length);
|
||||
|
||||
if (!$form.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function getQtyInput() {
|
||||
return $form.find('input[name="qty"].input-text.qty, input[name="qty"]').first();
|
||||
}
|
||||
|
||||
function normalizeQty() {
|
||||
var $input = getQtyInput(),
|
||||
min = parseFloat($input.attr('min')) || 1,
|
||||
val = parseFloat($input.val());
|
||||
|
||||
if ($input.length && (isNaN(val) || val < min)) {
|
||||
$input.val(min).trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMixForm) {
|
||||
$form.on('input keyup change blur', 'input[name="qty"]', normalizeQty);
|
||||
normalizeQty();
|
||||
}
|
||||
|
||||
$form.validation({
|
||||
radioCheckboxClosest: config.radioCheckboxClosest || '.nested',
|
||||
submitHandler: function (form) {
|
||||
var cartData;
|
||||
|
||||
if (submitting) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isMixForm) {
|
||||
normalizeQty();
|
||||
}
|
||||
try {
|
||||
window.sessionStorage.setItem('esunGtmPendingAddToCart', '1');
|
||||
} catch (error) {
|
||||
// The add-to-cart submission must still work when storage is unavailable.
|
||||
}
|
||||
try {
|
||||
cartData = customerData.get('cart')();
|
||||
if (cartData && typeof cartData.summary_count !== 'undefined') {
|
||||
window.sessionStorage.setItem('esunOpenMinicartAfterAdd', '1');
|
||||
window.sessionStorage.setItem(
|
||||
'esunCartCountBeforeAdd',
|
||||
String(Number(cartData.summary_count) || 0)
|
||||
);
|
||||
} else {
|
||||
window.sessionStorage.removeItem('esunOpenMinicartAfterAdd');
|
||||
window.sessionStorage.removeItem('esunCartCountBeforeAdd');
|
||||
}
|
||||
} catch (error) {
|
||||
// The add-to-cart submission must still work when storage is unavailable.
|
||||
}
|
||||
submitting = true;
|
||||
form.submit();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!isMixForm) {
|
||||
$(config.addToCartButtonSelector || '.action.tocart').attr('disabled', false);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -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,88 @@
|
||||
define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $campaign = $(element),
|
||||
items = config.items || {},
|
||||
activeItem = null,
|
||||
activeStartedAt = Date.now(),
|
||||
timer = null;
|
||||
|
||||
function getFirstItem() {
|
||||
var firstKey = Object.keys(items)[0];
|
||||
|
||||
return firstKey ? items[firstKey] : null;
|
||||
}
|
||||
|
||||
function getSelectedProductId() {
|
||||
var selectedId = $('[name="selected_configurable_option"]').val(),
|
||||
swatchWidget;
|
||||
|
||||
if (selectedId && items[selectedId]) {
|
||||
return selectedId;
|
||||
}
|
||||
|
||||
swatchWidget = $('.swatch-opt').data('mageSwatchRenderer');
|
||||
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
|
||||
selectedId = swatchWidget.getProductId();
|
||||
if (selectedId && items[selectedId]) {
|
||||
return selectedId;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function pad(value) {
|
||||
return value < 10 ? '0' + value : value;
|
||||
}
|
||||
|
||||
function renderCountdown() {
|
||||
var distance;
|
||||
|
||||
if (!activeItem || typeof activeItem.remainingMs === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
distance = Math.max(0, activeItem.remainingMs - (Date.now() - activeStartedAt));
|
||||
$campaign.find('[data-role="campaign-days"]').text(Math.floor(distance / 86400000));
|
||||
$campaign.find('[data-role="campaign-hours"]').text(pad(Math.floor((distance % 86400000) / 3600000)));
|
||||
$campaign.find('[data-role="campaign-minutes"]').text(pad(Math.floor((distance % 3600000) / 60000)));
|
||||
$campaign.find('[data-role="campaign-seconds"]').text(pad(Math.floor((distance % 60000) / 1000)));
|
||||
}
|
||||
|
||||
function renderItem(item) {
|
||||
if (!item) {
|
||||
$campaign.hide();
|
||||
activeItem = null;
|
||||
return;
|
||||
}
|
||||
|
||||
activeItem = item;
|
||||
activeStartedAt = Date.now();
|
||||
$campaign.show();
|
||||
renderCountdown();
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
var selectedId = getSelectedProductId();
|
||||
|
||||
renderItem(selectedId ? items[selectedId] : getFirstItem());
|
||||
}
|
||||
|
||||
refresh();
|
||||
timer = window.setInterval(renderCountdown, 1000);
|
||||
|
||||
$(document).on('change click updatePrice configurable.initialized', '.super-attribute-select, .swatch-option, [name="selected_configurable_option"], .price-box', function () {
|
||||
window.setTimeout(refresh, 50);
|
||||
});
|
||||
|
||||
$campaign.on('remove', function () {
|
||||
if (timer) {
|
||||
window.clearInterval(timer);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,479 @@
|
||||
define(["jquery", "mage/translate"], function ($, $t) {
|
||||
"use strict";
|
||||
|
||||
return function (config) {
|
||||
var sourceSelector = config.sourceSelector || ".box-tocart",
|
||||
priceSelector =
|
||||
config.priceSelector || '[data-role="purchase-final-total"]',
|
||||
addToCartSelector =
|
||||
config.addToCartSelector || "#product-addtocart-button",
|
||||
buyNowSelector =
|
||||
config.buyNowSelector || '[data-role="esun-buy-now"]',
|
||||
anchorScopeSelector = config.anchorScopeSelector || ".column.main",
|
||||
detailContentSelector =
|
||||
config.detailContentSelector || ".esun-product-detail-content",
|
||||
anchorsConfig = config.anchors || [],
|
||||
activeClass = "esun-sticky-product-bar--active",
|
||||
bodyActiveClass = "esun-sticky-product-bar-active",
|
||||
$source = $(sourceSelector).first(),
|
||||
hasPurchaseActions = $source.length > 0,
|
||||
$window = $(window),
|
||||
$body = $("body"),
|
||||
$bar = $(),
|
||||
$inlineBar = $(),
|
||||
$nav = $(),
|
||||
$inlineNav = $(),
|
||||
$topBar = $(), // <-- 新增
|
||||
$bottomBar = $(), // <-- 新增
|
||||
sourceTop = 0,
|
||||
sourceTopBottom = 0, // 新增:底部栏触发点
|
||||
ticking = false,
|
||||
resizeTimer;
|
||||
|
||||
function normalizeText(text) {
|
||||
return $.trim(
|
||||
String(text || "").replace(/\s+/g, " "),
|
||||
).toLowerCase();
|
||||
}
|
||||
|
||||
function slugify(text) {
|
||||
return (
|
||||
normalizeText(text)
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "") || "section"
|
||||
);
|
||||
}
|
||||
|
||||
function getTriggerTop() {
|
||||
var $trigger = $inlineBar.length ? $inlineBar : $source;
|
||||
|
||||
if (!$trigger.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(0, $trigger.offset().top);
|
||||
}
|
||||
|
||||
function isUsableTarget($target) {
|
||||
return (
|
||||
$target.length &&
|
||||
!$target.closest('[data-role="esun-sticky-product-bar"]')
|
||||
.length &&
|
||||
!$target.closest('[data-role="esun-detail-product-bar"]')
|
||||
.length &&
|
||||
$.trim($target.text()).length > 0 &&
|
||||
($target.outerHeight() > 0 ||
|
||||
$target.find("img, video, iframe").length > 0)
|
||||
);
|
||||
}
|
||||
|
||||
function findBySelectors(selectors) {
|
||||
var i, $target;
|
||||
|
||||
for (i = 0; i < selectors.length; i++) {
|
||||
$target = $(selectors[i]).first();
|
||||
|
||||
if (isUsableTarget($target)) {
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
|
||||
return $();
|
||||
}
|
||||
|
||||
function findByHeading(aliases) {
|
||||
var normalizedAliases = $.map(aliases || [], normalizeText),
|
||||
$scope = $(anchorScopeSelector).first(),
|
||||
$match = $();
|
||||
|
||||
if (!$scope.length || !normalizedAliases.length) {
|
||||
return $match;
|
||||
}
|
||||
|
||||
$scope
|
||||
.find(
|
||||
'h1, h2, h3, h4, .product-section-title, [data-content-type="heading"]',
|
||||
)
|
||||
.each(function () {
|
||||
var $heading = $(this),
|
||||
text = normalizeText($heading.text()),
|
||||
$section;
|
||||
|
||||
if (
|
||||
$match.length ||
|
||||
$.inArray(text, normalizedAliases) === -1
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$section = $heading.closest(
|
||||
'[data-content-type="row"], section, .block, .product-info-detailed, .product.attribute',
|
||||
);
|
||||
$match = $section.length ? $section : $heading;
|
||||
});
|
||||
|
||||
return $match;
|
||||
}
|
||||
|
||||
function ensureTargetId($target, label, index) {
|
||||
var id = $target.attr("id");
|
||||
|
||||
if (!id) {
|
||||
id = "esun-product-section-" + slugify(label) + "-" + index;
|
||||
$target.attr("id", id);
|
||||
}
|
||||
|
||||
$target.addClass("esun-product-anchor-target");
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
function buildAnchors() {
|
||||
var found = [];
|
||||
var excludeLabels = ["Industry Applications"];
|
||||
$.each(anchorsConfig, function (index, item) {
|
||||
if (excludeLabels.indexOf(item.label) !== -1) {
|
||||
return;
|
||||
}
|
||||
var $target = findBySelectors(item.selectors || []);
|
||||
|
||||
if (!isUsableTarget($target)) {
|
||||
$target = findByHeading(item.aliases || [item.label]);
|
||||
}
|
||||
|
||||
if (!isUsableTarget($target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
found.push({
|
||||
label: item.label,
|
||||
id: ensureTargetId($target, item.label, index),
|
||||
});
|
||||
});
|
||||
|
||||
$nav.add($inlineNav).empty();
|
||||
|
||||
$.each(found, function (index, item) {
|
||||
var $link = $("<a/>", {
|
||||
class: "esun-product-anchor-nav__link",
|
||||
href: "#" + item.id,
|
||||
text: item.label,
|
||||
});
|
||||
|
||||
$link.clone().appendTo($nav);
|
||||
$link.appendTo($inlineNav);
|
||||
});
|
||||
|
||||
$bar.add($inlineBar).toggleClass(
|
||||
"esun-sticky-product-bar--no-anchors",
|
||||
!found.length,
|
||||
);
|
||||
}
|
||||
|
||||
function syncPrice() {
|
||||
var price = $.trim($(priceSelector).first().text()),
|
||||
$prices = $bar
|
||||
.add($inlineBar)
|
||||
.find('[data-role="esun-sticky-product-price"]');
|
||||
|
||||
if (!price) {
|
||||
price = $.trim(
|
||||
$(
|
||||
".product-info-main .price-box .special-price .price, .product-info-main .price-box .price",
|
||||
)
|
||||
.first()
|
||||
.text(),
|
||||
);
|
||||
}
|
||||
|
||||
$prices.each(function () {
|
||||
var $price = $(this);
|
||||
|
||||
if ($price.text() !== price) {
|
||||
$price.text(price);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function syncButtonState() {
|
||||
var $addToCart = $(addToCartSelector).first(),
|
||||
disabled =
|
||||
$addToCart.prop("disabled") ||
|
||||
$addToCart.hasClass("disabled"),
|
||||
$stickyAddToCart = $bar
|
||||
.add($inlineBar)
|
||||
.find('[data-role="esun-sticky-add-to-cart"]');
|
||||
|
||||
if ($stickyAddToCart.prop("disabled") !== disabled) {
|
||||
$stickyAddToCart.prop("disabled", disabled);
|
||||
}
|
||||
|
||||
if ($stickyAddToCart.hasClass("disabled") !== disabled) {
|
||||
$stickyAddToCart.toggleClass("disabled", disabled);
|
||||
}
|
||||
}
|
||||
|
||||
function syncActiveAnchor() {
|
||||
var stickyHeight = $bar.outerHeight() || 0,
|
||||
scrollTop = $window.scrollTop(),
|
||||
activeId = "";
|
||||
|
||||
$nav.find("a").each(function () {
|
||||
var id = $(this).attr("href").replace("#", ""),
|
||||
$target = $("#" + $.escapeSelector(id));
|
||||
|
||||
if (
|
||||
$target.length &&
|
||||
$target.offset().top - stickyHeight - 20 <= scrollTop
|
||||
) {
|
||||
activeId = id;
|
||||
}
|
||||
});
|
||||
|
||||
$nav.add($inlineNav).find("a").removeClass("is-active");
|
||||
|
||||
if (activeId) {
|
||||
$nav.add($inlineNav)
|
||||
.find('a[href="#' + activeId + '"]')
|
||||
.addClass("is-active");
|
||||
}
|
||||
}
|
||||
|
||||
function updateSticky() {
|
||||
var scrollTop = $window.scrollTop();
|
||||
|
||||
var shouldStickTop = scrollTop >= sourceTop;
|
||||
var shouldStickBottom = scrollTop >= sourceTopBottom;
|
||||
|
||||
// 分别控制顶部和底部
|
||||
$topBar.toggleClass(activeClass, shouldStickTop);
|
||||
$bottomBar.toggleClass(activeClass, shouldStickBottom);
|
||||
|
||||
// body 类:只要有一个显示就添加(用于全局样式调整)
|
||||
$body.toggleClass(
|
||||
bodyActiveClass,
|
||||
shouldStickTop || shouldStickBottom,
|
||||
);
|
||||
|
||||
// 顶部锚点高亮(依然基于顶部导航)
|
||||
syncActiveAnchor();
|
||||
|
||||
ticking = false;
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
if (!ticking) {
|
||||
ticking = true;
|
||||
window.requestAnimationFrame(updateSticky);
|
||||
}
|
||||
}
|
||||
|
||||
function refreshOffsets() {
|
||||
sourceTop = getTriggerTop();
|
||||
|
||||
// 底部触发点:基于 .esun-product-details
|
||||
var $customTrigger = $(".esun-product-details").first();
|
||||
if ($customTrigger.length) {
|
||||
sourceTopBottom = Math.max(0, $customTrigger.offset().top);
|
||||
} else {
|
||||
// 如果没找到该元素,则回退到顶部触发点或 0(根据需求可改为 0)
|
||||
sourceTopBottom = sourceTop;
|
||||
}
|
||||
//sourceTop = getTriggerTop();
|
||||
var bottomHeight = $bottomBar.length ? $bottomBar.outerHeight() : 0;
|
||||
$body.css("padding-bottom", bottomHeight + "px");
|
||||
$body.css(
|
||||
"--esun-sticky-product-bar-height",
|
||||
($topBar.outerHeight() || 0) + "px",
|
||||
);
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
function createProductBar(className, role) {
|
||||
var $productBar = $("<div/>", {
|
||||
class: className,
|
||||
"data-role": role,
|
||||
});
|
||||
|
||||
// $('<div/>', {'class': 'esun-sticky-product-bar__actions'})
|
||||
// .append($('<strong/>', {
|
||||
// 'class': 'esun-sticky-product-bar__price',
|
||||
// 'data-role': 'esun-sticky-product-price'
|
||||
// }))
|
||||
// .append($('<button/>', {
|
||||
// 'type': 'button',
|
||||
// 'class': 'action primary tocart esun-sticky-product-bar__add',
|
||||
// 'data-role': 'esun-sticky-add-to-cart',
|
||||
// 'text': $t('Add to Cart')
|
||||
// }))
|
||||
// .append($('<button/>', {
|
||||
// 'type': 'button',
|
||||
// 'class': 'action primary esun-buy-now esun-sticky-product-bar__buy',
|
||||
// 'data-role': 'esun-sticky-buy-now',
|
||||
// 'text': $t('Buy Now')
|
||||
// }))
|
||||
// .appendTo($productBar);
|
||||
|
||||
$("<nav/>", {
|
||||
class: "esun-product-anchor-nav",
|
||||
"data-role": "esun-product-anchor-nav",
|
||||
"aria-label": $t("Product detail sections"),
|
||||
}).appendTo($productBar);
|
||||
|
||||
return $productBar;
|
||||
}
|
||||
|
||||
function createStickyBar() {
|
||||
// ----- 顶部 Bar(仅导航)-----
|
||||
$topBar = $("<div/>", {
|
||||
class: "esun-sticky-product-bar esun-sticky-product-bar--top",
|
||||
"data-role": "esun-sticky-product-bar-top",
|
||||
});
|
||||
$nav = $("<nav/>", {
|
||||
class: "esun-product-anchor-nav",
|
||||
"data-role": "esun-product-anchor-nav",
|
||||
"aria-label": $t("Product detail sections"),
|
||||
}).appendTo($topBar);
|
||||
$topBar.appendTo(document.body);
|
||||
|
||||
if (!hasPurchaseActions) {
|
||||
$bar = $topBar;
|
||||
return;
|
||||
}
|
||||
|
||||
// ----- 底部 Bar(仅操作按钮)-----
|
||||
$bottomBar = $("<div/>", {
|
||||
class: "esun-sticky-product-bar esun-sticky-product-bar--bottom",
|
||||
"data-role": "esun-sticky-product-bar-bottom",
|
||||
});
|
||||
var $actions = $("<div/>", {
|
||||
class: "esun-sticky-product-bar__actions",
|
||||
});
|
||||
$actions
|
||||
.append(
|
||||
$("<strong/>", {
|
||||
class: "esun-sticky-product-bar__price",
|
||||
"data-role": "esun-sticky-product-price",
|
||||
}),
|
||||
)
|
||||
.append(
|
||||
$("<button/>", {
|
||||
type: "button",
|
||||
class: "action primary tocart esun-sticky-product-bar__add",
|
||||
"data-role": "esun-sticky-add-to-cart",
|
||||
text: $t("Add to Cart"),
|
||||
}),
|
||||
)
|
||||
.append(
|
||||
$("<button/>", {
|
||||
type: "button",
|
||||
class: "action primary esun-buy-now esun-sticky-product-bar__buy",
|
||||
"data-role": "esun-sticky-buy-now",
|
||||
text: $t("Buy Now"),
|
||||
}),
|
||||
);
|
||||
$bottomBar.append($actions).appendTo(document.body);
|
||||
$bar = $topBar.add($bottomBar);
|
||||
}
|
||||
|
||||
function createInlineBar() {
|
||||
var $detailContent = $(detailContentSelector).first();
|
||||
|
||||
if (!$detailContent.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$inlineBar = createProductBar(
|
||||
"esun-detail-product-bar",
|
||||
"esun-detail-product-bar",
|
||||
);
|
||||
$inlineNav = $inlineBar.find(
|
||||
'[data-role="esun-product-anchor-nav"]',
|
||||
);
|
||||
$inlineBar.prependTo($detailContent);
|
||||
}
|
||||
|
||||
createStickyBar();
|
||||
createInlineBar();
|
||||
buildAnchors();
|
||||
syncPrice();
|
||||
syncButtonState();
|
||||
refreshOffsets();
|
||||
|
||||
$bar.add($inlineBar).on(
|
||||
"click",
|
||||
'[data-role="esun-sticky-add-to-cart"]',
|
||||
function () {
|
||||
$(addToCartSelector).first().trigger("click");
|
||||
},
|
||||
);
|
||||
|
||||
$bar.add($inlineBar).on(
|
||||
"click",
|
||||
'[data-role="esun-sticky-buy-now"]',
|
||||
function () {
|
||||
$(buyNowSelector).first().trigger("click");
|
||||
},
|
||||
);
|
||||
|
||||
$bar.add($inlineBar).on(
|
||||
"click",
|
||||
".esun-product-anchor-nav__link",
|
||||
function (event) {
|
||||
var id = $(this).attr("href").replace("#", ""),
|
||||
$target = $("#" + $.escapeSelector(id)),
|
||||
top;
|
||||
|
||||
if (!$target.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
top = Math.max(
|
||||
0,
|
||||
$target.offset().top - ($bar.outerHeight() || 0) - 16,
|
||||
);
|
||||
$("html, body").animate({ scrollTop: top }, 240);
|
||||
},
|
||||
);
|
||||
|
||||
$window.on("scroll", requestUpdate);
|
||||
$window.on("resize", function () {
|
||||
window.clearTimeout(resizeTimer);
|
||||
resizeTimer = window.setTimeout(function () {
|
||||
refreshOffsets();
|
||||
buildAnchors();
|
||||
}, 120);
|
||||
});
|
||||
|
||||
$(document).on(
|
||||
"input change",
|
||||
'#qty, .super-attribute-select, [name="selected_configurable_option"]',
|
||||
function () {
|
||||
window.setTimeout(function () {
|
||||
syncPrice();
|
||||
syncButtonState();
|
||||
refreshOffsets();
|
||||
}, 80);
|
||||
},
|
||||
);
|
||||
|
||||
if (window.MutationObserver) {
|
||||
new window.MutationObserver(function () {
|
||||
syncPrice();
|
||||
syncButtonState();
|
||||
}).observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
attributes: true,
|
||||
attributeFilter: ["disabled", "class"],
|
||||
});
|
||||
}
|
||||
|
||||
window.setTimeout(function () {
|
||||
buildAnchors();
|
||||
refreshOffsets();
|
||||
}, 800);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,122 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Customer/js/customer-data',
|
||||
'mage/translate',
|
||||
'mage/cookies'
|
||||
], function ($, customerData, $t) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $button = $(element),
|
||||
pending = false;
|
||||
|
||||
function setActive(active) {
|
||||
var label = active ? $t('Added to Wish List') : $t('Add to Wish List');
|
||||
|
||||
$button
|
||||
.toggleClass('is-active', active)
|
||||
.attr({
|
||||
'aria-label': label,
|
||||
'aria-pressed': active ? 'true' : 'false',
|
||||
title: label
|
||||
});
|
||||
$button.find('.iconfont')
|
||||
.toggleClass('icon-favorite5', active)
|
||||
.toggleClass('icon-favorite6', !active);
|
||||
$button.find('.esun-product-wishlist__label').text(label);
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
customerData.set('messages', {
|
||||
messages: [{
|
||||
type: 'error',
|
||||
text: message
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
function refreshActiveState() {
|
||||
if (!config.statusUrl || !config.productId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON(config.statusUrl, {
|
||||
product_id: config.productId,
|
||||
_: Date.now()
|
||||
}).done(function (response) {
|
||||
setActive(response && response.active === true);
|
||||
});
|
||||
}
|
||||
|
||||
function addToWishlist(event) {
|
||||
var params,
|
||||
requestData;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
if (pending || $button.hasClass('is-active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Magento's addToWishlist widget keeps data-post in sync with the
|
||||
// selected configurable, bundle, custom-option and quantity values.
|
||||
params = $button.data('post');
|
||||
if (!params || !params.action || !params.data) {
|
||||
showError($t('Unable to add this product to your wish list.'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
requestData = $.extend({}, params.data, {
|
||||
form_key: $.mage.cookies.get('form_key')
|
||||
});
|
||||
// The mix builder intentionally keeps the cart quantity at zero
|
||||
// until variants are selected. Wishlist quantity is independent
|
||||
// and must never submit that zero value.
|
||||
requestData.qty = Math.max(1, parseInt(requestData.qty, 10) || 1);
|
||||
pending = true;
|
||||
$button.addClass('is-loading').attr('aria-busy', 'true');
|
||||
|
||||
$.ajax({
|
||||
url: params.action,
|
||||
type: 'POST',
|
||||
data: requestData,
|
||||
dataType: 'json'
|
||||
}).done(function () {
|
||||
$button
|
||||
.removeClass('is-loading')
|
||||
.attr('aria-busy', 'false');
|
||||
setActive(true);
|
||||
customerData.invalidate(['wishlist']);
|
||||
customerData.reload(['wishlist'], true);
|
||||
refreshActiveState();
|
||||
}).fail(function (xhr) {
|
||||
var responseUrl = xhr.responseURL || '';
|
||||
|
||||
$button.removeClass('is-loading').attr('aria-busy', 'false');
|
||||
|
||||
// A guest AJAX request follows Magento's login redirect and then
|
||||
// fails JSON parsing with a final HTTP 200 response.
|
||||
if (xhr.status === 200 || xhr.status === 401 ||
|
||||
responseUrl.indexOf('/customer/account/login') !== -1) {
|
||||
window.location.href = config.loginUrl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
showError($t('Unable to add this product to your wish list. Please try again.'));
|
||||
}).always(function () {
|
||||
pending = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Capture the click before Magento's data-post handler can turn it into
|
||||
// a normal form submission. Option-change handlers still update data-post.
|
||||
// The product-specific endpoint is authoritative. Customer-data can be
|
||||
// stale during page initialization and must not turn an active heart
|
||||
// back into an outline.
|
||||
refreshActiveState();
|
||||
element.addEventListener('click', addToWishlist, true);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,660 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Catalog/js/price-utils',
|
||||
'Magento_Customer/js/customer-data',
|
||||
'mage/translate'
|
||||
], function ($, priceUtils, customerData) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $progress = $(element),
|
||||
products = config.products || {},
|
||||
priceFormat = config.priceFormat || {},
|
||||
activeProductId = config.defaultProductId,
|
||||
swatchSelector = '.swatch-opt',
|
||||
qtySelector = '#qty',
|
||||
totalSelector = '.esun-purchase-total',
|
||||
cartState = customerData.get('cart')() || {},
|
||||
mixCartHydrated = false,
|
||||
mixUserEdited = false,
|
||||
hasExistingMixItems = false;
|
||||
|
||||
function getMixMilestones() {
|
||||
var mix = config.mix || {},
|
||||
milestones = [];
|
||||
|
||||
$.each(mix.tiers || [], function (_, tier) {
|
||||
milestones.push({
|
||||
type: tier.price_type === 'fixed' ? 'fixed' : 'percent',
|
||||
qty: parseInt(tier.qty, 10),
|
||||
value: Number(tier.value),
|
||||
displayValue: Number(tier.display_value)
|
||||
});
|
||||
});
|
||||
milestones.sort(function (left, right) {
|
||||
return left.qty - right.qty;
|
||||
});
|
||||
|
||||
return milestones;
|
||||
}
|
||||
|
||||
function getActiveMixTier(quantity) {
|
||||
var active = null;
|
||||
|
||||
$.each((config.mix || {}).tiers || [], function (_, tier) {
|
||||
if (quantity >= parseInt(tier.qty, 10)) {
|
||||
active = tier;
|
||||
}
|
||||
});
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
function getMixUnitPrice(basePrice, tier) {
|
||||
if (!tier) {
|
||||
return basePrice;
|
||||
}
|
||||
if (tier.price_type === 'fixed') {
|
||||
return Math.min(basePrice, Number(tier.display_value));
|
||||
}
|
||||
|
||||
return basePrice * (1 - Number(tier.value) / 100);
|
||||
}
|
||||
|
||||
function getMixTierLabel(tier) {
|
||||
if (!tier) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return tier.price_type === 'fixed'
|
||||
? formatPrice(Number(tier.display_value))
|
||||
: Number(tier.value) + '% ' + $.mage.__('off');
|
||||
}
|
||||
|
||||
function renderMixMilestones(quantity) {
|
||||
var milestones = getMixMilestones(),
|
||||
$steps = $progress.find('[data-role="progress-steps"]'),
|
||||
percent = getProgressPercent(milestones, quantity);
|
||||
|
||||
$progress.find('[data-role="progress-track"]').css('--esun-progress-width', percent + '%');
|
||||
$steps.empty();
|
||||
$.each(milestones, function (_, milestone) {
|
||||
var active = quantity >= milestone.qty,
|
||||
$step = $('<div/>', {
|
||||
'class': 'esun-purchase-progress__step' + (active ? ' is-active' : '')
|
||||
}),
|
||||
value = milestone.type === 'fixed'
|
||||
? formatPrice(milestone.displayValue)
|
||||
: milestone.value + '% ' + $.mage.__('off');
|
||||
$step.append(
|
||||
$('<span/>', {'class': 'esun-purchase-progress__marker'}),
|
||||
$('<span/>', {'class': 'esun-purchase-progress__value'}).text(value),
|
||||
$('<span/>', {'class': 'esun-purchase-progress__label'}).text(
|
||||
milestone.qty + ' ' + $.mage.__('pcs')
|
||||
)
|
||||
);
|
||||
$steps.append($step);
|
||||
});
|
||||
}
|
||||
|
||||
function renderMix() {
|
||||
var quantity = 0,
|
||||
selectedVariants = 0,
|
||||
baseTotal = 0,
|
||||
finalTotal = 0,
|
||||
activeTier,
|
||||
nextTier = null,
|
||||
$builder = $('[data-role="esun-mix-builder"]'),
|
||||
$button = $('#product-addtocart-button');
|
||||
|
||||
$builder.find('[data-role="mix-item-qty"]').each(function () {
|
||||
var $input = $(this),
|
||||
itemQuantity = Math.max(0, parseInt($input.val(), 10) || 0),
|
||||
basePrice = Number($input.attr('data-base-price'));
|
||||
|
||||
$input.val(itemQuantity);
|
||||
quantity += itemQuantity;
|
||||
selectedVariants += itemQuantity > 0 ? 1 : 0;
|
||||
baseTotal += basePrice * itemQuantity;
|
||||
});
|
||||
|
||||
activeTier = getActiveMixTier(quantity);
|
||||
$builder.find('[data-role="mix-item-qty"]').each(function () {
|
||||
var $input = $(this),
|
||||
itemQuantity = parseInt($input.val(), 10) || 0,
|
||||
basePrice = Number($input.attr('data-base-price')),
|
||||
unitPrice = getMixUnitPrice(basePrice, activeTier);
|
||||
|
||||
finalTotal += unitPrice * itemQuantity;
|
||||
});
|
||||
|
||||
$.each((config.mix || {}).tiers || [], function (_, tier) {
|
||||
if (nextTier === null && quantity < parseInt(tier.qty, 10)) {
|
||||
nextTier = tier;
|
||||
}
|
||||
});
|
||||
|
||||
renderMixMilestones(quantity);
|
||||
if (nextTier) {
|
||||
$progress.find('[data-role="mix-message"]').text(
|
||||
$.mage.__('Add') + ' ' + (parseInt(nextTier.qty, 10) - quantity) + ' ' +
|
||||
$.mage.__('more to unlock') + ' ' + getMixTierLabel(nextTier)
|
||||
);
|
||||
} else if (activeTier) {
|
||||
$progress.find('[data-role="mix-message"]').text(
|
||||
$.mage.__('Unlocked:') + ' ' + getMixTierLabel(activeTier)
|
||||
);
|
||||
}
|
||||
|
||||
$builder.find('[data-role="mix-selection-summary"]').text(
|
||||
quantity > 0
|
||||
? selectedVariants + ' ' + $.mage.__('colors') + ' · ' + quantity + ' ' + $.mage.__('items')
|
||||
: $.mage.__('Choose a color, then set its quantity.')
|
||||
);
|
||||
$builder.find('[data-role="mix-final-total"]').text(formatPrice(finalTotal));
|
||||
$builder.find('[data-role="mix-base-total"]')
|
||||
.text(baseTotal > finalTotal + 0.0001 ? formatPrice(baseTotal) : '')
|
||||
.toggle(baseTotal > finalTotal + 0.0001);
|
||||
$button.prop('disabled', quantity <= 0).find('span').text(
|
||||
quantity > 0
|
||||
? (hasExistingMixItems ? $.mage.__('Update') : $.mage.__('Add')) + ' ' +
|
||||
selectedVariants + ' ' + $.mage.__('variants') +
|
||||
' (' + quantity + ' ' + $.mage.__('items') + ')'
|
||||
: $.mage.__('Add Mix to Cart')
|
||||
);
|
||||
renderMixQuantityBadges();
|
||||
}
|
||||
|
||||
function initializeMixBuilder() {
|
||||
var $form = $progress.closest('form'),
|
||||
$builder = $('[data-role="esun-mix-builder"]'),
|
||||
$qty = $form.find(qtySelector);
|
||||
|
||||
$form.attr('action', config.mixAddUrl).attr('data-esun-mix-form', '1');
|
||||
$('.product-info-main').addClass('is-mix-pricing');
|
||||
|
||||
function updateSelectedColorQuantity() {
|
||||
var productId = getSelectedMixProductId(),
|
||||
quantity = Math.max(0, parseInt($qty.val(), 10) || 0),
|
||||
$input;
|
||||
|
||||
if (!productId) {
|
||||
$qty.val(0);
|
||||
return;
|
||||
}
|
||||
|
||||
mixUserEdited = true;
|
||||
$input = getMixQuantityInput(productId);
|
||||
$qty.val(quantity);
|
||||
$input.val(quantity).attr('data-configured', '1');
|
||||
renderMix();
|
||||
}
|
||||
|
||||
function refreshSelectedColor() {
|
||||
window.setTimeout(syncSharedMixQuantity, 0);
|
||||
window.setTimeout(syncSharedMixQuantity, 100);
|
||||
window.setTimeout(syncSharedMixQuantity, 250);
|
||||
}
|
||||
|
||||
$qty.on('input.esunMix change.esunMix', updateSelectedColorQuantity);
|
||||
customerData.get('cart').subscribe(function (cart) {
|
||||
cartState = cart || {};
|
||||
syncMixBuilderFromCart();
|
||||
});
|
||||
$(document).on('esun:cartUpdated.esunMixProgress', function (_, cart) {
|
||||
cartState = cart || {};
|
||||
syncMixBuilderFromCart();
|
||||
});
|
||||
$form.on(
|
||||
'click.esunMix change.esunMix configurable.initialized.esunMix swatch.initialized.esunMix',
|
||||
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"]',
|
||||
refreshSelectedColor
|
||||
);
|
||||
syncMixBuilderFromCart();
|
||||
refreshSelectedColor();
|
||||
}
|
||||
|
||||
function syncMixBuilderFromCart() {
|
||||
var cartQuantities,
|
||||
$builder;
|
||||
|
||||
if (mixUserEdited) {
|
||||
renderMixQuantityBadges();
|
||||
return;
|
||||
}
|
||||
|
||||
cartQuantities = getCartMixQuantities();
|
||||
$builder = $('[data-role="esun-mix-builder"]');
|
||||
hasExistingMixItems = Object.keys(cartQuantities).length > 0;
|
||||
mixCartHydrated = true;
|
||||
$builder.find('[data-role="mix-mode"]').val('sync');
|
||||
$builder.find('[data-role="mix-item-qty"]').each(function () {
|
||||
var $input = $(this),
|
||||
productId = String($input.attr('data-child-id'));
|
||||
|
||||
$input.val(cartQuantities[productId] || 0).attr('data-configured', '1');
|
||||
});
|
||||
renderMix();
|
||||
window.setTimeout(syncSharedMixQuantity, 0);
|
||||
}
|
||||
|
||||
function getMixQuantityInput(productId) {
|
||||
return $('[data-role="esun-mix-builder"] [data-role="mix-item-qty"][data-child-id="' +
|
||||
String(productId) + '"]');
|
||||
}
|
||||
|
||||
function getSelectedMixProductId() {
|
||||
var selectedProduct = $progress.closest('form').find('[name="selected_configurable_option"]').val(),
|
||||
swatchWidget = getSwatchWidget(),
|
||||
widgetProductId;
|
||||
|
||||
if (selectedProduct && getMixQuantityInput(selectedProduct).length) {
|
||||
return String(selectedProduct);
|
||||
}
|
||||
|
||||
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
|
||||
widgetProductId = swatchWidget.getProductId();
|
||||
if (widgetProductId && getMixQuantityInput(widgetProductId).length) {
|
||||
return String(widgetProductId);
|
||||
}
|
||||
}
|
||||
|
||||
return getExactProductIdFromOptions();
|
||||
}
|
||||
|
||||
function getExactProductIdFromOptions() {
|
||||
var jsonConfig = getJsonConfig(),
|
||||
selectedOptions = {},
|
||||
attributeCount = 0,
|
||||
matchedProductId = null;
|
||||
|
||||
if (!jsonConfig || !jsonConfig.index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$progress.closest('form')
|
||||
.find('.swatch-attribute[data-attribute-id], .swatch-attribute[attribute-id]')
|
||||
.each(function () {
|
||||
var $attribute = $(this),
|
||||
attributeId = String(
|
||||
$attribute.attr('data-attribute-id') || $attribute.attr('attribute-id') || ''
|
||||
),
|
||||
optionId = $attribute.find('.swatch-option.selected').attr('data-option-id') ||
|
||||
$attribute.find('.swatch-option.selected').attr('option-id') ||
|
||||
$attribute.find('.super-attribute-select').val();
|
||||
|
||||
attributeCount += 1;
|
||||
if (optionId) {
|
||||
selectedOptions[attributeId] = String(optionId);
|
||||
}
|
||||
});
|
||||
|
||||
if (!attributeCount || Object.keys(selectedOptions).length !== attributeCount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$.each(jsonConfig.index, function (productId, productOptions) {
|
||||
var isMatch = true;
|
||||
|
||||
$.each(selectedOptions, function (attributeId, optionId) {
|
||||
if (String(productOptions[attributeId]) !== optionId) {
|
||||
isMatch = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (isMatch && getMixQuantityInput(productId).length) {
|
||||
matchedProductId = String(productId);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return matchedProductId;
|
||||
}
|
||||
|
||||
function syncSharedMixQuantity() {
|
||||
var productId = getSelectedMixProductId(),
|
||||
$qty = $progress.closest('form').find(qtySelector),
|
||||
$input = productId ? getMixQuantityInput(productId) : $(),
|
||||
quantity = 0;
|
||||
|
||||
if ($input.length) {
|
||||
if ($input.attr('data-configured') !== '1') {
|
||||
$input.val(0).attr('data-configured', '1');
|
||||
renderMix();
|
||||
}
|
||||
quantity = Math.max(0, parseInt($input.val(), 10) || 0);
|
||||
}
|
||||
$qty.prop('disabled', !$input.length).val(quantity);
|
||||
$progress.closest('form').find('.box-tocart .field.qty')
|
||||
.toggleClass('is-awaiting-color', !$input.length);
|
||||
renderMixQuantityBadges();
|
||||
}
|
||||
|
||||
function renderMixQuantityBadges() {
|
||||
var jsonConfig = getJsonConfig(),
|
||||
$colorAttribute = $progress.closest('form').find('.swatch-attribute.color').first(),
|
||||
attributeId = String(
|
||||
$colorAttribute.attr('data-attribute-id') || $colorAttribute.attr('attribute-id') || ''
|
||||
),
|
||||
quantitiesByOption = {},
|
||||
cartQuantities = getCartMixQuantities();
|
||||
|
||||
if (!$colorAttribute.length || !attributeId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('[data-role="esun-mix-builder"] [data-role="mix-item-qty"]').each(function () {
|
||||
var $input = $(this),
|
||||
productId = String($input.attr('data-child-id')),
|
||||
quantity = Math.max(0, parseInt($input.val(), 10) || 0) +
|
||||
(mixCartHydrated ? 0 : (cartQuantities[productId] || 0)),
|
||||
productOptions = $input.data('options') ||
|
||||
(jsonConfig && jsonConfig.index ? jsonConfig.index[productId] : {}) || {},
|
||||
optionId = productOptions[attributeId];
|
||||
|
||||
if (quantity > 0 && typeof optionId !== 'undefined') {
|
||||
optionId = String(optionId);
|
||||
quantitiesByOption[optionId] = (quantitiesByOption[optionId] || 0) + quantity;
|
||||
}
|
||||
});
|
||||
|
||||
$colorAttribute.find('.swatch-option').each(function () {
|
||||
var $option = $(this),
|
||||
optionId = String(
|
||||
$option.attr('data-option-id') || $option.attr('option-id') || ''
|
||||
),
|
||||
quantity = quantitiesByOption[optionId] || 0;
|
||||
|
||||
$option.find('.esun-mix-qty-badge').remove();
|
||||
if (!quantity) {
|
||||
$option.removeAttr('data-mix-qty');
|
||||
return;
|
||||
}
|
||||
$option.attr('data-mix-qty', quantity);
|
||||
});
|
||||
}
|
||||
|
||||
function getCartMixQuantities() {
|
||||
var cart = cartState,
|
||||
parentId = Number((config.mix || {}).parentId || 0),
|
||||
quantities = {};
|
||||
|
||||
$.each(cart.items || [], function (_, item) {
|
||||
var itemParentId = Number(item.parent_product_id || item.product_id || 0),
|
||||
childId = String(item.child_product_id || ''),
|
||||
quantity = Math.max(0, Number(item.qty) || 0);
|
||||
|
||||
if (itemParentId === parentId && childId && quantity > 0) {
|
||||
quantities[childId] = (quantities[childId] || 0) + quantity;
|
||||
}
|
||||
});
|
||||
|
||||
return quantities;
|
||||
}
|
||||
|
||||
function getSwatchWidget() {
|
||||
var $swatch = $progress.closest('form').find(swatchSelector);
|
||||
|
||||
return $swatch.data('mageSwatchRenderer') || $swatch.data('mage-SwatchRenderer');
|
||||
}
|
||||
|
||||
function getJsonConfig() {
|
||||
var swatchWidget = getSwatchWidget();
|
||||
|
||||
return swatchWidget && swatchWidget.options && swatchWidget.options.jsonConfig;
|
||||
}
|
||||
|
||||
function getSelectedProductIdFromSwatches() {
|
||||
var jsonConfig = getJsonConfig(),
|
||||
selectedOptions = {},
|
||||
matchedProductId = null;
|
||||
|
||||
if (!jsonConfig || !jsonConfig.index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$progress.closest('form').find('.swatch-attribute').each(function () {
|
||||
var $attribute = $(this),
|
||||
attributeId = $attribute.attr('data-attribute-id') ||
|
||||
$attribute.attr('attribute-id') || $attribute.data('attribute-id'),
|
||||
optionId = $attribute.find('.swatch-option.selected').attr('data-option-id') ||
|
||||
$attribute.find('.swatch-option.selected').attr('option-id') ||
|
||||
$attribute.find('.swatch-option.selected').data('option-id') ||
|
||||
$attribute.find('.super-attribute-select').val();
|
||||
|
||||
if (attributeId && optionId) {
|
||||
selectedOptions[attributeId] = String(optionId);
|
||||
}
|
||||
});
|
||||
|
||||
$.each(jsonConfig.index, function (productId, productOptions) {
|
||||
var isMatch = true;
|
||||
|
||||
$.each(selectedOptions, function (attributeId, optionId) {
|
||||
if (String(productOptions[attributeId]) !== optionId) {
|
||||
isMatch = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (isMatch && Object.keys(selectedOptions).length) {
|
||||
matchedProductId = productId;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return matchedProductId;
|
||||
}
|
||||
|
||||
function getSelectedProductId() {
|
||||
var selectedProduct = $progress.closest('form').find('[name="selected_configurable_option"]').val(),
|
||||
swatchWidget;
|
||||
|
||||
if (selectedProduct && products[selectedProduct]) {
|
||||
return selectedProduct;
|
||||
}
|
||||
|
||||
swatchWidget = getSwatchWidget();
|
||||
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
|
||||
selectedProduct = swatchWidget.getProductId();
|
||||
if (selectedProduct && products[selectedProduct]) {
|
||||
return selectedProduct;
|
||||
}
|
||||
}
|
||||
|
||||
selectedProduct = getSelectedProductIdFromSwatches();
|
||||
if (selectedProduct && products[selectedProduct]) {
|
||||
return selectedProduct;
|
||||
}
|
||||
|
||||
return activeProductId;
|
||||
}
|
||||
|
||||
function getQty() {
|
||||
var $qty = $(qtySelector),
|
||||
min = parseInt($qty.attr('min'), 10) || 1,
|
||||
qty = parseInt($qty.val(), 10);
|
||||
|
||||
if (!qty || qty < min) {
|
||||
qty = min;
|
||||
$qty.val(qty);
|
||||
}
|
||||
|
||||
return qty;
|
||||
}
|
||||
|
||||
function formatPrice(amount) {
|
||||
return priceUtils.formatPrice(amount, priceFormat);
|
||||
}
|
||||
|
||||
function getMilestones(productConfig) {
|
||||
var milestones = [];
|
||||
|
||||
$.each(productConfig.tiers || [], function (_, tier) {
|
||||
milestones.push({
|
||||
type: 'tier',
|
||||
qty: parseInt(tier.qty, 10),
|
||||
price: Number(tier.price),
|
||||
percentage: tier.percentage !== null && typeof tier.percentage !== 'undefined'
|
||||
? Number(tier.percentage)
|
||||
: null
|
||||
});
|
||||
});
|
||||
|
||||
milestones = milestones.filter(function (milestone) {
|
||||
return milestone.qty > 1;
|
||||
});
|
||||
|
||||
milestones.sort(function (a, b) {
|
||||
return a.qty - b.qty;
|
||||
});
|
||||
|
||||
return milestones;
|
||||
}
|
||||
|
||||
function getActiveTier(productConfig, qty) {
|
||||
var activeTier = null;
|
||||
|
||||
$.each(productConfig.tiers || [], function (_, tier) {
|
||||
if (qty >= parseInt(tier.qty, 10)) {
|
||||
activeTier = tier;
|
||||
}
|
||||
});
|
||||
|
||||
return activeTier;
|
||||
}
|
||||
|
||||
function getUnitFinalPrice(productConfig, qty) {
|
||||
return Number(productConfig.finalPrice);
|
||||
}
|
||||
|
||||
function getProgressPercent(milestones, qty) {
|
||||
var count = milestones.length,
|
||||
firstQty,
|
||||
firstPosition,
|
||||
previous,
|
||||
current,
|
||||
previousPosition,
|
||||
currentPosition,
|
||||
index,
|
||||
ratio;
|
||||
|
||||
if (!count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
firstQty = milestones[0].qty;
|
||||
firstPosition = 50 / count;
|
||||
|
||||
if (qty <= firstQty) {
|
||||
return Math.max(0, Math.min(firstPosition, qty / firstQty * firstPosition));
|
||||
}
|
||||
|
||||
for (index = 1; index < count; index += 1) {
|
||||
previous = milestones[index - 1];
|
||||
current = milestones[index];
|
||||
|
||||
if (qty <= current.qty) {
|
||||
previousPosition = (index - 0.5) / count * 100;
|
||||
currentPosition = (index + 0.5) / count * 100;
|
||||
ratio = (qty - previous.qty) / (current.qty - previous.qty);
|
||||
|
||||
return previousPosition + ratio * (currentPosition - previousPosition);
|
||||
}
|
||||
}
|
||||
|
||||
return qty === milestones[count - 1].qty
|
||||
? (count - 0.5) / count * 100
|
||||
: 100;
|
||||
}
|
||||
|
||||
function getTotalElement() {
|
||||
var $total = $(totalSelector),
|
||||
$qty = $('.box-tocart .field.qty');
|
||||
|
||||
if (!$total.length && $qty.length) {
|
||||
$total = $('<div/>', {
|
||||
'class': 'esun-purchase-total',
|
||||
'aria-live': 'polite'
|
||||
}).append(
|
||||
$('<strong/>', {'data-role': 'purchase-final-total'}),
|
||||
$('<span/>', {'data-role': 'purchase-base-total'})
|
||||
);
|
||||
$qty.after($total);
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function renderMilestones(productConfig, qty) {
|
||||
var milestones = getMilestones(productConfig),
|
||||
$steps = $progress.find('[data-role="progress-steps"]'),
|
||||
percent = getProgressPercent(milestones, qty);
|
||||
|
||||
$progress.find('[data-role="progress-track"]').css('--esun-progress-width', percent + '%');
|
||||
$steps.empty();
|
||||
|
||||
$.each(milestones, function (_, milestone) {
|
||||
var active = qty >= milestone.qty,
|
||||
$step = $('<div/>', {
|
||||
'class': 'esun-purchase-progress__step' + (active ? ' is-active' : '')
|
||||
}),
|
||||
$marker = $('<span/>', {'class': 'esun-purchase-progress__marker'}),
|
||||
$value = $('<span/>', {'class': 'esun-purchase-progress__value'}),
|
||||
$label = $('<span/>', {'class': 'esun-purchase-progress__label'});
|
||||
|
||||
$value.text(formatPrice(milestone.price));
|
||||
$label.text(milestone.qty + ' pcs' +
|
||||
(milestone.percentage ? ' ' + milestone.percentage + '% off' : ''));
|
||||
|
||||
$step.append($marker, $value, $label);
|
||||
$steps.append($step);
|
||||
});
|
||||
|
||||
$progress.toggle(milestones.length > 0);
|
||||
}
|
||||
|
||||
function renderTotals(productConfig, qty) {
|
||||
var $total = getTotalElement(),
|
||||
finalTotal = getUnitFinalPrice(productConfig, qty) * qty,
|
||||
baseTotal = Number(productConfig.basePrice) * qty;
|
||||
|
||||
$total.find('[data-role="purchase-final-total"]').text(formatPrice(finalTotal));
|
||||
$total.find('[data-role="purchase-base-total"]').text(formatPrice(baseTotal));
|
||||
$total.toggle(baseTotal > 0);
|
||||
}
|
||||
|
||||
function render() {
|
||||
var productId = getSelectedProductId(),
|
||||
productConfig = products[productId] || products[activeProductId],
|
||||
qty = getQty();
|
||||
|
||||
if (!productConfig) {
|
||||
$progress.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
activeProductId = productId;
|
||||
renderMilestones(productConfig, qty);
|
||||
renderTotals(productConfig, qty);
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
window.setTimeout(render, 50);
|
||||
window.setTimeout(render, 250);
|
||||
}
|
||||
|
||||
if (config.mixEnabled && config.mix && (config.mix.items || []).length) {
|
||||
initializeMixBuilder();
|
||||
return;
|
||||
}
|
||||
|
||||
render();
|
||||
|
||||
$(document).on(
|
||||
'click change input updatePrice priceUpdated configurable.initialized swatch.initialized',
|
||||
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"], ' + qtySelector + ', .price-box',
|
||||
refresh
|
||||
);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
define(["jquery"], function ($) {
|
||||
"use strict";
|
||||
|
||||
return function (config, element) {
|
||||
var $input = $(element),
|
||||
$form = $input.closest("form");
|
||||
|
||||
function getMin() {
|
||||
var min = parseFloat($input.attr("min"));
|
||||
|
||||
return isNaN(min) ? 1 : min;
|
||||
}
|
||||
|
||||
function normalizeQty() {
|
||||
var min = getMin();
|
||||
var val = parseFloat($input.val());
|
||||
|
||||
if (isNaN(val) || val < min) {
|
||||
val = min;
|
||||
}
|
||||
|
||||
$input.val(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
if (!$input.length || !$form.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form.off(".esunQtyStepper", '[data-role="qty-minus"], [data-role="qty-plus"]');
|
||||
$input.off(".esunQtyStepper");
|
||||
|
||||
$form.on("click.esunQtyStepper", '[data-role="qty-minus"]', function () {
|
||||
var min = getMin();
|
||||
var val = normalizeQty();
|
||||
|
||||
if (val > min) {
|
||||
$input.val(val - 1).trigger("change");
|
||||
}
|
||||
});
|
||||
|
||||
$form.on("click.esunQtyStepper", '[data-role="qty-plus"]', function () {
|
||||
var val = normalizeQty();
|
||||
|
||||
$input.val(val + 1).trigger("change");
|
||||
});
|
||||
|
||||
$input.on("input.esunQtyStepper keyup.esunQtyStepper change.esunQtyStepper blur.esunQtyStepper", function () {
|
||||
normalizeQty();
|
||||
});
|
||||
|
||||
normalizeQty();
|
||||
};
|
||||
});
|
||||
@@ -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,47 @@
|
||||
define(['Swiper'], function (Swiper) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var slider = element.querySelector('.esun-recommended-products__slider');
|
||||
|
||||
if (!slider) {
|
||||
return;
|
||||
}
|
||||
|
||||
new Swiper(slider, {
|
||||
slidesPerView: 1.08,
|
||||
spaceBetween: 14,
|
||||
allowTouchMove: true,
|
||||
simulateTouch: true,
|
||||
grabCursor: true,
|
||||
slidesPerGroup: 1,
|
||||
speed: 450,
|
||||
roundLengths: true,
|
||||
watchOverflow: true,
|
||||
observer: true,
|
||||
observeParents: true,
|
||||
resizeObserver: true,
|
||||
keyboard: {
|
||||
enabled: true
|
||||
},
|
||||
navigation: {
|
||||
prevEl: element.querySelector('.esun-recommended-products__previous'),
|
||||
nextEl: element.querySelector('.esun-recommended-products__next')
|
||||
},
|
||||
breakpoints: {
|
||||
480: {
|
||||
slidesPerView: 1.35,
|
||||
spaceBetween: 16
|
||||
},
|
||||
768: {
|
||||
slidesPerView: 1.65,
|
||||
spaceBetween: 20
|
||||
},
|
||||
1200: {
|
||||
slidesPerView: 2,
|
||||
spaceBetween: 24
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user