init
This commit is contained in:
+9
@@ -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_product_inquiry_listing"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+11
@@ -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\ProductInquiry\Block\Adminhtml\Inquiry\View"
|
||||
name="esun.product.inquiry.view"
|
||||
template="Esun_ProductInquiry::inquiry/view.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/** @var \Esun\ProductInquiry\Block\Adminhtml\Inquiry\View $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$inquiry = $block->getInquiry();
|
||||
?>
|
||||
<div class="admin__page-section">
|
||||
<div class="admin__page-section-title"><span class="title"><?= $escaper->escapeHtml(__('Product')) ?></span></div>
|
||||
<div class="admin__page-section-content">
|
||||
<table class="admin__table-secondary">
|
||||
<tr><th><?= $escaper->escapeHtml(__('Product')) ?></th><td><?= $escaper->escapeHtml((string)$inquiry->getData('parent_name')) ?> (<?= $escaper->escapeHtml((string)$inquiry->getData('parent_sku')) ?>)</td></tr>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Selected SKU')) ?></th><td><?= $escaper->escapeHtml((string)$inquiry->getData('product_sku')) ?></td></tr>
|
||||
<?php foreach ($block->getSelectedOptions() as $option): ?>
|
||||
<tr><th><?= $escaper->escapeHtml((string)($option['label'] ?? '')) ?></th><td><?= $escaper->escapeHtml((string)($option['value'] ?? '')) ?></td></tr>
|
||||
<?php endforeach; ?>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Availability at Submission')) ?></th><td><?= $escaper->escapeHtml($block->getAvailabilityLabel()) ?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__page-section">
|
||||
<div class="admin__page-section-title"><span class="title"><?= $escaper->escapeHtml(__('Contact Information')) ?></span></div>
|
||||
<div class="admin__page-section-content">
|
||||
<table class="admin__table-secondary">
|
||||
<tr><th><?= $escaper->escapeHtml(__('Name')) ?></th><td><?= $escaper->escapeHtml((string)$inquiry->getData('name')) ?></td></tr>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Email')) ?></th><td><a href="mailto:<?= $escaper->escapeHtmlAttr((string)$inquiry->getData('email')) ?>"><?= $escaper->escapeHtml((string)$inquiry->getData('email')) ?></a></td></tr>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Country')) ?></th><td><?= $escaper->escapeHtml((string)$inquiry->getData('country_name')) ?></td></tr>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Company Name')) ?></th><td><?= $escaper->escapeHtml((string)$inquiry->getData('company')) ?: '—' ?></td></tr>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Telephone')) ?></th><td><?= $escaper->escapeHtml((string)$inquiry->getData('telephone')) ?: '—' ?></td></tr>
|
||||
<tr><th><?= $escaper->escapeHtml(__('Inquiry Time')) ?></th><td><?= $escaper->escapeHtml($block->getFormattedCreatedAt()) ?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__page-section">
|
||||
<div class="admin__page-section-title"><span class="title"><?= $escaper->escapeHtml(__('Message')) ?></span></div>
|
||||
<div class="admin__page-section-content">
|
||||
<div style="white-space:pre-wrap;max-width:1000px"><?= $escaper->escapeHtml((string)$inquiry->getData('message')) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin__page-section">
|
||||
<form method="post" action="<?= $escaper->escapeUrl($block->getUrl('esun_product_inquiry/inquiry/saveStatus')) ?>">
|
||||
<?= /* @noEscape */ $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="id" value="<?= (int)$inquiry->getId() ?>"/>
|
||||
<label class="admin__field-label" for="inquiry-status"><span><?= $escaper->escapeHtml(__('Status')) ?></span></label>
|
||||
<select class="admin__control-select" id="inquiry-status" name="status">
|
||||
<?php foreach ($block->getStatusOptions() as $value => $label): ?>
|
||||
<option value="<?= $escaper->escapeHtmlAttr($value) ?>" <?= $inquiry->getData('status') === $value ? 'selected' : '' ?>><?= $escaper->escapeHtml($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button type="submit" class="action-primary"><span><?= $escaper->escapeHtml(__('Save Status')) ?></span></button>
|
||||
<a class="action-secondary" href="<?= $escaper->escapeUrl($block->getUrl('esun_product_inquiry/inquiry/index')) ?>"><?= $escaper->escapeHtml(__('Back')) ?></a>
|
||||
</form>
|
||||
</div>
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0"?>
|
||||
<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_product_inquiry_listing.esun_product_inquiry_listing_data_source</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<spinner>esun_product_inquiry_columns</spinner>
|
||||
<deps><dep>esun_product_inquiry_listing.esun_product_inquiry_listing_data_source</dep></deps>
|
||||
</settings>
|
||||
<dataSource name="esun_product_inquiry_listing_data_source" component="Magento_Ui/js/grid/provider">
|
||||
<settings>
|
||||
<storageConfig><param name="indexField" xsi:type="string">entity_id</param></storageConfig>
|
||||
<updateUrl path="mui/index/render"/>
|
||||
</settings>
|
||||
<aclResource>Esun_ProductInquiry::inquiries</aclResource>
|
||||
<dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"
|
||||
name="esun_product_inquiry_listing_data_source">
|
||||
<settings><requestFieldName>id</requestFieldName><primaryFieldName>entity_id</primaryFieldName></settings>
|
||||
</dataProvider>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings><sticky>true</sticky></settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<filters name="listing_filters"/>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="esun_product_inquiry_columns">
|
||||
<column name="entity_id">
|
||||
<settings><filter>textRange</filter><label translate="true">ID</label><sorting>desc</sorting></settings>
|
||||
</column>
|
||||
<column name="status" component="Magento_Ui/js/grid/columns/select">
|
||||
<settings>
|
||||
<filter>select</filter><dataType>select</dataType>
|
||||
<options class="Esun\ProductInquiry\Model\Source\Status"/>
|
||||
<label translate="true">Status</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="parent_name"><settings><filter>text</filter><label translate="true">Product</label></settings></column>
|
||||
<column name="product_sku"><settings><filter>text</filter><label translate="true">Selected SKU</label></settings></column>
|
||||
<column name="name"><settings><filter>text</filter><label translate="true">Name</label></settings></column>
|
||||
<column name="email"><settings><filter>text</filter><label translate="true">Email</label></settings></column>
|
||||
<column name="country_name"><settings><filter>text</filter><label translate="true">Country</label></settings></column>
|
||||
<column name="company"><settings><filter>text</filter><label translate="true">Company Name</label></settings></column>
|
||||
<column name="telephone"><settings><filter>text</filter><label translate="true">Telephone</label></settings></column>
|
||||
<column name="created_at"
|
||||
class="Esun\ProductInquiry\Ui\Component\Listing\Column\DateWithTimezone"
|
||||
component="Esun_ProductInquiry/js/grid/columns/date-with-timezone">
|
||||
<settings><filter>dateRange</filter><dataType>date</dataType><label translate="true">Inquiry Time</label></settings>
|
||||
</column>
|
||||
<actionsColumn name="actions" class="Esun\ProductInquiry\Ui\Component\Listing\Column\InquiryActions">
|
||||
<settings><indexField>entity_id</indexField><resizeEnabled>false</resizeEnabled><resizeDefaultWidth>100</resizeDefaultWidth></settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
@@ -0,0 +1,14 @@
|
||||
define([
|
||||
'Magento_Ui/js/grid/columns/date'
|
||||
], function (DateColumn) {
|
||||
'use strict';
|
||||
|
||||
return DateColumn.extend({
|
||||
getLabel: function (value, format) {
|
||||
var label = this._super(value, format),
|
||||
timezone = value[this.timezoneField];
|
||||
|
||||
return label && timezone ? label + ' (' + timezone + ')' : label;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -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">
|
||||
<head>
|
||||
<css src="Esun_ProductInquiry::css/product-inquiry.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceContainer name="before.body.end">
|
||||
<block class="Esun\ProductInquiry\Block\ProductInquiry"
|
||||
name="esun.product.inquiry.modal"
|
||||
template="Esun_ProductInquiry::product/inquiry.phtml"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?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="product.info"
|
||||
template="Esun_ProductInquiry::product/view/form.phtml"/>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,12 @@
|
||||
var config = {
|
||||
config: {
|
||||
mixins: {
|
||||
'Magento_Swatches/js/swatch-renderer': {
|
||||
'Esun_ProductInquiry/js/swatch-renderer-mixin': true
|
||||
},
|
||||
'Magento_ConfigurableProduct/js/configurable': {
|
||||
'Esun_ProductInquiry/js/configurable-mixin': true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/** @var \Esun\ProductInquiry\Block\ProductInquiry $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
if (!$block->canRender()) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="esun-product-inquiry" data-role="product-inquiry-modal" style="display:none">
|
||||
<form class="esun-product-inquiry__form"
|
||||
action="<?= $escaper->escapeUrl($block->getUrl('product-inquiry/index/post')) ?>"
|
||||
method="post"
|
||||
novalidate>
|
||||
<?= /* @noEscape */ $block->getBlockHtml('formkey') ?>
|
||||
<input type="hidden" name="parent_product_id" value="<?= (int)$block->getProduct()->getId() ?>"/>
|
||||
<input type="hidden" name="product_id" value="" data-role="product-inquiry-product-id"/>
|
||||
|
||||
<div class="esun-product-inquiry__status" data-role="product-inquiry-status" role="status" aria-live="polite"></div>
|
||||
<div class="esun-product-inquiry__product">
|
||||
<strong data-role="product-inquiry-product-name"></strong>
|
||||
<span data-role="product-inquiry-product-options"></span>
|
||||
</div>
|
||||
|
||||
<div class="esun-product-inquiry__grid">
|
||||
<div class="field required">
|
||||
<label for="product-inquiry-name">
|
||||
<span><?= $escaper->escapeHtml(__('Name')) ?></span>
|
||||
<span class="esun-product-inquiry__required" aria-hidden="true">*</span>
|
||||
</label>
|
||||
<input class="input-text" id="product-inquiry-name" name="name" type="text"
|
||||
maxlength="255" autocomplete="name" required data-validate="{required:true}"/>
|
||||
</div>
|
||||
<div class="field required">
|
||||
<label for="product-inquiry-email">
|
||||
<span><?= $escaper->escapeHtml(__('Email')) ?></span>
|
||||
<span class="esun-product-inquiry__required" aria-hidden="true">*</span>
|
||||
</label>
|
||||
<input class="input-text" id="product-inquiry-email" name="email" type="email"
|
||||
maxlength="255" autocomplete="email" required
|
||||
data-validate="{required:true, 'validate-email':true}"/>
|
||||
</div>
|
||||
<div class="field required">
|
||||
<label for="product-inquiry-country">
|
||||
<span><?= $escaper->escapeHtml(__('Country')) ?></span>
|
||||
<span class="esun-product-inquiry__required" aria-hidden="true">*</span>
|
||||
</label>
|
||||
<select id="product-inquiry-country" name="country_id" required data-validate="{required:true}">
|
||||
<option value=""><?= $escaper->escapeHtml(__('Please select a country.')) ?></option>
|
||||
<?php foreach ($block->getCountryOptions() as $country): ?>
|
||||
<option value="<?= $escaper->escapeHtmlAttr((string)$country['value']) ?>">
|
||||
<?= $escaper->escapeHtml((string)$country['label']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="product-inquiry-company"><span><?= $escaper->escapeHtml(__('Company Name')) ?></span></label>
|
||||
<input class="input-text" id="product-inquiry-company" name="company" type="text"
|
||||
maxlength="255" autocomplete="organization"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="product-inquiry-telephone"><span><?= $escaper->escapeHtml(__('Telephone')) ?></span></label>
|
||||
<input class="input-text" id="product-inquiry-telephone" name="telephone" type="tel"
|
||||
maxlength="64" autocomplete="tel"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field required esun-product-inquiry__message">
|
||||
<label for="product-inquiry-message">
|
||||
<span><?= $escaper->escapeHtml(__('Message')) ?></span>
|
||||
<span class="esun-product-inquiry__required" aria-hidden="true">*</span>
|
||||
</label>
|
||||
<textarea id="product-inquiry-message" name="message" rows="6" maxlength="5000"
|
||||
required data-validate="{required:true}"></textarea>
|
||||
</div>
|
||||
<input type="text" name="hideit" class="esun-product-inquiry__trap" tabindex="-1" autocomplete="off"/>
|
||||
<button type="submit" class="action primary esun-product-inquiry__submit">
|
||||
<span><?= $escaper->escapeHtml(__('Submit Inquiry')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"[data-role=product-inquiry-modal]": {
|
||||
"Esun_ProductInquiry/js/product-inquiry": <?= /* @noEscape */ $block->getJsonConfig() ?>
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Product view form with configurable options kept visible for inquiry when
|
||||
* every associated product is out of stock.
|
||||
*
|
||||
* @var $block \Magento\Catalog\Block\Product\View
|
||||
* @var $escaper \Magento\Framework\Escaper
|
||||
*/
|
||||
|
||||
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
|
||||
|
||||
$_product = $block->getProduct();
|
||||
$isConfigurable = $_product->getTypeId()
|
||||
=== \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE;
|
||||
$hasOptions = $block->hasOptions() || $isConfigurable;
|
||||
$canRenderOptions = $_product->isSaleable() || $isConfigurable;
|
||||
?>
|
||||
<div class="product-add-form">
|
||||
<form data-product-sku="<?= $escaper->escapeHtmlAttr($_product->getSku()) ?>"
|
||||
action="<?= $escaper->escapeUrl($block->getSubmitUrl($_product)) ?>"
|
||||
method="post"
|
||||
id="product_addtocart_form"<?php if ($_product->getOptions()): ?>
|
||||
enctype="multipart/form-data"<?php endif; ?>>
|
||||
<input type="hidden" name="product" value="<?= (int)$_product->getId() ?>" />
|
||||
<input type="hidden" name="selected_configurable_option" value="" />
|
||||
<input type="hidden" name="related_product" id="related-products-field" value="" />
|
||||
<input type="hidden"
|
||||
name="return_url"
|
||||
value="<?= $escaper->escapeUrl(
|
||||
$block->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true])
|
||||
) ?>" />
|
||||
<input type="hidden" name="item" value="<?= (int)$block->getRequest()->getParam('id') ?>" />
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<?= $block->getChildHtml('form_top') ?>
|
||||
<?php if (!$hasOptions): ?>
|
||||
<?= $block->getChildHtml('product_info_form_content') ?>
|
||||
<?php elseif ($canRenderOptions && $block->getOptionsContainer() === 'container1'): ?>
|
||||
<?= $block->getChildChildHtml('options_container') ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canRenderOptions && $hasOptions && $block->getOptionsContainer() === 'container2'): ?>
|
||||
<?= $block->getChildChildHtml('options_container') ?>
|
||||
<?php endif; ?>
|
||||
<?= $block->getChildHtml('form_bottom') ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"[data-role=priceBox][data-price-box=product-id-<?= $escaper->escapeHtmlAttr($_product->getId()) ?>]": {
|
||||
"priceBox": {
|
||||
"priceConfig": <?= /* @noEscape */ $block->getJsonConfig() ?>
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,207 @@
|
||||
.esun-product-inquiry__trigger {
|
||||
align-items: center;
|
||||
background: #18a957;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
box-shadow: none;
|
||||
color: #fff;
|
||||
display: inline-flex;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
justify-content: center;
|
||||
letter-spacing: 0;
|
||||
line-height: 1.2;
|
||||
min-height: 56px;
|
||||
max-width: 300px;
|
||||
padding: 0 34px;
|
||||
text-transform: none;
|
||||
transition:
|
||||
background-color 0.16s ease,
|
||||
opacity 0.16s ease;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__trigger:hover,
|
||||
.esun-product-inquiry__trigger:focus {
|
||||
background: #129347;
|
||||
border: 0;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-product-inquiry-modal .modal-inner-wrap {
|
||||
width: min(700px, calc(100% - 32px));
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.esun-product-inquiry-modal .modal-header {
|
||||
padding: 24px 32px;
|
||||
background: #1e9e5a;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-product-inquiry-modal .modal-title,
|
||||
.esun-product-inquiry-modal .action-close:before {
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.esun-product-inquiry-modal .modal-content {
|
||||
padding: 28px 32px 34px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__product {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-bottom: 24px;
|
||||
padding: 14px 18px;
|
||||
border-radius: 10px;
|
||||
background: #f1f8f4;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry .field {
|
||||
margin: 0 0 18px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry input,
|
||||
.esun-product-inquiry select,
|
||||
.esun-product-inquiry textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.esun-product-inquiry input.input-text,
|
||||
.esun-product-inquiry select,
|
||||
.esun-product-inquiry textarea {
|
||||
border: 1px solid #d9dde1;
|
||||
background: #fff;
|
||||
color: #1f2933;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
border-color 0.16s ease,
|
||||
box-shadow 0.16s ease;
|
||||
}
|
||||
|
||||
.esun-product-inquiry input.input-text,
|
||||
.esun-product-inquiry select {
|
||||
height: 48px;
|
||||
padding: 0 20px;
|
||||
border-radius: 24px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry select {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
padding-right: 52px;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23303030' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 22px center;
|
||||
background-size: 10px 8px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry textarea {
|
||||
min-height: 160px;
|
||||
padding: 16px 20px;
|
||||
border-radius: 18px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.esun-product-inquiry input.input-text:focus,
|
||||
.esun-product-inquiry select:focus,
|
||||
.esun-product-inquiry textarea:focus {
|
||||
border-color: #1e9e5a;
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0 3px rgba(30, 158, 90, 0.12);
|
||||
}
|
||||
|
||||
.esun-product-inquiry__message {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__required {
|
||||
color: #e02b27;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry .esun-product-inquiry__submit.action.primary {
|
||||
align-items: center;
|
||||
background: #18a957;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
box-shadow: none;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
justify-content: center;
|
||||
letter-spacing: 0;
|
||||
line-height: 1.2;
|
||||
margin: 8px 0 0 auto;
|
||||
max-width: 300px;
|
||||
min-height: 56px;
|
||||
padding: 0 34px;
|
||||
text-transform: none;
|
||||
transition:
|
||||
background-color 0.16s ease,
|
||||
opacity 0.16s ease;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.esun-product-inquiry .esun-product-inquiry__submit.action.primary:hover,
|
||||
.esun-product-inquiry .esun-product-inquiry__submit.action.primary:focus,
|
||||
.esun-product-inquiry .esun-product-inquiry__submit.action.primary:active {
|
||||
background: #129347;
|
||||
border: 0;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__status {
|
||||
display: none;
|
||||
margin-bottom: 18px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__status.success,
|
||||
.esun-product-inquiry__status.error {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__status.success {
|
||||
background: #edf8f2;
|
||||
color: #167746;
|
||||
}
|
||||
.esun-product-inquiry__status.error {
|
||||
background: #fff1f0;
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.esun-product-inquiry__trap {
|
||||
position: absolute !important;
|
||||
left: -10000px !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.esun-product-inquiry__grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
.esun-product-inquiry-modal .modal-content {
|
||||
padding: 24px 20px 28px;
|
||||
}
|
||||
.esun-product-inquiry .esun-product-inquiry__submit.action.primary {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
define(['jquery', 'mage/utils/wrapper'], function ($, wrapper) {
|
||||
'use strict';
|
||||
|
||||
return function (Widget) {
|
||||
Widget.prototype._fillSelect = wrapper.wrapSuper(Widget.prototype._fillSelect, function (element) {
|
||||
var config = this.options.spConfig || {},
|
||||
attributeId = element.id.replace(/[a-z]*/, ''),
|
||||
result;
|
||||
|
||||
if (config.canDisplayShowOutOfStockStatus) {
|
||||
config.salable = config.salable || {};
|
||||
config.salable[attributeId] = config.salable[attributeId] || {};
|
||||
}
|
||||
|
||||
result = this._super(element);
|
||||
|
||||
if (config.canDisplayShowOutOfStockStatus) {
|
||||
$(element).find('option').each(function () {
|
||||
var wasDisabled = this.disabled;
|
||||
if (this.config && this.config.allowedProducts && this.config.allowedProducts.length) {
|
||||
this.disabled = false;
|
||||
$(this).toggleClass('esun-out-of-stock-option', wasDisabled);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
});
|
||||
return Widget;
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,221 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/modal',
|
||||
'mage/validation',
|
||||
'mage/translate'
|
||||
], function ($, modal, validation, $t) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $modal = $(element),
|
||||
$form = $modal.find('form'),
|
||||
$trigger = $('[data-role="product-inquiry-trigger"]').first(),
|
||||
$addToCart = $('#product-addtocart-button'),
|
||||
$buyNow = $('[data-role="esun-buy-now"]'),
|
||||
$qty = $('.box-tocart .field.qty'),
|
||||
$status = $modal.find('[data-role="product-inquiry-status"]'),
|
||||
$submit = $form.find('[type="submit"]'),
|
||||
closeTimer = null,
|
||||
selectedChild = null;
|
||||
|
||||
if (!$trigger.length) {
|
||||
$trigger = $('<button>', {
|
||||
type: 'button',
|
||||
'class': 'action primary tocart esun-product-inquiry__trigger',
|
||||
'data-role': 'product-inquiry-trigger'
|
||||
}).append($('<span>', {text: $t('Inquiry')})).hide();
|
||||
if (!$('.esun-product-actions').length) {
|
||||
$('<div>', {
|
||||
'class': 'box-tocart esun-product-inquiry-actions'
|
||||
}).append(
|
||||
$('<div>', {'class': 'fieldset'}).append(
|
||||
$('<div>', {'class': 'actions esun-product-actions'})
|
||||
)
|
||||
).appendTo($('.product-options-bottom').first().length ?
|
||||
$('.product-options-bottom').first() : $('#product_addtocart_form'));
|
||||
}
|
||||
$('.esun-product-actions').first().append($trigger);
|
||||
}
|
||||
|
||||
modal({
|
||||
type: 'popup',
|
||||
responsive: true,
|
||||
innerScroll: true,
|
||||
modalClass: 'esun-product-inquiry-modal',
|
||||
title: $t('Inquiry'),
|
||||
buttons: []
|
||||
}, $modal);
|
||||
$form.validation();
|
||||
|
||||
function getSwatchWidget() {
|
||||
var $swatch = $('.swatch-opt');
|
||||
return $swatch.data('mageSwatchRenderer') || $swatch.data('mage-SwatchRenderer');
|
||||
}
|
||||
|
||||
function getSelectedProductId() {
|
||||
var selected = $('[name="selected_configurable_option"]').val(),
|
||||
widget,
|
||||
selectedOptions = {},
|
||||
match = null;
|
||||
|
||||
if (selected && config.children[String(selected)]) {
|
||||
return String(selected);
|
||||
}
|
||||
widget = getSwatchWidget();
|
||||
if (widget && typeof widget.getProductId === 'function') {
|
||||
selected = widget.getProductId();
|
||||
if (selected && config.children[String(selected)]) {
|
||||
return String(selected);
|
||||
}
|
||||
}
|
||||
$('.swatch-attribute').each(function () {
|
||||
var $attribute = $(this),
|
||||
attributeId = String($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);
|
||||
}
|
||||
});
|
||||
if (widget && widget.options && widget.options.jsonConfig) {
|
||||
$.each(widget.options.jsonConfig.index || {}, function (productId, options) {
|
||||
var matches = Object.keys(selectedOptions).length > 0;
|
||||
$.each(selectedOptions, function (attributeId, optionId) {
|
||||
if (String(options[attributeId]) !== optionId) {
|
||||
matches = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (matches && Object.keys(options).length === Object.keys(selectedOptions).length) {
|
||||
match = String(productId);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
function ensureStickyInquiryButtons() {
|
||||
$('.esun-sticky-product-bar__actions').each(function () {
|
||||
var $actions = $(this);
|
||||
if (!$actions.find('[data-role="esun-sticky-product-inquiry"]').length) {
|
||||
$('<button>', {
|
||||
type: 'button',
|
||||
'class': 'action primary esun-sticky-product-inquiry',
|
||||
'data-role': 'esun-sticky-product-inquiry',
|
||||
text: $t('Inquiry')
|
||||
}).hide().appendTo($actions);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setInquiryState(enabled) {
|
||||
ensureStickyInquiryButtons();
|
||||
$trigger.toggle(enabled);
|
||||
$addToCart.toggle(!enabled).prop('disabled', enabled);
|
||||
$buyNow.closest('.esun-buy-now-row').toggle(!enabled);
|
||||
$qty.toggle(!enabled);
|
||||
$('[data-role="esun-sticky-add-to-cart"], [data-role="esun-sticky-buy-now"]').toggle(!enabled);
|
||||
$('[data-role="esun-sticky-product-inquiry"]').toggle(enabled);
|
||||
}
|
||||
|
||||
function refreshState() {
|
||||
var productId = getSelectedProductId();
|
||||
selectedChild = productId ? config.children[String(productId)] : null;
|
||||
setInquiryState(Boolean(selectedChild && selectedChild.requiresInquiry));
|
||||
}
|
||||
|
||||
function fillProductSummary() {
|
||||
var options = [];
|
||||
if (!selectedChild) {
|
||||
return;
|
||||
}
|
||||
$.each(selectedChild.options || [], function (index, option) {
|
||||
if (option.value) {
|
||||
options.push(option.label + ': ' + option.value);
|
||||
}
|
||||
});
|
||||
$form.find('[data-role="product-inquiry-product-id"]').val(selectedChild.id);
|
||||
$modal.find('[data-role="product-inquiry-product-name"]').text(
|
||||
config.parentName
|
||||
);
|
||||
$modal.find('[data-role="product-inquiry-product-options"]').text(options.join(' / '));
|
||||
}
|
||||
|
||||
function closeAfterSuccess() {
|
||||
window.clearTimeout(closeTimer);
|
||||
closeTimer = window.setTimeout(function () {
|
||||
$modal.modal('closeModal');
|
||||
if ($form[0]) {
|
||||
$form[0].reset();
|
||||
}
|
||||
$status.removeClass('success error').empty();
|
||||
$submit.prop('disabled', false).removeClass('disabled');
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
$trigger.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
refreshState();
|
||||
if (!selectedChild || !selectedChild.requiresInquiry) {
|
||||
return;
|
||||
}
|
||||
fillProductSummary();
|
||||
$status.removeClass('success error').empty();
|
||||
$modal.modal('openModal');
|
||||
});
|
||||
|
||||
$(document).on('click', '[data-role="esun-sticky-product-inquiry"]', function () {
|
||||
$trigger.trigger('click');
|
||||
});
|
||||
|
||||
$form.on('submit.esunProductInquiry', function (event) {
|
||||
var closeOnSuccess = false;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
if (!$form.validation('isValid')) {
|
||||
return;
|
||||
}
|
||||
$submit.prop('disabled', true).addClass('disabled');
|
||||
$status.removeClass('success error').empty();
|
||||
$.ajax({
|
||||
url: config.submitUrl,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: $form.serialize()
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
if (!response.duplicate) {
|
||||
$(document).trigger('esun:generateLead', {leadType: 'product_inquiry'});
|
||||
}
|
||||
closeOnSuccess = true;
|
||||
$status.addClass('success').text(response.message);
|
||||
closeAfterSuccess();
|
||||
} else {
|
||||
$status.addClass('error').text(response.message);
|
||||
}
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
$status.addClass('error').text(response.message || $t('Unable to submit your inquiry.'));
|
||||
}).always(function () {
|
||||
if (!closeOnSuccess) {
|
||||
$submit.prop('disabled', false).removeClass('disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on(
|
||||
'click change configurable.initialized swatch.initialized',
|
||||
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"]',
|
||||
function () {
|
||||
window.setTimeout(refreshState, 20);
|
||||
window.setTimeout(refreshState, 150);
|
||||
}
|
||||
);
|
||||
[0, 100, 300, 800, 1200].forEach(function (delay) {
|
||||
window.setTimeout(refreshState, delay);
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
define(['jquery', 'mage/utils/wrapper'], function ($, wrapper) {
|
||||
'use strict';
|
||||
|
||||
return function (Widget) {
|
||||
Widget.prototype._RenderControls = wrapper.wrapSuper(Widget.prototype._RenderControls, function () {
|
||||
var config = this.options.jsonConfig || {},
|
||||
widget = this,
|
||||
result;
|
||||
|
||||
if (config.canDisplayShowOutOfStockStatus) {
|
||||
config.salable = config.salable || {};
|
||||
Object.keys(config.attributes || {}).forEach(function (key) {
|
||||
var attributeId = config.attributes[key].id || key;
|
||||
config.salable[attributeId] = config.salable[attributeId] || {};
|
||||
});
|
||||
}
|
||||
|
||||
result = this._super();
|
||||
|
||||
if (config.canDisplayShowOutOfStockStatus) {
|
||||
Object.keys(config.attributes || {}).forEach(function (key) {
|
||||
var attribute = config.attributes[key],
|
||||
attributeId = attribute.id || key;
|
||||
|
||||
(attribute.options || []).forEach(function (option) {
|
||||
if (widget.optionsMap[attributeId] && widget.optionsMap[attributeId][option.id]) {
|
||||
widget.optionsMap[attributeId][option.id].products = (option.products || []).slice();
|
||||
}
|
||||
});
|
||||
});
|
||||
this._Rewind(this.element);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
Widget.prototype.disableSwatchForOutOfStockProducts = function () {
|
||||
var widget = this,
|
||||
config = this.options.jsonConfig || {},
|
||||
container = this.element;
|
||||
|
||||
if (!config.canDisplayShowOutOfStockStatus) {
|
||||
return;
|
||||
}
|
||||
Object.keys(config.attributes || {}).forEach(function (key) {
|
||||
var attributeId = config.attributes[key].id || key,
|
||||
salable = (config.salable || {})[attributeId] || {};
|
||||
widget.element.find('[data-attribute-id="' + attributeId + '"] .swatch-option').each(function () {
|
||||
var option = String($(this).data('option-id'));
|
||||
$(this).toggleClass('esun-out-of-stock-option', !Object.prototype.hasOwnProperty.call(salable, option));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return Widget;
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user