ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+173
View File
@@ -0,0 +1,173 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Api\Data;
interface RequestInterface
{
/**#@+
* Constants defined for keys of data array
*/
public const REQUEST_ID = 'request_id';
public const NAME = 'name';
public const EMAIL = 'email';
public const PHONE = 'phone';
public const PRODUCT_ID = 'product_id';
public const STORE_ID = 'store_id';
public const COMMENT = 'comment';
public const CREATED_AT = 'created_at';
public const STATUS = 'status';
public const MESSAGE_TEXT = 'message_text';
/**
* Returns request id field
*
* @return int|null
*/
public function getRequestId();
/**
* @param int $requestId
*
* @return $this
*/
public function setRequestId($requestId);
/**
* Returns name
*
* @return string|null
*/
public function getName();
/**
* @param string $name
*
* @return $this
*/
public function setName($name);
/**
* Returns email
*
* @return string|null
*/
public function getEmail();
/**
* @param string $email
*
* @return $this
*/
public function setEmail($email);
/**
* Returns phone
*
* @return string|null
*/
public function getPhone();
/**
* @param string $phone
*
* @return $this
*/
public function setPhone($phone);
/**
* Returns comment
*
* @return string|null
*/
public function getComment();
/**
* @param string $comment
*
* @return $this
*/
public function setComment($comment);
/**
* Returns product id
*
* @return int|null
*/
public function getProductId();
/**
* @param int $productId
*
* @return $this
*/
public function setProductId($productId);
/**
* Returns store id
*
* @return int|null
*/
public function getStoreId();
/**
* @param int $storeId
*
* @return $this
*/
public function setStoreId($storeId);
/**
* Returns created at
*
* @return string|null
*/
public function getCreatedAt();
/**
* @param string $createdAt
*
* @return $this
*/
public function setCreatedAt($createdAt);
/**
* Returns created at
*
* @return string|null
*/
public function getStatus();
/**
* @param int $status
*
* @return $this
*/
public function setStatus($status);
/**
* Returns admin answer message text
*
* @return string|null
*/
public function getMessageText();
/**
* @param string $text
*
* @return $this
*/
public function setMessageText($text);
}
@@ -0,0 +1,43 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Api;
/**
* Interface RequestRepositoryInterface
* @api
*/
interface RequestRepositoryInterface
{
/**
* @param \Amasty\HidePrice\Api\Data\RequestInterface $request
* @return \Amasty\HidePrice\Api\Data\RequestInterface
* @throws \Magento\Framework\Exception\CouldNotSaveException
*/
public function save(\Amasty\HidePrice\Api\Data\RequestInterface $request);
/**
* @param int $requestId
* @return \Amasty\HidePrice\Api\Data\RequestInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function get($requestId);
/**
* @param \Amasty\HidePrice\Api\Data\RequestInterface $request
* @return bool
* @throws \Magento\Framework\Exception\CouldNotDeleteException
*/
public function delete(\Amasty\HidePrice\Api\Data\RequestInterface $request);
/**
* @param int $requestId
* @return bool
* @throws \Magento\Framework\Exception\CouldNotDeleteException
*/
public function deleteById($requestId);
}
@@ -0,0 +1,146 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\Catalog\Product\Edit\Action\Attribute\Tab;
use Magento\Backend\Block\Widget\Tab\TabInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
class HidePrice extends \Magento\Catalog\Block\Adminhtml\Form implements TabInterface
{
/**
* @var \Magento\Catalog\Model\ProductFactory
*/
protected $_productFactory;
/**
* @var \Magento\Eav\Model\Config
*/
private $eavConfig;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Catalog\Model\ProductFactory $productFactory,
\Magento\Eav\Model\Config $eavConfig,
array $data = []
) {
$this->_productFactory = $productFactory;
parent::__construct($context, $registry, $formFactory, $data);
$this->eavConfig = $eavConfig;
}
/**
* @return void
*/
protected function _construct()
{
parent::_construct();
$this->setShowGlobalIcon(true);
}
/**
* @return $this|void
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('fields', ['legend' => __('Hide Price')]);
$attributes = $this->getAttributes();
/**
* Initialize product object as form property
* for using it in elements generation
*/
$form->setDataObject($this->_productFactory->create());
$this->_setFieldset($attributes, $fieldset, []);
$form->setFieldNameSuffix('attributes');
$this->setForm($form);
}
/**
* Retrieve attributes for product mass update
*
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAttributes()
{
$attributes = $this->eavConfig->getEntityType(
\Magento\Catalog\Model\Product::ENTITY
)->getAttributeCollection()->clear()
->addFieldToFilter('attribute_code', ['in' => ['am_hide_price_customer_gr', 'am_hide_price_mode']]);
foreach ($attributes as $attribute) {
$attribute->setIsVisible(true);
if ($attribute->getAttributeCode() == 'am_hide_price_mode') {
$attribute->setSourceModel(\Amasty\HidePrice\Model\Source\PriceMode::class);
}
}
return $attributes;
}
/**
* Custom additional element html
*
* @param AbstractElement $element
* @return string
*/
protected function _getAdditionalElementHtml($element)
{
// Add name attribute to checkboxes that correspond to multiselect elements
$nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
$elementId = $element->getId();
$dataAttribute = "data-disable='{$elementId}'";
$dataCheckboxName = "toggle_" . "{$elementId}";
$checkboxLabel = __('Change');
$html = <<<HTML
<span class="attribute-change-checkbox">
<input type="checkbox" id="$dataCheckboxName" name="$dataCheckboxName" class="checkbox" $nameAttributeHtml onclick="toogleFieldEditMode(this, '{$elementId}')" $dataAttribute />
<label class="label" for="$dataCheckboxName">
{$checkboxLabel}
</label>
</span>
HTML;
return $html;
}
/**
* @return \Magento\Framework\Phrase
*/
public function getTabLabel()
{
return __('Hide Price');
}
/**
* @return \Magento\Framework\Phrase
*/
public function getTabTitle()
{
return __('Hide Price');
}
/**
* @return bool
*/
public function canShowTab()
{
return true;
}
/**
* @return bool
*/
public function isHidden()
{
return false;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml;
class Request extends \Magento\Backend\Block\Widget\Grid\Container
{
/**
* Constructor
*
* @return void
*/
protected function _construct()
{
$this->_controller = 'request';
$this->_headerText = __('Get a Quote Requests');
parent::_construct();
}
protected function _addNewButton()
{
return;//remove new button
}
}
@@ -0,0 +1,54 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\Request;
use Magento\Backend\Block\Template;
use Amasty\HidePrice\Model\Source\ReplaceButton;
class Comment extends Template
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\Module\Manager
*/
private $moduleManager;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper,
\Magento\Framework\Module\Manager $moduleManager,
Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->helper = $helper;
$this->moduleManager = $moduleManager;
}
/**
* @return bool
*/
public function isNeedShow()
{
return $this->moduleManager->isEnabled('Amasty_Customform')
&& $this->helper->getModuleConfig('information/replace_with') == ReplaceButton::CUSTOM_FORM;
}
/**
* @return string
*/
public function getLink()
{
return $this->_urlBuilder->getUrl('amasty_customform/answer/index', [
'form_id' => $this->helper->getModuleConfig('information/custom_form')
]);
}
}
@@ -0,0 +1,198 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\Request\Edit;
class Info extends \Magento\Backend\Block\Template
{
protected $currentRequest;
/**
* @var \Magento\Framework\Registry
*/
private $coreRegistry;
/**
* @var \Magento\Customer\Api\CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @var \Magento\Catalog\Model\ProductRepository
*/
private $productRepository;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Amasty\HidePrice\Model\Source\Status
*/
private $status;
/**
* Info constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param \Magento\Catalog\Model\ProductRepository $productRepository
* @param \Amasty\HidePrice\Model\Source\Status $status
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
\Magento\Catalog\Model\ProductRepository $productRepository,
\Amasty\HidePrice\Model\Source\Status $status,
array $data = []
) {
$this->coreRegistry = $coreRegistry;
$this->customerRepository = $customerRepository;
$this->productRepository = $productRepository;
$this->storeManager = $context->getStoreManager();
$this->status = $status;
parent::__construct($context, $data);
}
public function _construct()
{
$this->currentRequest = $this->coreRegistry->registry(
\Amasty\HidePrice\Controller\Adminhtml\Request::CURRENT_REQUEST_MODEL
);
parent::_construct();
}
/**
* Add buttons on request view page
* @return $this
*/
protected function _prepareLayout()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
)->setData(
[
'label' => __('Send Email'),
'class' => 'action-save action-secondary',
'type' => 'submit'
]
);
$this->setChild('submit_button', $button);
$this->getToolbar()->addChild(
'back_button',
\Magento\Backend\Block\Widget\Button::class,
[
'label' => __('Back'),
'onclick' => 'setLocation("' . $this->getUrl('*/*/index') . '")',
'class' => 'back'
]
);
$deleteUrl = $this->getUrl(
'*/*/delete',
['id' => $this->getCurrentRequest()->getRequestId()]
);
$this->getToolbar()->addChild(
'delete_button',
\Magento\Backend\Block\Widget\Button::class,
[
'label' => __('Delete'),
'onclick' => 'deleteConfirm("' . $this->escapeJsQuote(
__(
'You are about to delete this request. '
. 'Are you sure you want to do that?'
)
) . '", "' . $deleteUrl . '")',
'class' => 'delete'
]
);
parent::_prepareLayout();
return $this;
}
/**
* Submit URL getter
*
* @return string
*/
public function getSubmitUrl()
{
return $this->getUrl('*/*/send', ['request_id' => $this->getCurrentRequest()->getRequestId()]);
}
public function getRequestData()
{
/** @var \Amasty\HidePrice\Model\Request $model */
$model = $this->getCurrentRequest();
$customerName = $model->getName();
try {
$customer = $this->customerRepository->get($model->getEmail());
} catch (\Exception $ex) {
$customer = null;
}
if ($customer) {
$customerName = sprintf(
'<a href="%s">%s</a>',
$this->getUrl('customer/index/edit', ['id' => $customer->getId()]),
$customerName
);
}
$productHtml = $model->getProductId();
try {
$product = $this->productRepository->getById($model->getProductId());
} catch (\Exception $ex) {
$product = null;
}
if ($product) {
$productHtml = sprintf(
'<a href="%s">%s</a>',
$this->getUrl('catalog/product/edit', ['id' => $product->getId()]),
$product->getName()
);
}
$store = $this->storeManager->getStore($model->getStore())->getName();
$status = $this->status->getOptionByValue($model->getStatus());
$result = [
['label' => __('Customer Name'), 'value' => $customerName],
['label' => __('Customer Email'), 'value' => $model->getEmail()],
['label' => __('Customer Phone'), 'value' => $model->getPhone()],
['label' => __('Product'), 'value' => $productHtml],
['label' => __('Store'), 'value' => $store],
[
'label' => __('Created'),
'value' => $this->_localeDate->date($model->getCreatedAt())->format('Y-m-d H:i:s')
],
['label' => __('Status'), 'value' => $status],
['label' => __('Comment'), 'value' => $model->getComment()],
];
$answer = $model->getMessageText();
if ($answer) {
$result[] = ['label' => __('Admin Answer Text'), 'value' => $answer];
}
return $result;
}
/**
* @return \Amasty\HidePrice\Model\Request
*/
public function getCurrentRequest()
{
return $this->currentRequest;
}
}
@@ -0,0 +1,166 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block\Adminhtml\System\Config;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Module\ModuleListInterface;
class Information extends \Magento\Config\Block\System\Config\Form\Fieldset
{
/**
* @var string
*/
private $userGuide = 'https://amasty.com/docs/doku.php?id=magento_2:hide_price';
/**
* @var array
*/
private $enemyExtensions = [];
/**
* @var string
*/
private $content;
/**
* @var ModuleListInterface
*/
private $moduleList;
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Backend\Model\Auth\Session $authSession,
\Magento\Framework\View\Helper\Js $jsHelper,
ModuleListInterface $moduleList,
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $data);
$this->moduleList = $moduleList;
}
/**
* Render fieldset html
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$html = $this->_getHeaderHtml($element);
$this->setContent(__('Please update Amasty Base module. Re-upload it and replace all the files.'));
$this->_eventManager->dispatch(
'amasty_base_add_information_content',
['block' => $this]
);
$html .= $this->getContent();
$html .= $this->_getFooterHtml($element);
$html = str_replace(
'amasty_information]" type="hidden" value="0"',
'amasty_information]" type="hidden" value="1"',
$html
);
$html = preg_replace('(onclick=\"Fieldset.toggleCollapse.*?\")', '', $html);
return $html;
}
/**
* @return array|string
*/
public function getAdditionalModuleContent()
{
$result = '';
if (!class_exists(\Zend_Dom_Query::class)
&& !class_exists(\Zend\Dom\Query::class)
&& !class_exists(\Laminas\Dom\Query::class)
) {
$message = [
'type' => 'message-error',
'text' => __(
'Laminas DOM package is not installed (The package is required for hiding "Add to Cart" '
. 'button on Category Page). Please, run the following command in the SSH: composer require '
. 'laminas/laminas-dom'
)
];
if ($this->getBaseVersion() < '1.3.4') {
return $message['text'];
}
$result = [];
$result[] = $message;
}
return $result;
}
/**
* @return string
*/
public function getUserGuide()
{
return $this->userGuide;
}
/**
* @param string $userGuide
*/
public function setUserGuide($userGuide)
{
$this->userGuide = $userGuide;
}
/**
* @return array
*/
public function getEnemyExtensions()
{
return $this->enemyExtensions;
}
/**
* @param array $enemyExtensions
*/
public function setEnemyExtensions($enemyExtensions)
{
$this->enemyExtensions = $enemyExtensions;
}
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* @return string
*/
private function getBaseVersion()
{
$version = '';
if (isset($this->moduleList->getOne('Amasty_Base')['setup_version'])) {
$version = $this->moduleList->getOne('Amasty_Base')['setup_version'];
}
return $version;
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Block;
use Amasty\HidePrice\Helper\Data;
use Magento\Framework\View\Element\Template;
use Amasty\HidePrice\Model\Source\ReplaceButton;
use Amasty\HidePrice\Model\Source\HideButton;
class Form extends \Magento\Framework\View\Element\Template
{
/**
* @var Data
*/
private $helper;
public function __construct(
Template\Context $context,
Data $helper,
array $data = []
) {
parent::__construct($context, $data);
$this->helper = $helper;
}
/**
* @return string
*/
public function toHtml()
{
$html = '';
$isPopupContentGenerated = false;
if ($this->helper->getModuleConfig('information/hide_button') == HideButton::REPLACE_WITH_NEW_ONE) {
switch ($this->helper->getModuleConfig('information/replace_with')) {
case ReplaceButton::HIDE_PRICE_POPUP:
$isPopupContentGenerated = true;
$html = $this->getDefaultPopup();
break;
case ReplaceButton::CUSTOM_FORM:
if ($this->helper->isCustomFormOn()) {
$isPopupContentGenerated = true;
$html = $this->getLayout()->createBlock(
\Amasty\Customform\Block\Form::class,
'',
[
'data' => [
'form_id' => $this->helper->getModuleConfig('information/custom_form')
]
]
)->addAdditionalClass('amhideprice-form no-display')->toHtml();
}
break;
}
}
if (!$isPopupContentGenerated && $this->isPopupEnabled()) {
$html .= $this->getDefaultPopup();
}
return $html;
}
/**
* @return string
*/
private function getDefaultPopup()
{
$this->setTemplate('Amasty_HidePrice::form.phtml');
return parent::toHtml();
}
/**
* Check if GDPR consent enabled
*
* @return bool
*/
public function isGDPREnabled()
{
return $this->helper->isGDPREnabled();
}
/**
* Get text for GDPR
*
* @return string
*/
public function getGDPRText()
{
return $this->helper->getGDPRText();
}
/**
* @return bool
*/
private function isPopupEnabled()
{
return $this->helper->getModuleConfig('frontend/link') == Data::HIDE_PRICE_POPUP_IDENTIFICATOR;
}
}
+59
View File
@@ -0,0 +1,59 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Adminhtml;
use Magento\Backend\Model\View\Result\Page;
use Magento\Framework\Controller\ResultFactory;
abstract class Request extends \Magento\Backend\App\Action
{
public const CURRENT_REQUEST_MODEL = 'amasty_hideprice_request_model';
/**
* @var \Amasty\HidePrice\Model\RequestRepository
*/
protected $requestRepository;
/**
* @var \Magento\Framework\Registry
*/
protected $coreRegistry;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Amasty\HidePrice\Model\RequestRepository $requestRepository,
\Magento\Framework\Registry $coreRegistry
) {
parent::__construct($context);
$this->requestRepository = $requestRepository;
$this->coreRegistry = $coreRegistry;
}
/**
* Authorization level of a basic admin session
*
* @see _isAllowed()
*/
public const ADMIN_RESOURCE = 'Amasty_HidePrice::request';
/**
* Initiate action
*
* @return Page
*/
protected function _initAction()
{
/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu(self::ADMIN_RESOURCE);
$resultPage->addBreadcrumb(__('Amasty Hide Price'), __('Amasty Hide Price'));
$resultPage->getConfig()->getTitle()->prepend(__('Requests'));
return $resultPage;
}
}
@@ -0,0 +1,53 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Adminhtml\Request;
class Delete extends \Amasty\HidePrice\Controller\Adminhtml\Request
{
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Amasty\HidePrice\Model\RequestRepository $requestRepository,
\Magento\Framework\Registry $coreRegistry,
\Psr\Log\LoggerInterface $logger
) {
parent::__construct($context, $requestRepository, $coreRegistry);
$this->logger = $logger;
}
public function execute()
{
$id = $this->getRequest()->getParam('id');
if ($id) {
try {
$this->requestRepository->deleteById($id);
$this->messageManager->addSuccessMessage(__('Request was deleted.'));
$this->_redirect('amasty_hideprice/*/');
return;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(
__('Can\'t delete item right now. Please review the log and try again.')
);
$this->logger->critical($e);
$this->_redirect('amasty_hideprice/*/edit', ['id' => $id]);
return;
}
}
$this->messageManager->addErrorMessage(__('Can\'t find a item to delete.'));
$this->_redirect('amasty_hideprice/*/');
}
}
@@ -0,0 +1,47 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Adminhtml\Request;
use Amasty\HidePrice\Model\Source\Status;
class Edit extends \Amasty\HidePrice\Controller\Adminhtml\Request
{
public function execute()
{
$id = $this->getRequest()->getParam('id');
if ($id) {
try {
$model = $this->requestRepository->get($id);
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
$this->messageManager->addErrorMessage(__('This request no longer exists.'));
$this->_redirect('amasty_hideprice/*');
return;
}
} else {
$this->messageManager->addErrorMessage(__('This request no longer exists.'));
$this->_redirect('amasty_hideprice/*');
return;
}
$this->coreRegistry->register(\Amasty\HidePrice\Controller\Adminhtml\Request::CURRENT_REQUEST_MODEL, $model);
$this->_initAction();
$this->_view->getPage()->getConfig()->getTitle()->prepend(
__('Get a Quote Request from ') . $model->getName()
);
$this->_view->renderLayout();
/* change request status to viewed*/
if ($model->getStatus() == Status::PENDING) {
$model->setStatus(Status::VIEWED);
$this->requestRepository->save($model);
}
}
}
@@ -0,0 +1,18 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Adminhtml\Request;
class Index extends \Amasty\HidePrice\Controller\Adminhtml\Request
{
public function execute()
{
$this->_initAction();
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Get a Quote Requests'));
$this->_view->renderLayout();
}
}
@@ -0,0 +1,59 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Adminhtml\Request;
class MassDelete extends \Amasty\HidePrice\Controller\Adminhtml\Request
{
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var \Amasty\HidePrice\Model\ResourceModel\Request\CollectionFactory
*/
private $collectionFactory;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Amasty\HidePrice\Model\RequestRepository $requestRepository,
\Magento\Framework\Registry $coreRegistry,
\Psr\Log\LoggerInterface $logger,
\Amasty\HidePrice\Model\ResourceModel\Request\CollectionFactory $collectionFactory
) {
parent::__construct($context, $requestRepository, $coreRegistry);
$this->logger = $logger;
$this->collectionFactory = $collectionFactory;
}
/**
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
*/
public function execute()
{
$requestIds = $this->getRequest()->getParam('request_ids');
if (!is_array($requestIds)) {
$this->messageManager->addErrorMessage(__('Please select items.'));
} else {
try {
/** @var \Amasty\HidePrice\Model\ResourceModel\Request\Collection $collection */
$collection = $this->collectionFactory->create();
$collection->deleteByIds($requestIds);
$this->messageManager->addSuccessMessage(__('Get a Quote requests are deleted.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(
__('Can\'t delete items right now. Please review the log and try again.')
);
$this->logger->critical($e);
}
}
$this->_redirect('amasty_hideprice/*/');
}
}
@@ -0,0 +1,133 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Adminhtml\Request;
use Amasty\HidePrice\Model\Source\Status;
use Amasty\HidePrice\Model\Validator;
use Magento\Framework\App\ObjectManager;
class Send extends \Amasty\HidePrice\Controller\Adminhtml\Request
{
/**
* @var \Magento\Framework\Mail\Template\TransportBuilder
*/
private $transportBuilder;
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var Validator
*/
private $validator;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Amasty\HidePrice\Model\RequestRepository $requestRepository,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
\Amasty\HidePrice\Helper\Data $helper,
\Magento\Store\Model\StoreManagerInterface $storeManager,
Validator $validator = null // TODO move to not optional
) {
parent::__construct($context, $requestRepository, $coreRegistry);
$this->transportBuilder = $transportBuilder;
$this->helper = $helper;
$this->storeManager = $storeManager;
$this->validator = $validator ?? ObjectManager::getInstance()->get(Validator::class);
}
/**
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function execute()
{
$id = $this->getRequest()->getParam('request_id');
$message = $this->getRequest()->getParam('email_text');
if (!$this->validator->isNotEmpty(trim($message))) {
$this->messageManager->addErrorMessage(__('Please enter a Email Text.'));
$this->_redirect('*/*/edit', ['id' => $id]);
return;
}
if ($id) {
try {
$model = $this->requestRepository->get($id);
$emailTo = $model->getEmail();
$sender = $this->helper->getModuleConfig('general/sender');
$template = $this->helper->getModuleConfig('general/template');
if ($this->sendEmail($model, $sender, $emailTo, $template, $message)) {
$model->setStatus(Status::ANSWERED);
$model->setMessageText($message);
$this->requestRepository->save($model);
$this->messageManager->addSuccessMessage(__('Email Answer was sent.'));
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
$this->messageManager->addErrorMessage(__('This request no longer exists.'));
}
} else {
$this->messageManager->addErrorMessage(__('Please select request id.'));
}
$this->_redirect('amasty_hideprice/*/');
}
/**
* @param \Amasty\HidePrice\Model\Request $model
* @param $sender
* @param $emailTo
* @param $template
* @param $message
*
* @return bool
*/
private function sendEmail(\Amasty\HidePrice\Model\Request $model, $sender, $emailTo, $template, $message)
{
try {
$store = $this->storeManager->getStore($model->getStoreId());
$data = [
'website_name' => $store->getWebsite()->getName(),
'group_name' => $store->getGroup()->getName(),
'store_name' => $store->getName(),
'store' => $store,
'request' => $model,
'message' => $message,
'customer_name' => $model->getName()
];
$transport = $this->transportBuilder->setTemplateIdentifier(
$template
)->setTemplateOptions(
['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $store->getId()]
)->setTemplateVars(
$data
)->setFrom(
$sender
)->addTo(
$emailTo,
$model->getName()
)->getTransport();
$transport->sendMessage();
return true;
} catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
return false;
}
}
}
+253
View File
@@ -0,0 +1,253 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Controller\Request;
use Amasty\HidePrice\Model\Request;
use Amasty\HidePrice\Model\Validator;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;
class Add extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\Data\Form\FormKey\Validator
*/
private $formKeyValidator;
/**
* @var \Amasty\HidePrice\Model\RequestFactory
*/
private $requestFactory;
/**
* @var \Amasty\HidePrice\Model\RequestRepository
*/
private $requestRepository;
/**
* @var \Magento\Catalog\Model\ProductRepository
*/
private $productRepository;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Magento\Framework\Json\EncoderInterface
*/
private $jsonEncoder;
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\Mail\Template\TransportBuilder
*/
private $transportBuilder;
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var \Magento\Framework\Data\Form\Filter\Escapehtml
*/
private $escapehtml;
/**
* @var Validator
*/
private $validator;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
\Amasty\HidePrice\Model\RequestFactory $requestFactory,
\Amasty\HidePrice\Model\RequestRepository $requestRepository,
\Magento\Catalog\Model\ProductRepository $productRepository,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
\Amasty\HidePrice\Helper\Data $helper,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Form\Filter\Escapehtml $escapehtml,
Validator $validator = null // TODO move to not optional
) {
parent::__construct($context);
$this->formKeyValidator = $formKeyValidator;
$this->requestFactory = $requestFactory;
$this->requestRepository = $requestRepository;
$this->productRepository = $productRepository;
$this->storeManager = $storeManager;
$this->jsonEncoder = $jsonEncoder;
$this->helper = $helper;
$this->transportBuilder = $transportBuilder;
$this->logger = $logger;
$this->escapehtml = $escapehtml;
$this->validator = $validator ?? ObjectManager::getInstance()->get(Validator::class);
}
public function execute()
{
$message = [
'error' => __(
'Sorry. There is a problem with Your Quote Request.' .
' Please try again or use Contact Us link in the menu.'
)
];
if ($this->getRequest()->isPost()) {
try {
$data = $this->getValidData();
/** @var Request $model */
$model = $this->requestFactory->create();
$model->addData($data);
$this->requestRepository->save($model);
$message = ['success' => __('Thanks for contacting us. We\'ll respond to you as soon as possible. ')];
$this->sendAdminNotification($model);
$this->sendAutoReply($model);
} catch (LocalizedException $e) {
$message = ['error' => $e->getMessage()];
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
}
$this->getResponse()->representJson(
$this->jsonEncoder->encode($message)
);
}
/**
* Validates all data
*
* @throws LocalizedException
* @return array
*/
private function getValidData()
{
$data = $this->getRequest()->getPostValue();
if (!$this->formKeyValidator->validate($this->getRequest())) {
throw new LocalizedException(
__('Form key is not valid. Please try to reload the page.')
);
}
if (!$this->validator->isValidEmail($data['email'])) {
throw new LocalizedException(__('Please enter a valid email address.'));
}
$data['name'] = $this->escapehtml->outputFilter(trim($data['name']));
if (!$this->validator->isNotEmpty($data['name'])) {
throw new LocalizedException(__('Please enter a name.'));
}
$data['phone'] = $this->escapehtml->outputFilter(trim($data['phone']));
if (!$this->validator->isNotEmpty($data['phone'])) {
throw new LocalizedException(__('Please enter a phone.'));
}
$data['product_id'] = (int)$data['product_id'];
if (!$this->validator->isNotEmpty($data['product_id'])
|| !($product = $this->productRepository->getById($data['product_id']))
) {
throw new LocalizedException(__('There are no product for your request.'));
} else {
$data['product_name'] = $product->getName();
}
if (array_key_exists('comment', $data)) {
$data['comment'] = $this->escapehtml->outputFilter(trim($data['comment']));
}
if ($this->helper->isGDPREnabled() && (!isset($data['gdpr']) || !$data['gdpr'])) {
throw new LocalizedException(__('Please agree to the Privacy Policy'));
}
$data['store_id'] = $this->storeManager->getStore()->getId();
return $data;
}
/**
* @param Request $model
*/
private function sendAdminNotification(Request $model)
{
$emailTo = trim($this->helper->getModuleConfig('admin_email/to'));
if ($emailTo) {
$emailTo = explode(',', $emailTo);
$sender = $this->helper->getModuleConfig('admin_email/sender');
$template = $this->helper->getModuleConfig('admin_email/template');
$this->sendEmail($model, $sender, $emailTo, $template);
}
}
/**
* @param Request $model
*/
private function sendAutoReply(Request $model)
{
$enabled = $this->helper->getModuleConfig('reply_email/enabled');
if ($enabled) {
$emailTo = [$model->getEmail()];
$sender = $this->helper->getModuleConfig('reply_email/sender');
$template = $this->helper->getModuleConfig('reply_email/template');
$this->sendEmail($model, $sender, $emailTo, $template);
}
}
/**
* @param Request $model
* @param $sender
* @param array $emailTo
* @param $template
*/
private function sendEmail(Request $model, $sender, $emailTo, $template)
{
try {
$store = $this->storeManager->getStore();
$first = array_shift($emailTo);
$data = [
'website_name' => $store->getWebsite()->getName(),
'group_name' => $store->getGroup()->getName(),
'store_name' => $store->getName(),
'store' => $store,
'request' => $model,
'customer_name' => $model->getName()
];
$transport = $this->transportBuilder->setTemplateIdentifier(
$template
)->setTemplateOptions(
['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $store->getId()]
)->setTemplateVars(
$data
)->setFrom(
$sender
)->addTo(
$first,
$model->getName()
)->addTo(
$emailTo,
$model->getName()
)->getTransport();
$transport->sendMessage();
} catch (\Exception $e) {
$this->logger->critical($e);
}
}
}
+563
View File
@@ -0,0 +1,563 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Helper;
use Amasty\HidePrice\Model\Source\HideButton;
use Lts\Customer\Model\Netsuite\Status;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\DataObject;
use Amasty\HidePrice\Model\Source\ReplaceButton;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
public const ROOT_CATEGORY_ID = 1;
public const NOT_LOGGED_KEY = '00';
public const DISABLED_GROUP_KEY = -1;
public const HIDE_PRICE_DATA_ROLE = 'data-role="amhideprice-hide-button"';
public const HIDE_PRICE_POPUP_IDENTIFICATOR = 'AmastyHidePricePopup';
/**
* @var string
*/
protected $currentCustomerGroup;
/**
* @var array
*/
protected $matchedCategories;
/**
* @var array
*/
protected $cache = [];
/**
* @var CollectionFactory
*/
private $categoryCollectionFactory;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Magento\Framework\Json\EncoderInterface
*/
private $jsonEncoder;
/**
* @var \Magento\Customer\Model\SessionFactory
*/
private $sessionFactory;
/**
* @var \Magento\Framework\Filter\FilterManager
*/
private $filterManager;
/**
* @var \Magento\Customer\Model\Url
*/
private $customerUrl;
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Customer\Model\SessionFactory $sessionFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
CollectionFactory $categoryCollectionFactory,
\Magento\Framework\Filter\FilterManager $filterManager,
\Magento\Customer\Model\Url $customerUrl
) {
parent::__construct($context);
$this->categoryCollectionFactory = $categoryCollectionFactory;
$this->storeManager = $storeManager;
$this->jsonEncoder = $jsonEncoder;
$this->sessionFactory = $sessionFactory;
$this->currentCustomerGroup = $this->getCustomerSession()->getCustomerGroupId();
if (!$this->currentCustomerGroup) {
$this->currentCustomerGroup = self::NOT_LOGGED_KEY;
}
$this->filterManager = $filterManager;
$this->customerUrl = $customerUrl;
}
private function getCustomerSession()
{
return $this->sessionFactory->create();
}
public function getModuleConfig(string $path): string
{
return (string)$this->scopeConfig->getValue('amasty_hide_price/' . $path, ScopeInterface::SCOPE_STORE);
}
/**
* @return bool
*/
public function isModuleEnabled()
{
return $this->getModuleConfig('general/enabled') && $this->isModuleOutputEnabled();
}
/**
* @param ProductInterface $product
* @return bool
*/
public function isApplied(ProductInterface $product)
{
if (!$this->isModuleEnabled()) {
return false;
}
if (!$this->issetCachedResult($product->getId())) {
/* Checking settings by product and customer group. Order is important.*/
$result = $this->checkGlobalSettings($product);
$result = $this->checkStockStatus($result, $product);
$result = $this->checkCategorySettings($result, $product);
$result = $this->checkProductSettings($result, $product);
$result = $this->checkIgnoreSettings($result, $product);
// $result = $this->checkByNetsuiteStatus($result);
/* save result to cache for multiple places: price button add to wishlist and other*/
$this->saveResultToCache($result, $product->getId());
} else {
$result = $this->getResultFromCache($product->getId());
}
return $result;
}
/**
* Checking module setting and output
* @param ProductInterface $product
* @return bool
*/
public function isNeedHideProduct(ProductInterface $product)
{
$isConfigEnabled = $this->getModuleConfig('information/hide_price')
|| $this->getHideAddToCart();
return $isConfigEnabled && $this->isApplied($product);
}
/**
* @return int
*/
public function getHideAddToCart()
{
return (int)$this->getModuleConfig('information/hide_button');
}
/**
* @return bool
*/
public function getHideWishlist()
{
return (bool)$this->getModuleConfig('information/hide_wishlist');
}
/**
* Hide Price depend on selected categories and customer groups in configuration
* @param ProductInterface $product
* @return bool
*/
private function checkGlobalSettings(ProductInterface $product)
{
$result = false;
$settingCustomerGroup = $this->convertStringSettingToArray('general/customer_group');
if (in_array($this->currentCustomerGroup, $settingCustomerGroup)) {
$productCategories = $product->getCategoryIds();
$settingCategories = $this->convertStringSettingToArray('general/category');
//check for root category - hide price for all
$result = in_array(self::ROOT_CATEGORY_ID, $settingCategories)
|| count(array_uintersect($productCategories, $settingCategories, "strcmp")) > 0
? true: false;
}
return $result;
}
/**
* Plugin in stock status must work
*
* @param $result
* @param ProductInterface $product
*
* @return bool
*/
public function checkStockStatus($result, ProductInterface $product)
{
return $result;
}
/**
* Hide Price depend on selected individual category settings
* @param $result
* @param ProductInterface $product
* @return bool
*/
private function checkCategorySettings($result, ProductInterface $product)
{
$productCategories = $product->getCategoryIds();
if (!$this->matchedCategories) {
/* get categories only with not empty attributes customer_gr_cat and mode_cat */
$collection = $this->categoryCollectionFactory->create()
->addAttributeToSelect('am_hide_price_mode_cat')
->addAttributeToSelect('am_hide_price_customer_gr_cat')
->addAttributeToFilter('am_hide_price_mode_cat', ['notnull' => true])
->addAttributeToFilter('am_hide_price_customer_gr_cat', ['notnull' => true]);
$this->matchedCategories = $collection->getData();
}
if (!empty($this->matchedCategories)) {
foreach ($this->matchedCategories as $category) {
if (!in_array($category['entity_id'], $productCategories)) {
continue;
}
$customerGroups = $this->trimAndExplode($category['am_hide_price_customer_gr_cat']);
if (in_array($this->currentCustomerGroup, $customerGroups)) {
$result = !(bool)$category['am_hide_price_mode_cat'];
}
}
}
return $result;
}
/**
* Hide Price depend on selected individual product settings
* @param $result
* @param ProductInterface $product
* @return bool
*/
private function checkProductSettings($result, ProductInterface $product)
{
$mode = $product->getData('am_hide_price_mode');
$customerGroups = $product->getData('am_hide_price_customer_gr');
if ($mode !== null && $customerGroups) {
$customerGroups = $this->trimAndExplode($customerGroups);
if (in_array($this->currentCustomerGroup, $customerGroups)) {
$result = !(bool)$mode;
}
}
return $result;
}
private function checkByNetsuiteStatus($result)
{
$customerSession = $this->getCustomerSession();
if ($customerSession->isLoggedIn()) {
$customer = $customerSession->getCustomer();
$dataCustomer = $customer->getDataModel();
$netsuiteStatus = $dataCustomer->getExtensionAttributes()?->getNetsuiteStatus();
$netsuiteStatus = $netsuiteStatus? strtolower($netsuiteStatus):'';
if (in_array($netsuiteStatus, Status::getApprovedStatuses())) {
$result = true;
}
}
$result = false;
return $result;
}
/**
* Check ignore settings - the most important
* @param $result
* @param ProductInterface $product
* @return bool
*/
private function checkIgnoreSettings($result, ProductInterface $product)
{
$currentCustomerId = $this->getCustomerSession()->getCustomerId();
if ($currentCustomerId) {
$ignoredCustomers = $this->convertStringSettingToArray('general/ignore_customer');
if (in_array($currentCustomerId, $ignoredCustomers)) {
return false;
}
}
$ignoredProductIds = $this->convertStringSettingToArray('general/ignore_products');
if (in_array($product->getId(), $ignoredProductIds)) {
return false;
}
return $result;
}
/**
* Generate button html depend on module configuration
* @param $product
* @return string
*/
public function getNewPriceHtmlBox($product)
{
$priceBox = $this->getPriceBox();
// help for magento swatches detect category page
$html = sprintf('<div class="%s" data-product-id="%d"></div>', $priceBox, $product->getId());
$text = $this->filterManager->stripTags(
$this->getModuleConfig('frontend/text'),
[
'allowableTags' => null,
'escape' => true
]
);
$image = $this->getModuleConfig('frontend/image');
if ($text || $image) {
$href = $this->getModuleConfig('frontend/link');
if ($href) {
if ($href == self::HIDE_PRICE_POPUP_IDENTIFICATOR) {
$tag = $this->generatePopup($product);
} else {
$href = $this->checkLoginUrl($href);
$tag = '<a href="' . $href . '" ';
}
$closeTag = '</a>';
} else {
$tag = '<div ';
$closeTag = '</div>';
}
$customStyles = $this->getModuleConfig('frontend/custom_css');
if ($customStyles) {
$customStyles = 'style="' . $customStyles . '"';
}
$html .= $tag . ' class="amasty-hide-price-container" ' . $customStyles . '>';
if ($image) {
$mediaPath = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
$image = $mediaPath . '/amasty/hide_price/' . $image;
$html .= '<img class="amasty-hide-price-image" src="' . $image .'">';
}
if ($text) {
$html .= '<span class="amasty-hide-price-text">' . $text . '</span>';
}
$html .= $closeTag;
}
return $html;
}
private function getPriceBox(): string
{
//fix dropdown in configurable product
return $this->_request->getControllerName() !== 'product' ? 'price-box price-final_price'
: 'price-final_price';
}
/**
* @param string $href
*
* @return string|string
*/
protected function checkLoginUrl(string $href)
{
if (strpos($href, 'customer/account/login') !== false) {
$href = $this->customerUrl->getLoginUrl();
}
return $href;
}
/**
* Generate button replacement html
* @param Product|null $product
* @param array|null $productData
* @return string
*/
public function getNewAddToCartHtml($product = null, $productData = null)
{
// help for magento swatches detect category page
$result = '';
if ($this->getModuleConfig('information/hide_button') == HideButton::REPLACE_WITH_NEW_ONE) {
$text = strip_tags($this->getModuleConfig('information/replace_text'));
$link = $this->getModuleConfig('information/replace_link') ?: '';
if (!$product && isset($productData['id'])) {
$product = new DataObject([
'id' => $productData['id'],
'name' => $productData['name']
]);
}
switch ($this->getModuleConfig('information/replace_with')) {
case ReplaceButton::REDIRECT_URL:
$href = $this->checkLoginUrl((string)$this->getModuleConfig('information/redirect_link'));
$href = $href ?: '#';
$tag = '<a href="' . $href . '"';
break;
case ReplaceButton::HIDE_PRICE_POPUP:
case ReplaceButton::CUSTOM_FORM:
$tag = $this->generatePopup($product);
break;
}
$styles = strip_tags($this->getModuleConfig('information/replace_css'));
$styles = $styles ? ' style="' . $styles . '"' : '';
$result .= sprintf(
'%s class="amasty-hide-price-button" %s><span>%s</span></a>',
$tag,
$styles,
$text
);
}
return $result;
}
/**
* generate Js code for Get a Quote Form
* @param Product|DataObject $product
* @return string
*/
private function generateFormJs($product)
{
$js = '<script>';
$js .= 'require([
"jquery",
"Amasty_HidePrice/js/amhidepriceForm"
], function ($, amhidepriceForm) {
amhidepriceForm.addProduct(' . $this->generateFormConfig($product) . ');
});';
$js .= '</script>';
return $js;
}
private function generateFormConfig($product)
{
$customer = $this->getCustomerSession()->getCustomer();
return $this->jsonEncoder->encode([
'url' => $this->_getUrl('amasty_hide_price/request/add'),
'id' => $product->getId(),
'name' => $product->getName(),
'customer' => [
'name' => $customer->getName(),
'email' => $customer->getEmail(),
'phone' => $customer->getPhone()
]
]);
}
private function convertStringSettingToArray($name)
{
$setting = $this->getModuleConfig($name);
$setting = $this->trimAndExplode($setting);
return $setting;
}
/**
* @param $string
* @return array
*/
private function trimAndExplode($string): array
{
$string = str_replace(' ', '', (string) $string);
return $string ? explode(',', $string) : [];
}
/**
* @param $productId
* @return bool
*/
private function issetCachedResult($productId)
{
if (!array_key_exists($this->currentCustomerGroup, $this->cache)) {
return false;
}
return array_key_exists($productId, $this->cache[$this->currentCustomerGroup]);
}
/**
* @param $productId
* @return mixed
*/
private function getResultFromCache($productId)
{
return $this->cache[$this->currentCustomerGroup][$productId];
}
/**
* @param $result
* @param $productId
*/
private function saveResultToCache($result, $productId)
{
if (!array_key_exists($this->currentCustomerGroup, $this->cache)) {
$this->cache[$this->currentCustomerGroup] = [];
}
$this->cache[$this->currentCustomerGroup][$productId] = $result;
}
/**
* @return bool
*/
public function isGDPREnabled()
{
return (bool)$this->getModuleConfig('gdpr/enabled');
}
/**
* @return string
*/
public function getGDPRText()
{
return $this->filterManager->stripTags(
$this->getModuleConfig('gdpr/text'),
[
'allowableTags' => '<a>',
'escape' => false
]
);
}
/**
* @param Product|DataObject $product
* @return string
*/
private function generatePopup($product)
{
$popupHtml = $this->generateFormJs($product)
. '<a data-product-id="' . $product->getId() . '" data-amhide="'
. self::HIDE_PRICE_POPUP_IDENTIFICATOR . '" ';
return $popupHtml;
}
/**
* @return bool
*/
public function isCustomFormOn()
{
return $this->_moduleManager->isEnabled('Amasty_Customform');
}
/**
* Checking module setting and output
* @param ProductInterface $product
* @return bool
*/
public function isNeedHidePrice(ProductInterface $product)
{
return $this->getModuleConfig('information/hide_price') && $this->isApplied($product);
}
}
@@ -0,0 +1,32 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Config\Backend\Popup;
use Magento\Framework\Exception\LocalizedException;
use Amasty\HidePrice\Model\Source\ReplaceButton;
class Customform extends \Magento\Framework\App\Config\Value
{
/**
* @return $this
* @throws LocalizedException
*/
public function save()
{
if ($this->getValue() == ReplaceButton::CUSTOM_FORM
&& $this->getModuleManager()
&& $this->getModuleManager()->isEnabled('Amasty_Customform') === false
) {
throw new LocalizedException(
__('Custom Forms module was not installed.')
);
}
return parent::save();
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model;
use Amasty\Base\Model\ConfigProviderAbstract;
class ConfigProvider extends ConfigProviderAbstract
{
private const ENABLE = 'general/enabled';
private const HIDE_WISHLIST = 'information/hide_wishlist';
private const HIDE_COMPARE = 'information/hide_compare';
private const HIDE_ADD_TO_CART = 'information/hide_button';
/**
* @var string
*/
protected $pathPrefix = 'amasty_hide_price/';
public function isEnabled(?int $storeId = null): bool
{
return $this->isSetFlag(self::ENABLE, $storeId);
}
public function isHideWishlist(?int $storeId = null): bool
{
return $this->isSetFlag(self::HIDE_WISHLIST, $storeId);
}
public function isHideCompare(?int $storeId = null): bool
{
return $this->isSetFlag(self::HIDE_COMPARE, $storeId);
}
public function isHideAddToCart(?int $storeId = null): bool
{
return $this->isSetFlag(self::HIDE_ADD_TO_CART, $storeId);
}
}
+86
View File
@@ -0,0 +1,86 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model;
class DomWrapper
{
/**
* @var null|\Laminas\Dom\Query|\Zend\Dom\Query|\Zend_Dom_Query
*/
private $domQuery = null;
/**
* @var bool
*/
private $initialized = false;
/**
* @var string
*/
private $executeMethod = 'query';
/**
* @param \DOMDocument $domDocument
*/
public function setContent(\DOMDocument $domDocument)
{
if (class_exists(\Laminas\Dom\Query::class)) {
$this->domQuery = new \Laminas\Dom\Query($domDocument->saveHTML());
$this->executeMethod = 'execute';
$this->initialized = true;
} elseif (class_exists(\Zend\Dom\Query::class)) {
$this->domQuery = new \Zend\Dom\Query($domDocument->saveHTML());
$this->executeMethod = 'execute';
} elseif (class_exists(\Zend_Dom_Query::class)) {
$this->domQuery = new \Zend_Dom_Query($domDocument);
$this->initialized = true;
}
}
/**
* @param string $selector
*
* @return \Laminas\Dom\NodeList|array
*/
public function query($selector)
{
if ($this->domQuery) {
$result = $this->domQuery->{$this->executeMethod}($selector);
} else {
$result = [];
}
return $result;
}
/**
* @return string
*/
public function getDocument()
{
if ($this->domQuery) {
/** @var string|\DOMDocument $document */
$document = $this->domQuery->getDocument();
if (!is_string($document)) {
$document = $document->saveHTML();
}
} else {
$document = '';
}
return $document;
}
/**
* @return bool
*/
public function isInitialized()
{
return $this->initialized;
}
}
+56
View File
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model;
use Amasty\HidePrice\Helper\Data;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\Pricing\Render as PricingRender;
use Magento\Framework\Pricing\SaleableInterface;
class IsNeedRenderPrice
{
/**
* @var ConfigProvider
*/
private $configProvider;
/**
* @var Data
*/
private $helper;
public function __construct(
ConfigProvider $configProvider,
Data $helper
) {
$this->configProvider = $configProvider;
$this->helper = $helper;
}
public function execute(SaleableInterface $saleableItem, array $arguments): bool
{
// if Item not a product - show price
$isNotProduct = !($saleableItem instanceof ProductInterface);
// is current price block zone is not list, view or option
$isNoZone = (key_exists('zone', $arguments)
&& !in_array(
$arguments['zone'],
[PricingRender::ZONE_ITEM_LIST, PricingRender::ZONE_ITEM_VIEW, PricingRender::ZONE_ITEM_OPTION]
)
);
$isShowPrice = !$this->configProvider->isEnabled()
|| $isNotProduct
|| $isNoZone
|| !$this->helper->isNeedHideProduct($saleableItem);
return $isShowPrice;
}
}
+189
View File
@@ -0,0 +1,189 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model;
class Request extends \Magento\Framework\Model\AbstractModel implements \Amasty\HidePrice\Api\Data\RequestInterface
{
/**
* Model Init
*
* {@inheritdoc}
*/
protected function _construct()
{
parent::_construct();
$this->_init('Amasty\HidePrice\Model\ResourceModel\Request');
$this->setIdFieldName('request_id');
}
/**#@+
* Standard Getter and Setters start
*/
/**
* {@inheritdoc}
*/
public function getRequestId()
{
return $this->getData(self::REQUEST_ID);
}
/**
* {@inheritdoc}
*/
public function setRequestId($requestId)
{
return $this->setData(self::REQUEST_ID, $requestId);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return $this->getData(self::NAME);
}
/**
* {@inheritdoc}
*/
public function setName($name)
{
return $this->setData(self::NAME, $name);
}
/**
* {@inheritdoc}
*/
public function getProductId()
{
return $this->getData(self::PRODUCT_ID);
}
/**
* {@inheritdoc}
*/
public function setProductId($productId)
{
return $this->setData(self::PRODUCT_ID, $productId);
}
/**
* {@inheritdoc}
*/
public function getStoreId()
{
return $this->getData(self::STORE_ID);
}
/**
* {@inheritdoc}
*/
public function setStoreId($storeId)
{
return $this->setData(self::STORE_ID, $storeId);
}
/**
* {@inheritdoc}
*/
public function getEmail()
{
return $this->getData(self::EMAIL);
}
/**
* {@inheritdoc}
*/
public function setEmail($email)
{
return $this->setData(self::EMAIL, $email);
}
/**
* {@inheritdoc}
*/
public function getPhone()
{
return $this->getData(self::PHONE);
}
/**
* {@inheritdoc}
*/
public function setPhone($phone)
{
return $this->setData(self::PHONE, $phone);
}
/**
* {@inheritdoc}
*/
public function getComment()
{
return $this->getData(self::COMMENT);
}
/**
* {@inheritdoc}
*/
public function setComment($comment)
{
return $this->setData(self::COMMENT, $comment);
}
/**
* {@inheritdoc}
*/
public function getCreatedAt()
{
return $this->getData(self::CREATED_AT);
}
/**
* {@inheritdoc}
*/
public function setCreatedAt($flag)
{
return $this->setData(self::CREATED_AT, $flag);
}
/**
* {@inheritdoc}
*/
public function getStatus()
{
return $this->getData(self::STATUS);
}
/**
* {@inheritdoc}
*/
public function setStatus($status)
{
return $this->setData(self::STATUS, $status);
}
/**
* {@inheritdoc}
*/
public function getMessageText()
{
return $this->getData(self::MESSAGE_TEXT);
}
/**
* {@inheritdoc}
*/
public function setMessageText($text)
{
return $this->setData(self::MESSAGE_TEXT, $text);
}
/**#@-
* Standard Getter and Setters finish
*/
}
+109
View File
@@ -0,0 +1,109 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model;
use Amasty\HidePrice\Api\Data;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
class RequestRepository implements \Amasty\HidePrice\Api\RequestRepositoryInterface
{
/**
* @var array
*/
protected $request = [];
/**
* @var ResourceModel\Request
*/
private $requestResource;
/**
* @var RequestFactory
*/
private $requestFactory;
public function __construct(
\Amasty\HidePrice\Model\ResourceModel\Request $requestResource,
\Amasty\HidePrice\Model\RequestFactory $requestFactory
) {
$this->requestResource = $requestResource;
$this->requestFactory = $requestFactory;
}
/**
* {@inheritdoc}
*/
public function save(Data\RequestInterface $request)
{
if ($request->getRequestId()) {
$request = $this->get($request->getRequestId())->addData($request->getData());
}
try {
$this->requestResource->save($request);
unset($this->request[$request->getRequestId()]);
} catch (\Exception $e) {
if ($request->getRequestId()) {
throw new CouldNotSaveException(
__('Unable to save request with ID %1. Error: %2', [$request->getRequestId(), $e->getMessage()])
);
}
throw new CouldNotSaveException(__('Unable to save new request. Error: %1', $e->getMessage()));
}
return $request;
}
/**
* {@inheritdoc}
*/
public function get($requestId)
{
if (!isset($this->request[$requestId])) {
/** @var \Amasty\HidePrice\Model\Request $request */
$request = $this->requestFactory->create();
$this->requestResource->load($request, $requestId);
if (!$request->getRequestId()) {
throw new NoSuchEntityException(__('Request with specified ID "%1" not found.', $requestId));
}
$this->request[$requestId] = $request;
}
return $this->request[$requestId];
}
/**
* {@inheritdoc}
*/
public function delete(Data\RequestInterface $request)
{
try {
$this->requestResource->delete($request);
unset($this->request[$request->getRequestId()]);
} catch (\Exception $e) {
if ($request->getRequestId()) {
throw new CouldNotDeleteException(
__('Unable to remove request with ID %1. Error: %2', [$request->getRequestId(), $e->getMessage()])
);
}
throw new CouldNotDeleteException(__('Unable to remove request rule. Error: %1', $e->getMessage()));
}
return true;
}
/**
* {@inheritdoc}
*/
public function deleteById($requestId)
{
$model = $this->get($requestId);
$this->delete($model);
return true;
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\ResourceModel;
class Request extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Model Initialization
*
* @return void
*/
protected function _construct()
{
$this->_init('amasty_hideprice_request', 'request_id');
}
}
@@ -0,0 +1,32 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\ResourceModel\Request;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init(\Amasty\HidePrice\Model\Request::class, \Amasty\HidePrice\Model\ResourceModel\Request::class);
}
/**
* @param array $ids
*/
public function deleteByIds(array $ids)
{
$this->getConnection()->delete(
$this->getMainTable(),
['request_id IN(?)' => $ids]
);
}
}
+101
View File
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Store\Model\Store;
class Category implements OptionSourceInterface
{
public const NONE = 0;
public const SYSTEM_CATEGORY_ID = 0;
public const ROOT_LEVEL = 0;
/**
* @var CollectionFactory
*/
private $collectionFactory;
/**
* @var RequestInterface
*/
private $request;
public function __construct(
CollectionFactory $collectionFactory,
RequestInterface $request
) {
$this->collectionFactory = $collectionFactory;
$this->request = $request;
}
/**
* Options getter
*
* @return array
*/
public function toOptionArray(): array
{
$optionArray = [];
$arr = $this->toArray();
foreach ($arr as $value => $label) {
$optionArray[] = [
'value' => $value,
'label' => $label
];
}
return $optionArray;
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray(): array
{
return $this->getChildren(self::SYSTEM_CATEGORY_ID, self::ROOT_LEVEL);
}
/**
* @param $parentCategoryId
* @param $level
* @return array
*/
private function getChildren(int $parentCategoryId, int $level)
{
$storeId = (int) $this->request->getParam(Store::ENTITY, Store::DEFAULT_STORE_ID);
$options[self::NONE] = __('None');
$collection = $this->collectionFactory->create();
$collection->setStoreId($storeId);
$collection->addAttributeToSelect('name');
$collection->addAttributeToFilter('level', $level);
$collection->addAttributeToFilter('parent_id', $parentCategoryId);
$collection->setOrder('position', SortOrder::SORT_ASC);
foreach ($collection as $category) {
$options[$category->getId()] =
str_repeat(". ", max(0, ($category->getLevel() - 1) * 3)) . $category->getName();
if ($category->hasChildren()) {
$options = array_replace(
$options,
$this->getChildren((int) $category->getId(), $category->getLevel() + 1)
);
}
}
return $options;
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Option\ArrayInterface;
use Magento\Framework\DB\Select;
class CustomForm implements ArrayInterface
{
public const CUSTOMFORM_TABLE = 'amasty_customform_form';
/**
* @var ResourceConnection
*/
private $resource;
public function __construct(ResourceConnection $resource)
{
$this->resource = $resource;
}
/**
* @return array
*/
public function toOptionArray()
{
$options = [];
$connection = $this->resource->getConnection();
$tableName = $this->resource->getTableName(self::CUSTOMFORM_TABLE);
if ($connection->isTableExists($tableName)) {
$select = $connection->select()
->from($tableName)
->reset(Select::COLUMNS)
->columns(['value' => 'form_id', 'label' => 'title']);
$options = $connection->fetchAll($select);
}
return $options;
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Amasty\HidePrice\Helper\Data as Helper;
class Group extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Magento\Customer\Model\Customer\Attribute\Source\Group
*/
private $groupSource;
public function __construct(\Magento\Customer\Model\Customer\Attribute\Source\Group $groupSource)
{
$this->groupSource = $groupSource;
}
public function toOptionArray()
{
return array_merge(
[
[
'value' => Helper::DISABLED_GROUP_KEY,
'label' => __('NONE')
],
[
'value' => Helper::NOT_LOGGED_KEY,
'label' => __('NOT LOGGED IN')
]
],
$this->groupSource->getAllOptions()
);
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
$optionArray = $this->toOptionArray();
$labels = array_column($optionArray, 'label');
$values = array_column($optionArray, 'value');
return array_combine($values, $labels);
}
public function getAllOptions()
{
return $this->toOptionArray();
}
/**
* @return array
*/
public function getFlatColumns()
{
$columns = [];
$columns[$this->getAttribute()->getAttributeCode()] = [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => '255',
'unsigned' => false,
'nullable' => true,
'default' => null,
'extra' => null
];
return $columns;
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
class HideButton implements \Magento\Framework\Option\ArrayInterface
{
public const SHOW = 0;
public const HIDE = 1;
public const REPLACE_WITH_NEW_ONE = 2;
/**
* @return array
*/
public function toOptionArray()
{
$options = [
[
'value' => self::SHOW,
'label' => __('No')
],
[
'value' => self::HIDE,
'label' => __('Yes')
],
[
'value' => self::REPLACE_WITH_NEW_ONE,
'label' => __('Replace with custom button')
]
];
return $options;
}
}
+61
View File
@@ -0,0 +1,61 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
class PriceMode implements \Magento\Framework\Option\ArrayInterface
{
public const HIDE = 0;
public const SHOW = 1;
/**
* @return array
*/
public function toOptionArray()
{
$options = [
[
'value' => self::HIDE,
'label' => __('Hide')
],
[
'value' => self::SHOW,
'label' => __('Show')
]
];
return $options;
}
/**
* Rewrite method for using in mass update attribute
* @param $attribute
* @return $this
*/
public function setAttribute($attribute)
{
return $this;
}
/**
* Retrieve Full Option values array
*
* @param bool $withEmpty Add empty option to array
* @param bool $defaultValues
* @return array
*/
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
$options = $this->toOptionArray();
$options[] = [
'value' => '',
'label' => __('-- Default Config --')
];
return $options;
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Framework\Module\Manager;
use Magento\Framework\Option\ArrayInterface;
class ReplaceButton implements ArrayInterface
{
public const REDIRECT_URL = 0;
public const HIDE_PRICE_POPUP = 1;
public const CUSTOM_FORM = 2;
/**
* @var Manager
*/
private $moduleManager;
public function __construct(Manager $moduleManager)
{
$this->moduleManager = $moduleManager;
}
/**
* @return array
*/
public function toOptionArray()
{
$options = [
[
'value' => self::REDIRECT_URL,
'label' => __('Link to Custom URL')
],
[
'value' => self::HIDE_PRICE_POPUP,
'label' => __('Amasty Hide Price Popup')
],
[
'value' => self::CUSTOM_FORM,
'label' => __('Popup with Custom Form')
]
];
if ($this->moduleManager->isEnabled('Amasty_Customform') === false) {
$options[self::CUSTOM_FORM]['label'] .= ' (' . __('not installed') . ')';
}
return $options;
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
class Status implements \Magento\Framework\Option\ArrayInterface
{
public const PENDING = 0;
public const VIEWED = 1;
public const ANSWERED = 2;
/**
* @var array
*/
protected $options;
/**
* @return array
*/
public function toOptionArray()
{
if (!$this->options) {
$this->options = [
[
'value' => self::PENDING,
'label' => __('Pending')
],
[
'value' => self::VIEWED,
'label' => __('Viewed')
],
[
'value' => self::ANSWERED,
'label' => __('Answered')
]
];
}
return $this->options;
}
public function getOptionByValue($value)
{
$options = $this->toOptionArray();
foreach ($options as $option) {
if ($option['value'] == $value) {
return $option['label'];
}
}
return '';
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Source;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Option\ArrayInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Catalog\Model\Product;
class StockStatus implements ArrayInterface
{
/**
* @var array|null
*/
private $options = null;
/**
* @var AttributeRepositoryInterface
*/
private $attributeRepository;
public function __construct(AttributeRepositoryInterface $attributeRepository)
{
$this->attributeRepository = $attributeRepository;
}
/**
* @return array
*/
public function toOptionArray()
{
if (!isset($this->options)) {
$this->options = [];
try {
$attribute = $this->attributeRepository->get(Product::ENTITY, 'custom_stock_status');
$this->options = $attribute->getSource()->getAllOptions(false);
} catch (NoSuchEntityException $exception) {
$this->options = [];
}
array_unshift($this->options, [
'label' => __('NONE'),
'value' => ''
]);
}
return $this->options;
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model;
use Laminas\Validator\EmailAddress;
use Laminas\Validator\NotEmpty;
class Validator
{
/**
* @var EmailAddress
*/
private $emailAddressValidator;
/**
* @var NotEmpty
*/
private $notEmptyValidator;
public function __construct(
EmailAddress $emailAddressValidator,
NotEmpty $notEmptyValidator
) {
$this->emailAddressValidator = $emailAddressValidator;
$this->notEmptyValidator = $notEmptyValidator;
}
public function isValidEmail(string $email): bool
{
return $this->emailAddressValidator->isValid($email);
}
public function isNotEmpty(string $data): bool
{
return $this->notEmptyValidator->isValid($data);
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Model\Xsearch;
use Amasty\HidePrice\Helper\Data;
use Amasty\HidePrice\Model\ConfigProvider;
use Amasty\HidePrice\Model\IsNeedRenderPrice;
use Amasty\HidePrice\Plugin\Framework\Pricing\Render;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
class HidePopupData
{
public const IS_COMPARE_ALLOWED = 'amhideprice_is_compare_allowed';
public const IS_WISHLIST_ALLOWED = 'amhideprice_is_wishlist_allowed';
public const IS_ADD_TO_CART_ALLOWED = 'amhideprice_is_add_to_cart_allowed';
/**
* @var Render
*/
private $render;
/**
* @var ProductCollectionFactory
*/
private $productCollectionFactory;
/**
* @var IsNeedRenderPrice
*/
private $isNeedRenderPrice;
/**
* @var Data
*/
private $helper;
/**
* @var ConfigProvider
*/
private $configProvider;
public function __construct(
Render $render,
ProductCollectionFactory $productCollectionFactory,
IsNeedRenderPrice $isNeedRenderPrice,
Data $helper,
ConfigProvider $configProvider
) {
$this->render = $render;
$this->productCollectionFactory = $productCollectionFactory;
$this->isNeedRenderPrice = $isNeedRenderPrice;
$this->helper = $helper;
$this->configProvider = $configProvider;
}
public function execute(array $productsData): array
{
$ids = array_column($productsData, 'entity_id');
$collection = $this->productCollectionFactory->create();
$collection->addIdFilter($ids);
foreach ($collection as $product) {
$id = $product->getEntityId();
if (!$this->isNeedRenderPrice->execute($product, [])) {
$productsData[$id]['price'] = $this->helper->getNewPriceHtmlBox($product);
}
$isApplied = $this->helper->isApplied($product);
$productsData[$id][self::IS_COMPARE_ALLOWED] = !($this->configProvider->isHideCompare() && $isApplied);
$productsData[$id][self::IS_WISHLIST_ALLOWED] = !($this->configProvider->isHideWishlist() && $isApplied);
$productsData[$id][self::IS_ADD_TO_CART_ALLOWED]
= !($this->configProvider->isHideAddToCart() && $isApplied);
}
return $productsData;
}
}
@@ -0,0 +1,28 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Observer\Quickorder;
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
class AddHidePriceAttributesToCollection implements ObserverInterface
{
/**
* event name: amasty_quickorder_collection_load_before
*/
public function execute(Observer $observer): void
{
$collection = $observer->getCollection();
if ($collection instanceof ProductCollection) {
$collection->addAttributeToSelect('am_hide_price_mode');
$collection->addAttributeToSelect('am_hide_price_customer_gr');
}
}
}
@@ -0,0 +1,24 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Backend\Model\Menu;
class Item
{
public function aroundGetUrl(
\Magento\Backend\Model\Menu\Item $subject,
callable $proceed
) {
$result = $proceed();
/* hack for having correct url key ( we cant add params in menu.xml file)*/
if ($subject->getId() == 'Amasty_HidePrice::settings') {
$find = 'admin/system_config/edit';
$result = str_replace($find, $find . '/section/amasty_hide_price', $result);
}
return $result;
}
}
+50
View File
@@ -0,0 +1,50 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Bundle\Block;
class Option
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper
) {
$this->helper = $helper;
}
public function aroundRenderPriceString(
\Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option $subject,
\Closure $proceed,
$selection,
$includeContainer = true
) {
if ($this->helper->isNeedHideProduct($subject->getProduct())) {
return '';
}
return $proceed($selection, $includeContainer);
}
/**
* remove + symbal
* @param \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option $subject
* @param $result
* @return mixed
*/
public function afterGetSelectionTitlePrice(
\Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option $subject,
$result
) {
$result = str_replace('<span class="price-notice">+</span>', '', $result);
return $result;
}
}
@@ -0,0 +1,52 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Bundle\Helper\Catalog\Product;
use \Magento\Bundle\Helper\Catalog\Product\Configuration;
use \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
/**
* Class ConfigurationPlugin
*/
class ConfigurationPlugin
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper
) {
$this->helper = $helper;
}
/**
* @param Configuration $subject
* @param callable $proceed
* @param ItemInterface $item
* @return array
*/
public function aroundGetBundleOptions(Configuration $subject, callable $proceed, ItemInterface $item)
{
$options = $proceed($item);
if ($this->helper->isNeedHidePrice($item->getProduct())) {
foreach ($options as &$option) {
if (isset($option['value']) && is_array($option['value'])) {
$value = current($option['value']);
$pricePosition = strpos($value, '<span class="price">');
if ($pricePosition !== false) {
$option['value'] = [substr($value, 0, $pricePosition)];
}
}
}
}
return $options;
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product;
class Compare
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper
) {
$this->helper = $helper;
}
/**
* Hide add to Compare link
* @param $subject
* @param callable $proceed
* @return string
*/
public function aroundToHtml(
$subject,
callable $proceed
) {
if ($this->helper->getModuleConfig('information/hide_compare')
&& $this->helper->isApplied($subject->getProduct())
) {
return '';
}
return $proceed();
}
}
@@ -0,0 +1,217 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product\ProductList;
use Amasty\HidePrice\Helper\Data;
use Amasty\HidePrice\Model\Source\HideButton;
use Amasty\HidePrice\Model\DomWrapper;
use Amasty\HidePrice\Model\DomWrapperFactory;
class AbstractList
{
private $replacedJs;
/**
* @var Data
*/
private $helper;
/**
* @var \Magento\Framework\Registry
*/
private $coreRegistry;
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var DomWrapperFactory
*/
private $domWrapperFactory;
public function __construct(
Data $helper,
\Magento\Framework\Registry $coreRegistry,
DomWrapperFactory $domWrapperFactory,
\Psr\Log\LoggerInterface $logger
) {
$this->helper = $helper;
$this->coreRegistry = $coreRegistry;
$this->logger = $logger;
$this->domWrapperFactory = $domWrapperFactory;
}
/**
* replace "add to cart" button if it needed
*
* @param string $html
* @return string
*/
protected function replaceButtonFromHtml($html)
{
if ($this->helper->getModuleConfig('information/hide_button') && $html) {
try {
$html = $this->processReplace($html);
} catch (\Exception $exception) {
$this->logger->critical($exception->getMessage());
}
}
return $html;
}
/**
* replace "add to cart" button if it needed
*
* @param string $html
* @return string
*/
protected function processReplace($html)
{
$html = $this->replaceJsCode($html);
$dom = new \DOMDocument('1.0', 'HTML-ENTITIES');
libxml_use_internal_errors(true);
$charset = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
$dom->loadHTML($charset . $html);
/** @var DomWrapper $domQuery */
$domQuery = $this->domWrapperFactory->create();
$domQuery->setContent($dom);
if ($domQuery->isInitialized()) {
foreach ($this->getProductsData() as $productData) {
$result = $domQuery->query(
$this->generateSelector($productData)
);
if ($result && count($result)) {
$domDoc = $result->getDocument();
$result->rewind();
$result = $result->current();
$replacement = $this->helper->getNewAddToCartHtml(null, $productData);
if ($this->helper->getModuleConfig('information/hide_button') == HideButton::HIDE
&& $result->parentNode
&& $result->parentNode->tagName == 'form'
) {
$result->parentNode->removeChild($result);
} else {
$replacementElement = $result->ownerDocument->createDocumentFragment();
$replacementElement->appendXML(htmlentities($replacement));
$result->parentNode->replaceChild($replacementElement, $result);
}
$domQuery->setContent($domDoc);
}
}
$html = $this->getHtml($domQuery->getDocument());
}
//phpcs:ignore
$html = html_entity_decode($html);
$html = str_replace($charset, '', $html);
$html = $this->revertJsCode($html);
return $html;
}
/**
* @param string $html
*
* @return string
*/
protected function replaceJsCode($html)
{
$this->replacedJs = [];
if (strpos($html, '<script') !== false) {
$html = preg_replace_callback(
'#(\<script[^\>]*\>)(.*?)(\<\/script\>)#ims',
[$this, 'replaceJS'],
$html
);
}
return $html;
}
/**
* @param string $html
*
* @return string
*/
protected function revertJsCode($html)
{
foreach ($this->replacedJs as $key => $js) {
$html = str_replace('{{HIDEPRICE_' . $key . '}}', $js, $html);
}
return $html;
}
/**
* @param string $docDocument
* @return mixed|null|string|string[]
*/
private function getHtml($docDocument)
{
$fragment = str_replace(
['<html>', '</html>', '<body>', '</body>', '<head>', '</head>'],
'',
$docDocument
);
$fragment = preg_replace('/^<!DOCTYPE.+?>/', '', $fragment);
return $fragment;
}
/**
* @param $matches
* @return string
*/
private function replaceJS($matches)
{
$text = '';
if (count($matches) >= 4) {
$this->replacedJs[] = $matches[2];
$text = $matches[1] . '{{HIDEPRICE_' . (count($this->replacedJs) - 1) . '}}' . $matches[3];
} elseif (isset($matches[0])) {
$text = $matches[0];
}
return $text;
}
/**
* @return array
*/
private function getProductsData()
{
$dataArray = $this->coreRegistry->registry('amasty_hideprice_data_array');
if (!$dataArray || !is_array($dataArray)) {
$dataArray = [];
}
return $dataArray;
}
/**
* get selector for one product
*
* @param array $productData
* @return string
*/
private function generateSelector($productData)
{
return 'form[data-product-sku="' . $productData['sku']
. '"] > button, form[data-role="tocart-form"][action*="product/' . $productData['id']
. '"] > button';
}
}
@@ -0,0 +1,25 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product\ProductList;
use Magento\Catalog\Block\Product\ListProduct;
class Category extends AbstractList
{
/**
* @param ListProduct $subject
* @param $html
* @return string
*/
public function afterToHtml(ListProduct $subject, $html)
{
$html = $this->replaceButtonFromHtml($html);
return $html;
}
}
@@ -0,0 +1,25 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product\ProductList;
use Magento\CatalogWidget\Block\Product\ProductsList;
class Widget extends AbstractList
{
/**
* @param ProductsList $subject
* @param $html
* @return string
*/
public function afterToHtml(ProductsList $subject, $html)
{
$html = $this->replaceButtonFromHtml($html);
return $html;
}
}
@@ -0,0 +1,80 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product;
use Magento\Catalog\Block\Product\View as MagentoView;
class View
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\View\LayoutInterface
*/
private $layout;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper,
\Magento\Framework\View\LayoutInterface $layout
) {
$this->helper = $helper;
$this->layout = $layout;
}
/**
* Hide Add to cart Button
* @param MagentoView $subject
* @param $result
* @return string
*/
public function afterToHtml(
MagentoView $subject,
$result
) {
$matchedNames = [
'product.info.addtocart.additional',
'product.info.addtocart',
'product.info.addtocart.bundle'
];
if (in_array($subject->getNameInLayout(), $matchedNames)
&& $this->helper->getModuleConfig('information/hide_button')
&& $this->helper->isApplied($subject->getProduct())
) {
preg_match('@<button[^>]*amquote-addto-button.*?<\/button>@s', $result, $quoteCartButton);
$result = $this->helper->getNewAddToCartHtml($subject->getProduct());
if (isset($quoteCartButton[0])) {
//compatibility with Amasty Request a Quote
$buttonBlock = $this->layout->createBlock(\Amasty\RequestQuote\Block\Product\Action::class);
if ($buttonBlock) {
$result .= $buttonBlock->toHtml();
}
}
}
return $result;
}
/**
* Hide meta data
* @param MagentoView $subject
*/
public function beforeToHtml(
MagentoView $subject
) {
if ($subject->getNameInLayout() == 'opengraph.general'
&& $subject->getProduct()
&& $this->helper->isNeedHideProduct($subject->getProduct())
) {
$subject->getProduct()->setData('final_price', 0);
}
}
}
@@ -0,0 +1,46 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product\View\Options;
class AbstractOptions
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper
) {
$this->helper = $helper;
}
/**
* Hide option price html
* @param $subject
* @param callable $proceed
* @return string
*/
public function aroundGetFormatedPrice(
$subject,
callable $proceed
) {
if ($this->helper->isNeedHideProduct($subject->getProduct())) {
return '';
}
return $proceed();
}
public function afterGetValuesHtml($subject, $result)
{
$result = str_replace('<span class="price-notice">+</span>', '', $result);
return $result;
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Block\Product;
class Wishlist
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper
) {
$this->helper = $helper;
}
/**
* Hide Wishlist link
* @param $subject
* @param callable $proceed
* @return string
*/
public function aroundToHtml(
$subject,
callable $proceed
) {
if ($this->helper->getModuleConfig('information/hide_wishlist')
&& $this->helper->isApplied($subject->getProduct())
) {
return '';
}
return $proceed();
}
}
@@ -0,0 +1,35 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Model\Option;
class Value
{
/**
* @var \Amasty\HidePrice\Helper\Data
*/
private $helper;
public function __construct(
\Amasty\HidePrice\Helper\Data $helper
) {
$this->helper = $helper;
}
public function afterGetPrice(
$subject,
$result
) {
if ($this->helper->isNeedHideProduct($subject->getOption()->getProduct())
&& !$subject->getOption()->getDisableHideprice()
) {
return '';
}
return $result;
}
}
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Model\Product\Option\Type;
use Magento\Catalog\Model\Product\Option\Type\Select;
class DisableOptionsHidePriceInQuote
{
/**
* @see Select::getOptionPrice()
*
* @param Select $subject
* @param string $result
*
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeGetOptionPrice(Select $subject, string $result): void
{
$subject->getOption()->setData('disable_hideprice', true);
}
}
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Pricing\Price\FinalPrice;
use Amasty\HidePrice\Helper\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Framework\Pricing\Amount\AmountInterface;
use Magento\Framework\Pricing\Amount\BaseFactory as BaseAmountFactory;
use Magento\Framework\Registry;
class HideMinAndMaxPrice
{
/**
* @var Data
*/
private $helper;
/**
* @var Registry
*/
private $registry;
/**
* @var BaseAmountFactory
*/
private $baseAmountFactory;
public function __construct(
Data $helper,
Registry $registry,
BaseAmountFactory $baseAmountFactory
) {
$this->helper = $helper;
$this->registry = $registry;
$this->baseAmountFactory = $baseAmountFactory;
}
public function afterGetMinimalPrice(FinalPrice $subject, AmountInterface $result): AmountInterface
{
if ($this->isNeedHidePrice($subject->getProduct())) {
$result = $this->getZeroPrice();
}
return $result;
}
public function afterGetMaximalPrice(FinalPrice $subject, AmountInterface $result): AmountInterface
{
if ($this->isNeedHidePrice($subject->getProduct())) {
$result = $this->getZeroPrice();
}
return $result;
}
private function isNeedHidePrice(Product $product): bool
{
if ($this->helper->getModuleConfig('information/hide_price')
&& !$this->registry->registry('hideprice_off')
&& $this->helper->isApplied($product)
) {
return true;
}
return false;
}
private function getZeroPrice(): AmountInterface
{
return $this->baseAmountFactory->create(['amount' => 0]);
}
}
@@ -0,0 +1,36 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Catalog\Pricing\Tier;
use Magento\Catalog\Pricing\Price\TierPrice as NativeTierPrice;
use Magento\Framework\Pricing\Amount\AmountInterface;
class TierPrice
{
/**
* @param NativeTierPrice $subject
* @param \Closure $proceed
* @param AmountInterface $amount
*
* @return int|mixed
*/
public function aroundGetSavePercent(
NativeTierPrice $subject,
\Closure $proceed,
AmountInterface $amount
) {
$result = 0;
if ($subject->getProduct()
&& $subject->getProduct()->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()
) {
$result = $proceed($amount);;
}
return $result;
}
}
+59
View File
@@ -0,0 +1,59 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Conf;
use Amasty\Conf\Plugin\Product\View\Type\Configurable as ConfPlugin;
use Magento\Framework\Registry;
use Amasty\HidePrice\Helper\Data;
use Magento\Catalog\Model\Product;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType;
class Configurable
{
/**
* @var Data
*/
private $helper;
/**
* @var Registry
*/
private $registry;
public function __construct(
Data $helper,
Registry $registry
) {
$this->helper = $helper;
$this->registry = $registry;
}
/**
* @param ConfPlugin $subject
* @param $result
*
* @return mixed
*/
public function afterGetMatrixTitles(
ConfPlugin $subject,
$result
) {
/** @var Product $product */
$product = $this->registry->registry('current_product');
if ($product
&& $this->helper->getModuleConfig('information/hide_price')
&& $product->getTypeId() == ConfigurableType::TYPE_CODE
&& $this->helper->isApplied($product)
) {
unset($result['price']);
unset($result['subtotal']);
}
return $result;
}
}
@@ -0,0 +1,52 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Framework\Pricing\Price;
use Magento\Framework\Pricing\Price\AbstractPrice as NativePricing;
use Amasty\HidePrice\Helper\Data;
use Magento\Framework\Pricing\Amount\Base as BaseAmount;
use Magento\Framework\Registry;
class AbstractPrice
{
/**
* @var Data
*/
private $helper;
/**
* @var Registry
*/
private $registry;
public function __construct(Data $helper, Registry $registry)
{
$this->helper = $helper;
$this->registry = $registry;
}
/**
* @param NativePricing $subject
* @param $result
*
* @return BaseAmount
*/
public function afterGetAmount(
NativePricing $subject,
$result
) {
if ($this->helper->getModuleConfig('information/hide_price')
&& !$this->registry->registry('hideprice_off')
&& $this->helper->isApplied($subject->getProduct())
) {
$result = new BaseAmount(0);
}
return $result;
}
}
@@ -0,0 +1,244 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Framework\Pricing;
use Amasty\HidePrice\Helper\Data;
use Amasty\HidePrice\Model\IsNeedRenderPrice;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Customer\Model\Session;
use Magento\Framework\App\State;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Json\EncoderInterface;
use Magento\Framework\Pricing\Amount\AmountInterface;
use Magento\Framework\Pricing\Price\PriceInterface;
use Magento\Framework\Pricing\Render as PricingRender;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Framework\Registry;
use Magento\Store\Model\StoreManagerInterface;
class Render
{
/**
* @var Session
*/
private $customerSession;
/**
* @var StoreManagerInterface
*/
private $storeManager;
/**
* @var Registry
*/
private $coreRegistry;
/**
* @var ManagerInterface
*/
private $eventManager;
/**
* @var Data
*/
private $helper;
/**
* @var EncoderInterface
*/
private $jsonEncoder;
/**
* @var State
*/
private $state;
/**
* @var IsNeedRenderPrice
*/
private $isNeedRenderPrice;
public function __construct(
Session $customerSession,
StoreManagerInterface $storeManager,
Registry $coreRegistry,
ManagerInterface $eventManager,
EncoderInterface $jsonEncoder,
IsNeedRenderPrice $isNeedRenderPrice,
Data $helper,
State $state
) {
$this->customerSession = $customerSession;
$this->storeManager = $storeManager;
$this->coreRegistry = $coreRegistry;
$this->eventManager = $eventManager;
$this->helper = $helper;
$this->jsonEncoder = $jsonEncoder;
$this->state = $state;
$this->isNeedRenderPrice = $isNeedRenderPrice;
}
/**
* @param PricingRender $subject
* @param callable $proceed
* @param $priceCode
* @param SaleableInterface $saleableItem
* @param array $arguments
* @return string
*/
public function aroundRender(
PricingRender $subject,
callable $proceed,
$priceCode,
SaleableInterface $saleableItem,
array $arguments = []
) {
if (!$this->isNeedRenderPrice->execute($saleableItem, $arguments)
&& $this->state->getAreaCode() != \Magento\Framework\App\Area::AREA_ADMINHTML
&& $price = $this->renderPrice($saleableItem, $priceCode, $arguments)
) {
return $price;
}
return $proceed($priceCode, $saleableItem, $arguments);
}
public function renderPrice(SaleableInterface $saleableItem, string $priceCode, array $arguments = []): ?string
{
$this->saveDataToSession($saleableItem);
$additional = $this->generateJsHideOnCategory($saleableItem);
if ($this->helper->getModuleConfig('information/hide_price')) {
$priceHtml = $this->getNewPriceHtmlBox($saleableItem, $priceCode, $arguments);
$result = $priceHtml . $additional;
}
return $result ?? null;
}
/**
* @param PricingRender $subject
* @param callable $proceed
* @param AmountInterface $amount
* @param PriceInterface $price
* @param SaleableInterface $saleableItem
* @param array $arguments
* @return string
*/
public function aroundRenderAmount(
PricingRender $subject,
callable $proceed,
AmountInterface $amount,
PriceInterface $price,
SaleableInterface $saleableItem = null,
array $arguments = []
) {
if ($this->isNeedRenderPrice->execute($saleableItem, $arguments)) {
// Show Price Box
$result = $proceed($amount, $price, $saleableItem, $arguments);
return $result;
}
return '';
}
private function getNewPriceHtmlBox($saleableItem, $priceCode, $arguments)
{
$html = '';
/* get price replacement only for final price - others is hided*/
$arguments['id_suffix'] = isset($arguments['id_suffix']) ? $arguments['id_suffix'] : '';
if (in_array($priceCode, ['final_price', 'wishlist_configured_price']) && $arguments['id_suffix'] != 'copy-') {
$html = $this->helper->getNewPriceHtmlBox($saleableItem);
}
return $html;
}
/**
* @deprecated Hiding product button in another function
* Js for for hiding product button on category page
*
* @param $saleableItem
*
* @return string
* @internal param string $sku
* @internal param int $id
*/
private function generateJsHideOnCategory($saleableItem)
{
if ($saleableItem->getHidePriceObserved()) {
return;
}
$id = $saleableItem->getId();
$name = $saleableItem->getName();
$productId = 'amhideprice-product-id-' . $id . '-' . random_int(1, 10000);
// TODO - remove js code - button is replaced by observer
$html = '<span ' . Data::HIDE_PRICE_DATA_ROLE . ' id="'
. $productId . '" style="display: none !important;"></span>
<script>
require([
"jquery",
"Amasty_HidePrice/js/amhideprice"
], function ($, amhideprice) {
$( document ).ready(function() {
$("#' . $productId . '").amhideprice(' .
$this->jsonEncoder->encode([
'parent' => $this->helper->getModuleConfig('developer/parent'),
'button' => $this->helper->getModuleConfig('developer/addtocart'),
'html' => $this->helper->getNewAddToCartHtml(null, [
'id' => $id,
'name' => $name
]),
'hide_compare' => $this->helper->getModuleConfig('information/hide_compare'),
'hide_wishlist' => $this->helper->getModuleConfig('information/hide_wishlist'),
'hide_addtocart' => $this->helper->getModuleConfig('information/hide_button')
])
. ');
});
});
</script>';
$saleableItem->setHidePriceObserved(true);
return $html;
}
/**
* @param $saleableItem
*/
private function saveDataToSession(SaleableInterface $saleableItem)
{
$dataArray = $this->coreRegistry->registry('amasty_hideprice_data_array');
if (!$dataArray) {
$dataArray = [];
}
$dataArray[] = [
'sku' => $saleableItem->getSku(),
'id' => $saleableItem->getId(),
'name' => $saleableItem->getName()
];
$this->coreRegistry->unregister('amasty_hideprice_data_array');
$this->coreRegistry->register('amasty_hideprice_data_array', $dataArray);
}
/**
* @param string $html
* @param $saleableItem
* @return string
*/
private function updatePriceHtml($html, $saleableItem)
{
$html .= $this->generateJsHideOnCategory($saleableItem);
return $html;
}
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\GroupedProduct\Model\Product\Type\Grouped;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection;
use Magento\GroupedProduct\Model\Product\Type\Grouped;
class AddHidepriceAttributesToGroupedCollection
{
public function afterGetAssociatedProductCollection(Grouped $subject, Collection $collection): Collection
{
$collection->addAttributeToSelect(['am_hide_price_mode', 'am_hide_price_customer_gr']);
return $collection;
}
public function afterGetAssociatedProducts(Grouped $subject, array $result, Product $product): array
{
if ($product->getAmHidePriceMode() === '0') {
foreach ($result as $item) {
$item->setData('am_hide_price_mode', '0');
$item->setData('am_hide_price_customer_gr', $product->getAmHidePriceCustomerGr());
}
}
return $result;
}
}
@@ -0,0 +1,52 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Quote\Model;
use Amasty\HidePrice\Helper\Data;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Type\AbstractType;
use Magento\Framework\Exception\LocalizedException;
use Magento\Quote\Model\Quote;
class QuotePlugin
{
/**
* @var Data
*/
private $helper;
public function __construct(Data $helper)
{
$this->helper = $helper;
}
/**
* @param Quote $subject
* @param Product $product
* @param $request
* @param $processMode
*
* @return array
* @throws LocalizedException
*/
public function beforeAddProduct(
Quote $subject,
Product $product,
$request = null,
$processMode = AbstractType::PROCESS_MODE_FULL
) {
if (!$subject instanceof \Amasty\RequestQuote\Model\Quote
&& $this->helper->getHideAddToCart()
&& $this->helper->isApplied($product)
) {
throw new LocalizedException(__('Adding to the cart is disabled'));
}
return [$product, $request, $processMode];
}
}
@@ -0,0 +1,35 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\RequestQuote\Model\HidePrice;
use Amasty\HidePrice\Helper\Data;
use Magento\Catalog\Api\Data\ProductInterface;
class ProviderPlugin
{
/**
* @var Data
*/
private $helper;
public function __construct(Data $helper)
{
$this->helper = $helper;
}
/**
* @param \Amasty\RequestQuote\Model\HidePrice\Provider $subject
* @param bool $result
* @param ProductInterface $product
* @return bool
*/
public function afterIsHidePrice($subject, $result, ProductInterface $product)
{
return $this->helper->isNeedHidePrice($product);
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Wishlist\Model;
use Amasty\HidePrice\Helper\Data;
use Magento\Catalog\Model\Product;
use Magento\Framework\Exception\LocalizedException;
use Magento\Wishlist\Model\Wishlist;
use Magento\Catalog\Model\ProductRepository;
class WishlistPlugin
{
/**
* @var Data
*/
private $helper;
/**
* @var ProductRepository
*/
protected $productRepository;
public function __construct(
Data $helper,
ProductRepository $productRepository
) {
$this->helper = $helper;
$this->productRepository = $productRepository;
}
/**
* @param Wishlist $subject
* @param $product
* @param null $buyRequest
* @param bool $forciblySetQty
*
* @return array
* @throws LocalizedException
*/
public function beforeAddNewItem(Wishlist $subject, $product, $buyRequest = null, $forciblySetQty = false)
{
if (!$product instanceof Product) {
$product = $this->productRepository->getById($product);
}
if ($this->helper->getHideWishlist() && $this->helper->isApplied($product)) {
throw new LocalizedException(__('%1 can\'t be added to your wishlist', $product->getName()));
}
return [$product, $buyRequest, $forciblySetQty];
}
}
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product;
use Amasty\HidePrice\Helper\Data;
use Amasty\HidePrice\Model\ConfigProvider;
use Amasty\HidePrice\Model\Xsearch\HidePopupData;
use Amasty\Xsearch\Block\Search\Product as ProductBlock;
use Magento\Catalog\Model\ProductRepository;
/**
* @see \Amasty\Xsearch\Block\Search\Product::getAddToCart()
*/
class HideAddToCart
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetAddToCart(ProductBlock $subject, callable $proceed, array $productData = []): bool
{
$isCompareAllowed = $productData[HidePopupData::IS_ADD_TO_CART_ALLOWED] ?? true;
return $isCompareAllowed && $proceed();
}
}
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product;
use Amasty\HidePrice\Model\Xsearch\HidePopupData;
use Amasty\Xsearch\Block\Search\Product as ProductBlock;
/**
* @see \Amasty\Xsearch\Block\Search\Product::isCompareAllowed()
*/
class HideCompare
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundIsCompareAllowed(ProductBlock $subject, callable $proceed, array $productData): bool
{
$isCompareAllowed = $productData[HidePopupData::IS_COMPARE_ALLOWED] ?? true;
return $isCompareAllowed && $proceed();
}
}
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product;
use Amasty\HidePrice\Model\ConfigProvider;
use Amasty\HidePrice\Model\Xsearch\HidePopupData;
use Amasty\Xsearch\Block\Search\Product as ProductBlock;
/**
* @see \Amasty\Xsearch\Block\Search\Product::getProducts
*/
class HidePrice
{
/**
* @var HidePopupData
*/
private $hidePopupData;
/**
* @var ConfigProvider
*/
private $configProvider;
public function __construct(
HidePopupData $hidePopupData,
ConfigProvider $configProvider
) {
$this->hidePopupData = $hidePopupData;
$this->configProvider = $configProvider;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetProducts(ProductBlock $subject, array $productsData): array
{
return $this->configProvider->isEnabled() ? $this->hidePopupData->execute($productsData) : $productsData;
}
}
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product;
use Amasty\HidePrice\Helper\Data;
use Amasty\HidePrice\Model\ConfigProvider;
use Amasty\HidePrice\Model\Xsearch\HidePopupData;
use Amasty\Xsearch\Block\Search\Product as ProductBlock;
use Magento\Catalog\Model\ProductRepository;
/**
* @see \Amasty\Xsearch\Block\Search\Product::isWishlistAllowed()
*/
class HideWishlist
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundIsWishlistAllowed(ProductBlock $subject, callable $proceed, array $productData): bool
{
$isCompareAllowed = $productData[HidePopupData::IS_WISHLIST_ALLOWED] ?? true;
return $isCompareAllowed && $proceed();
}
}
@@ -0,0 +1,161 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Setup\Patch\Data;
use Amasty\HidePrice\Model\Source\Group;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Model\Entity\Attribute\Source\Boolean;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class CreateAttributes implements DataPatchInterface
{
private const HIDE_PRICE_MODE_ATTR = 'am_hide_price_mode';
private const HIDE_PRICE_CUSTOMER_GROUP_ATTR = 'am_hide_price_customer_gr';
private const HIDE_PRICE_MODE_CAT_ATTR = 'am_hide_price_mode_cat';
private const HIDE_PRICE_CUSTOMER_GROUP_CAT_ATTR = 'am_hide_price_customer_gr_cat';
/**
* @var EavSetup
*/
private $eavSetup;
public function __construct(
EavSetupFactory $eavSetupFactory,
ModuleDataSetupInterface $setup
) {
$this->eavSetup = $eavSetupFactory->create(['setup' => $setup]);
}
public function apply(): self
{
$this->addHidePriceModeAttr();
$this->addHidePriceCustomerGroupAttr();
$this->addHidePriceModeCatAttribute();
$this->addHidePriceCustomerGrCatAttr();
return $this;
}
private function addHidePriceCustomerGrCatAttr(): void
{
$this->eavSetup->addAttribute(
Category::ENTITY,
self::HIDE_PRICE_CUSTOMER_GROUP_CAT_ATTR,
[
'type' => 'text',
'backend' => ArrayBackend::class,
'label' => __('Use Current Price Mode By Customer Group'),
'input' => 'multiselect',
'required' => false,
'sort_order' => 4,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'wysiwyg_enabled' => false,
'is_html_allowed_on_front' => false,
'group' => __('General Information')
]
);
}
private function addHidePriceModeCatAttribute(): void
{
$this->eavSetup->addAttribute(
Category::ENTITY,
self::HIDE_PRICE_MODE_CAT_ATTR,
[
'type' => 'int',
'label' => __('Display Price Mode'),
'input' => 'select',
'required' => false,
'sort_order' => 4,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'wysiwyg_enabled' => false,
'is_html_allowed_on_front' => false,
'group' => __('General Information')
]
);
}
private function addHidePriceModeAttr(): void
{
$this->eavSetup->addAttribute(
Product::ENTITY,
self::HIDE_PRICE_MODE_ATTR,
[
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => __('Display Price Mode'),
'input' => 'select',
'class' => '',
'source' => Boolean::class,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'visible' => false,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'used_in_product_listing' => true,
'apply_to' => '',
'is_configurable' => false
]
);
}
private function addHidePriceCustomerGroupAttr(): void
{
$this->eavSetup->addAttribute(
Product::ENTITY,
self::HIDE_PRICE_CUSTOMER_GROUP_ATTR,
[
'type' => 'text',
'backend' => ArrayBackend::class,
'frontend' => '',
'label' => __('Use Current Price Mode By Customer Group'),
'input' => 'multiselect',
'class' => '',
'source' => Group::class,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'visible' => false,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'used_in_product_listing' => true,
'apply_to' => '',
'is_configurable' => false
]
);
}
public function getAliases(): array
{
return [];
}
public static function getDependencies(): array
{
return [];
}
}
+103
View File
@@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Setup\Patch\Data;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Product;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
/**
* Transfer data after changing attribute types
*/
class TransferData implements DataPatchInterface
{
private const HIDE_PRICE_CUSTOMER_GROUP_ATTR = 'am_hide_price_customer_gr';
private const HIDE_PRICE_CUSTOMER_GROUP_CAT_ATTR = 'am_hide_price_customer_gr_cat';
private const PRODUCT_ENTITY_VARCHAR_TABLE = 'catalog_product_entity_varchar';
private const PRODUCT_ENTITY_TEXT_TABLE = 'catalog_product_entity_text';
private const CATEGORY_ENTITY_VARCHAR_TABLE = 'catalog_category_entity_varchar';
private const CATEGORY_ENTITY_TEXT_TABLE = 'catalog_category_entity_text';
/**
* @var ModuleDataSetupInterface
*/
private $schemaSetup;
/**
* @var AttributeRepositoryInterface
*/
private $attributeRepository;
public function __construct(
ModuleDataSetupInterface $schemaSetup,
AttributeRepositoryInterface $attributeRepository
) {
$this->schemaSetup = $schemaSetup;
$this->attributeRepository = $attributeRepository;
}
public static function getDependencies(): array
{
return [CreateAttributes::class];
}
public function getAliases(): array
{
return [];
}
public function apply(): self
{
$this->moveProductAttributeData();
$this->moveCategoryAttributeData();
return $this;
}
private function moveProductAttributeData(): void
{
$attribute = $this->attributeRepository->get(Product::ENTITY, self::HIDE_PRICE_CUSTOMER_GROUP_ATTR);
$this->transferData(
self::PRODUCT_ENTITY_VARCHAR_TABLE,
self::PRODUCT_ENTITY_TEXT_TABLE,
(int)$attribute->getAttributeId()
);
}
private function moveCategoryAttributeData(): void
{
$attribute = $this->attributeRepository->get(Category::ENTITY, self::HIDE_PRICE_CUSTOMER_GROUP_CAT_ATTR);
$this->transferData(
self::CATEGORY_ENTITY_VARCHAR_TABLE,
self::CATEGORY_ENTITY_TEXT_TABLE,
(int)$attribute->getAttributeId()
);
}
private function transferData(string $fromTableName, string $toTableName, int $attributeId): void
{
$fromTable = $this->schemaSetup->getTable($fromTableName);
$toTable = $this->schemaSetup->getTable($toTableName);
$connection = $this->schemaSetup->getConnection();
$select = $connection->select()
->from($fromTable)
->where('attribute_id = ?', $attributeId);
$attributeValues = $connection->fetchAll($select);
foreach ($attributeValues as $value) {
unset($value['value_id']);
$connection->insert($toTable, $value);
}
}
}
@@ -0,0 +1,127 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Setup\Patch\Data;
use Amasty\HidePrice\Model\Source\ReplaceButton;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class UpdateSettings implements DataPatchInterface
{
private const TABLE_CORE_CONFIG_DATA = 'core_config_data';
private const REPLACE_LINK_SETTING_PATH = 'amasty_hide_price/information/replace_link';
private const REPLACE_WITH_SETTING_PATH = 'amasty_hide_price/information/replace_with';
private const REDIRECT_LINK_SETTING_PATH = 'amasty_hide_price/information/redirect_link';
public const FORM_SELECTOR = 'form[data-role="tocart-form"],';
public const NEW_FORM_SELECTOR = 'form[data-role="tocart-form"] button,';
public const ADD_TO_CART_SETTING_PATH = 'amasty_hide_price/developer/addtocart';
/**
* @var ModuleDataSetupInterface
*/
private $setup;
public function __construct(
ModuleDataSetupInterface $setup
) {
$this->setup = $setup;
}
public function apply(): self
{
$this->updateReplaceLinkSetting();
$this->updateAddToCartSetting();
return $this;
}
private function updateAddToCartSetting(): void
{
$connection = $this->setup->getConnection();
$tableName = $this->setup->getTable(self::TABLE_CORE_CONFIG_DATA);
$select = $this->setup->getConnection()->select()
->from($tableName, ['path', 'value', 'scope', 'scope_id', 'config_id'])
->where('path = ?', self::ADD_TO_CART_SETTING_PATH);
$replaceLinks = $connection->fetchAll($select);
foreach ($replaceLinks as $replaceLink) {
if (isset($replaceLink['value'])) {
if (strpos($replaceLink['value'], self::FORM_SELECTOR) !== false) {
$value = str_replace(self::FORM_SELECTOR, self::NEW_FORM_SELECTOR, $replaceLink['value']);
$connection->update(
$tableName,
['value' => $value],
['config_id = ?' => $replaceLink['config_id']]
);
}
}
}
}
private function updateReplaceLinkSetting(): void
{
$connection = $this->setup->getConnection();
$tableName = $this->setup->getTable(self::TABLE_CORE_CONFIG_DATA);
$select = $this->setup->getConnection()->select()
->from($tableName, ['path', 'value', 'scope', 'scope_id'])
->where('path = ?', self::REPLACE_LINK_SETTING_PATH);
$replaceLinks = $connection->fetchAll($select);
foreach ($replaceLinks as $replaceLink) {
if (isset($replaceLink['value'])) {
if ($replaceLink['value'] === 'AmastyHidePricePopup') {
$updateData[] = [
'value' => ReplaceButton::HIDE_PRICE_POPUP,
'path' => self::REPLACE_WITH_SETTING_PATH,
'scope' => $replaceLink['scope'],
'scope_id' => $replaceLink['scope_id']
];
} else {
$updateData[] = [
'value' => ReplaceButton::REDIRECT_URL,
'path' => self::REPLACE_WITH_SETTING_PATH,
'scope' => $replaceLink['scope'],
'scope_id' => $replaceLink['scope_id']
];
$updateData[] = [
'value' => $replaceLink['value'],
'path' => self::REDIRECT_LINK_SETTING_PATH,
'scope' => $replaceLink['scope'],
'scope_id' => $replaceLink['scope_id']
];
}
}
}
if (!empty($updateData)) {
$connection->insertOnDuplicate(
$tableName,
$updateData
);
}
}
public function getAliases(): array
{
return [];
}
public static function getDependencies(): array
{
return [];
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Setup;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UninstallInterface;
class Uninstall implements UninstallInterface
{
private const HIDE_PRICE_REQUEST_TABLE = 'amasty_hideprice_request';
public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context): void
{
$this->uninstallTables($setup);
$this->uninstallConfigData($setup);
}
private function uninstallTables(SchemaSetupInterface $setup): void
{
$tablesToDrop = [
self::HIDE_PRICE_REQUEST_TABLE
];
foreach ($tablesToDrop as $table) {
$setup->getConnection()->dropTable(
$setup->getTable($table)
);
}
}
private function uninstallConfigData(SchemaSetupInterface $setup): void
{
$configTable = $setup->getTable('core_config_data');
$setup->getConnection()->delete($configTable, "`path` LIKE 'amasty_hide_price%'");
}
}
@@ -0,0 +1,44 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
namespace Amasty\HidePrice\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\Catalog\Model\Locator\LocatorInterface;
class HidePrice extends AbstractModifier
{
/**
* @var LocatorInterface
*/
protected $locator;
/**
* @param LocatorInterface $locator
*/
public function __construct(
LocatorInterface $locator
) {
$this->locator = $locator;
}
public function modifyData(array $data)
{
$product = $this->locator->getProduct();
$modelId = $product->getId();
$data[$modelId][self::DATA_SOURCE_DEFAULT]['am_hide_price_mode'] = $product->getData('am_hide_price_mode');
$data[$modelId][self::DATA_SOURCE_DEFAULT]['am_hide_price_customer_gr']
= $product->getData('am_hide_price_customer_gr');
return $data;
}
public function modifyMeta(array $meta)
{
/* should be implement from Abstract class*/
return $meta;
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"name": "amasty/module-hide-price",
"description": "Hide Price by Amasty",
"require": {
"php": ">=7.3",
"amasty/base": ">=1.14.6",
"laminas/laminas-dom": "*"
},
"type": "magento2-module",
"version": "1.6.2",
"license": [
"proprietary"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Amasty\\HidePrice\\": ""
}
}
}
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Amasty_HidePrice::config"
title="Amasty Hide Price Settings"
sortOrder="100115" />
</resource>
</resource>
</resource>
<resource id="Magento_Backend::marketing">
<resource id="Amasty_HidePrice::request" title="Amasty Hide Price" sortOrder="100116" />
</resource>
</resource>
</resources>
</acl>
</config>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="amasty-hide-price" xsi:type="array">
<item name="class" xsi:type="string">Amasty\HidePrice\Ui\DataProvider\Product\Form\Modifier\HidePrice</item>
<item name="sortOrder" xsi:type="number">30</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="Magento\Backend\Model\Menu\Item">
<plugin name="Amasty_HidePrice:correct-configuration-url"
type="Amasty\HidePrice\Plugin\Backend\Model\Menu\Item" />
</type>
<type name="Amasty\HidePrice\Model\Config\Backend\Popup\Customform">
<arguments>
<argument name="data" xsi:type="array">
<item name="module_manager" xsi:type="object">Magento\Framework\Module\Manager</item>
</argument>
</arguments>
</type>
</config>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Amasty_HidePrice::request" title="Hide Price" module="Amasty_HidePrice" sortOrder="80"
parent="Magento_Backend::marketing"
resource="Amasty_HidePrice::request"/>
<add id="Amasty_HidePrice::request_manage" title="Get a Quote Requests" module="Amasty_HidePrice" sortOrder="10"
parent="Amasty_HidePrice::request"
action="amasty_hideprice/request/"
resource="Amasty_HidePrice::request"/>
<add id="Amasty_HidePrice::settings" title="Configuration" module="Amasty_HidePrice" sortOrder="20"
parent="Amasty_HidePrice::request"
action="adminhtml/system_config/edit/"
resource="Amasty_HidePrice::config"/>
</menu>
</config>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="amasty_hideprice" frontName="amasty_hideprice">
<module name="Amasty_HidePrice" />
</route>
</router>
</config>
+252
View File
@@ -0,0 +1,252 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="amasty_hide_price" translate="label" type="text" sortOrder="130115" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Hide Price</label>
<tab>amasty</tab>
<resource>Amasty_HidePrice::config</resource>
<group id="amasty_information" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Information</label>
<frontend_model>Amasty\HidePrice\Block\Adminhtml\System\Config\Information</frontend_model>
</group>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>General Settings</label>
<field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Enable Extension</label>
<comment>Choose ‘Yes’ to hide the price for the selected product categories and customer groups</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="customer_group" translate="label comment" type="multiselect" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide Price for Selected Group(s)</label>
<comment>Product price will be hidden for the selected customer groups only</comment>
<source_model>Amasty\HidePrice\Model\Source\Group</source_model>
</field>
<field id="category" translate="label comment" type="multiselect" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide Price for Selected Category(s)</label>
<comment>Product price will be hidden for the selected product categories only</comment>
<source_model>Amasty\HidePrice\Model\Source\Category</source_model>
</field>
<field id="ignore_products" translate="label comment" type="text" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Do not Apply to Product ID’s</label>
<comment>Specify comma separated product id’s to show the price for. This setting has the maximum priority</comment>
</field>
<field id="ignore_customer" translate="label comment" type="text" sortOrder="40" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Do not Apply to Customer ID’s</label>
<comment>Specify comma separated customer id’s to show price for. This setting has the maximum priority</comment>
</field>
<field id="sender" translate="label" type="select" sortOrder="50" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Email Sender for Admin Reply Email</label>
<source_model>Magento\Config\Model\Config\Source\Email\Identity</source_model>
</field>
<field id="template" translate="label comment" type="select" sortOrder="60" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Email Template for Admin Reply Email</label>
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
<comment>Email template chosen based on theme fallback when "Default" option is selected</comment>
</field>
</group>
<group id="information" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Hide Price Options</label>
<field id="hide_price" translate="label" type="select" sortOrder="40" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide Price</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="hide_button" translate="label comment" type="select" sortOrder="50" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide "Add to Cart"</label>
<comment>Hide ‘Add to Cart’ or replace it with the custom button, e.g. ‘Sign up’ or ‘Get a Quote’</comment>
<source_model>Amasty\HidePrice\Model\Source\HideButton</source_model>
</field>
<field id="replace_text" translate="label" type="text" sortOrder="60" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Replace "Add to Cart" Title with</label>
<depends>
<field id="hide_button">2</field>
</depends>
</field>
<field id="replace_with" translate="label" type="select" sortOrder="65" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Replace "Add to Cart" Link with</label>
<source_model>Amasty\HidePrice\Model\Source\ReplaceButton</source_model>
<backend_model>Amasty\HidePrice\Model\Config\Backend\Popup\Customform</backend_model>
<depends>
<field id="hide_button">2</field>
</depends>
</field>
<field id="redirect_link" translate="label" type="text" sortOrder="67" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Custom URL</label>
<depends>
<field id="hide_button">2</field>
<field id="replace_with">0</field>
</depends>
</field>
<field id="custom_form" translate="label" type="select" sortOrder="67" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Custom Form</label>
<source_model>Amasty\HidePrice\Model\Source\CustomForm</source_model>
<depends>
<field id="hide_button">2</field>
<field id="replace_with">2</field>
</depends>
</field>
<field id="replace_css" translate="label" type="textarea" sortOrder="65" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Css Styles for Replaced Link</label>
<comment>Customize the CSS Styles for the replaced Link</comment>
<depends>
<field id="hide_button">2</field>
</depends>
</field>
<field id="hide_wishlist" translate="label comment" type="select" sortOrder="80" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide "Add to Wishlist"</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Hide wishlist link when price is hidden</comment>
</field>
<field id="hide_compare" translate="label" type="select" sortOrder="90" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide "Add to Compare"</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Hide compare link when price is hidden</comment>
</field>
</group>
<group id="frontend" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Frontend Options</label>
<field id="text" translate="label comment" type="textarea" sortOrder="10" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Hide Price Text</label>
<comment>Display the above text when price is hidden, e.g. ‘Call for Price’</comment>
</field>
<field id="custom_css" translate="label comment" type="textarea" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Custom CSS Styles for Hide Price Link</label>
<comment>Customize the CSS Styles for the Hide Price Link</comment>
</field>
<field id="image" translate="label comment" type="image" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Upload Image</label>
<backend_model>Magento\Config\Model\Config\Backend\Image</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">amasty/hide_price</upload_dir>
<base_url type="media" scope_info="1">amasty/hide_price</base_url>
<comment>Show the uploaded image instead of price</comment>
</field>
<field id="link" translate="label comment" type="text" sortOrder="40" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Link Url</label>
<comment>Use text ‘AmastyHidePricePopup’ for opening Ajax Popup with a ‘Get a Quote’ form. Insert the page URL to redirect customers to any page you need</comment>
</field>
</group>
<group id="admin_email" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Admin Email Notifications</label>
<field id="to" translate="label comment" type="text" sortOrder="10" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Send Email to</label>
<comment>Leave Empty to Disable Notifications</comment>
</field>
<field id="sender" translate="label" type="select" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Email Sender</label>
<source_model>Magento\Config\Model\Config\Source\Email\Identity</source_model>
</field>
<field id="template" translate="label comment" type="select" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Email Template</label>
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
<comment>Email template chosen based on theme fallback when "Default" option is selected</comment>
</field>
</group>
<group id="reply_email" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Auto Reply Email Options</label>
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="sender" translate="label" type="select" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Email Sender</label>
<source_model>Magento\Config\Model\Config\Source\Email\Identity</source_model>
</field>
<field id="template" translate="label comment" type="select" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Email Template</label>
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
<comment>Email template chosen based on theme fallback when "Default" option is selected</comment>
</field>
</group>
<group id="gdpr" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>GDPR Consent</label>
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="text" translate="label" type="textarea" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Сonsent Text</label>
<depends>
<field id="enabled">1</field>
</depends>
</field>
</group>
<group id="stock_status" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Stock Status</label>
<field id="stock_status" translate="label comment" type="multiselect" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Hide Price for Custom Stock Status</label>
<comment>Installation of Amasty Custom Stock Status module is required</comment>
<source_model>Amasty\HidePrice\Model\Source\StockStatus</source_model>
</field>
</group>
<group id="developer" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1"
showInStore="0">
<label>Developer Options</label>
<comment>These options need to be changed if you are using a custom Magento theme</comment>
<field id="addtocart" translate="label comment" type="text" sortOrder="10" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>"Add to Cart" Selector</label>
<comment>Default value: form[data-role="tocart-form"], button.tocart</comment>
</field>
<field id="parent" translate="label" type="text" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Category Item Selector</label>
</field>
</group>
</section>
</system>
</config>
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<amasty_hide_price>
<general>
<enabled>0</enabled>
<customer_group>0</customer_group>
<category>1</category>
</general>
<information>
<hide_price>1</hide_price>
<hide_button>1</hide_button>
<replace_text>Sign up</replace_text>
<replace_link>/customer/account</replace_link>
<replace_css>background: #eeeeee;
border: 1px solid #cccccc;
color: #333333;
cursor: pointer;
display: inline-block;
padding: 7px 15px;
margin-right: 15px;
font-size: 1.4rem;
line-height: 1.6rem;
</replace_css>
<hide_wishlist>1</hide_wishlist>
<hide_compare>1</hide_compare>
</information>
<frontend>
<text>Call for Price</text>
<custom_css>background: #eeeeee;
border: 1px solid #cccccc;
color: #333333;
cursor: pointer;
display: inline-block;
padding: 7px 15px;
margin-right: 15px;
font-size: 1.4rem;
line-height: 1.6rem;
margin-bottom: 10px;
</custom_css>
<link>AmastyHidePricePopup</link>
</frontend>
<reply_email>
<enabled>1</enabled>
</reply_email>
<gdpr>
<enabled>0</enabled>
<text><![CDATA[I have read & accept the <a target="_blank" href="/privacy-policy">Privacy Policy</a>]]></text>
</gdpr>
<developer>
<addtocart>form[data-role="tocart-form"] button, button.tocart</addtocart>
<parent>.product-item, .item, td</parent>
</developer>
</amasty_hide_price>
</default>
</config>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="amasty_hideprice_request" resource="default" engine="innodb" comment="Amasty Hide price Requests">
<column xsi:type="int" name="request_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Request Id"/>
<column xsi:type="varchar" name="name" nullable="false" length="255" comment="Name"/>
<column xsi:type="varchar" name="email" nullable="false" length="255" comment="Email"/>
<column xsi:type="varchar" name="phone" nullable="false" length="255" comment="Phone"/>
<column xsi:type="int" name="product_id" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Product id"/>
<column xsi:type="smallint" name="store_id" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Store id"/>
<column xsi:type="text" name="comment" nullable="false" comment="Comment"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Creation Time"/>
<column xsi:type="smallint" name="status" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Status"/>
<column xsi:type="text" name="message_text" nullable="false" comment="Message Text"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="request_id"/>
</constraint>
</table>
</schema>
+19
View File
@@ -0,0 +1,19 @@
{
"amasty_hideprice_request": {
"column": {
"request_id": true,
"name": true,
"email": true,
"phone": true,
"product_id": true,
"store_id": true,
"comment": true,
"created_at": true,
"status": true,
"message_text": true
},
"constraint": {
"PRIMARY": true
}
}
}
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
</config>
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
<template id="amasty_hide_price_admin_email_template"
label="Amasty Hide Price Admin Notification"
file="amasty_hideprice_admin_notification.html"
type="html"
module="Amasty_HidePrice"
area="frontend"
/>
<template id="amasty_hide_price_reply_email_template"
label="Amasty Hide Price Auto Reply"
file="amasty_hideprice_auto_reply.html"
type="html"
module="Amasty_HidePrice"
area="frontend"
/>
<template id="amasty_hide_price_general_template"
label="Amasty Hide Price Admin Answer"
file="amasty_hideprice_admin_answer.html"
type="html"
module="Amasty_HidePrice"
area="frontend"
/>
</config>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="amasty_quickorder_collection_load_before">
<observer name="amasty_quickorder_collection_load_before" instance="Amasty\HidePrice\Observer\QuickOrder\AddHidePriceAttributesToCollection" />
</event>
</config>
+126
View File
@@ -0,0 +1,126 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Block\Product\View">
<plugin name="Amasty_HidePrice:hide_button" type="Amasty\HidePrice\Plugin\Catalog\Block\Product\View" />
</type>
<type name="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare">
<plugin name="Amasty_HidePrice:hide_compare_list" type="Amasty\HidePrice\Plugin\Catalog\Block\Product\Compare" />
</type>
<type name="Magento\Catalog\Block\Product\View\AddTo\Compare">
<plugin name="Amasty_HidePrice:hide_compare_view" type="Amasty\HidePrice\Plugin\Catalog\Block\Product\Compare" />
</type>
<type name="Magento\Wishlist\Block\Catalog\Product\ProductList\Item\AddTo\Wishlist">
<plugin name="Amasty_HidePrice:hide_wishlist_list" type="Amasty\HidePrice\Plugin\Catalog\Block\Product\Wishlist" />
</type>
<type name="Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist">
<plugin name="Amasty_HidePrice:hide_wishlist_view" type="Amasty\HidePrice\Plugin\Catalog\Block\Product\Wishlist" />
</type>
<type name="Magento\Catalog\Block\Product\View\Options\AbstractOptions">
<plugin name="Amasty_HidePrice:hide_custom_option_price"
type="Amasty\HidePrice\Plugin\Catalog\Block\Product\View\Options\AbstractOptions" />
</type>
<type name="Magento\Catalog\Model\Product\Option\Value">
<plugin name="Amasty_HidePrice:hide_custom_option_price_select"
type="Amasty\HidePrice\Plugin\Catalog\Model\Option\Value" />
</type>
<type name="Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option">
<plugin name="Amasty_HidePrice:hide_custom_option_bundle"
type="Amasty\HidePrice\Plugin\Bundle\Block\Option" />
</type>
<type name="Magento\Catalog\Block\Product\ListProduct">
<plugin name="Amasty_HidePrice:hide_button_backend_category"
type="Amasty\HidePrice\Plugin\Catalog\Block\Product\ProductList\Category" />
</type>
<type name="Magento\CatalogWidget\Block\Product\ProductsList">
<plugin name="Amasty_HidePrice:hide_button_backend_widget"
type="Amasty\HidePrice\Plugin\Catalog\Block\Product\ProductList\Widget" />
</type>
<type name="Magento\Framework\Pricing\Price\AbstractPrice">
<plugin name="Amasty_HidePrice::price_hide" type="Amasty\HidePrice\Plugin\Framework\Pricing\Price\AbstractPrice" />
</type>
<type name="Amasty\Conf\Plugin\Product\View\Type\Configurable">
<plugin name="Amasty_HidePrice::remove_price_column" type="Amasty\HidePrice\Plugin\Conf\Configurable" />
</type>
<type name="Magento\Catalog\Pricing\Price\TierPrice">
<plugin name="Amasty_HidePrice::disable-tier" type="Amasty\HidePrice\Plugin\Catalog\Pricing\Tier\TierPrice" />
</type>
<type name="Amasty\RequestQuote\Model\HidePrice\Provider">
<plugin name="Amasty_HidePrice::resolve-hide-info" type="Amasty\HidePrice\Plugin\RequestQuote\Model\HidePrice\ProviderPlugin" />
</type>
<type name="Magento\Bundle\Helper\Catalog\Product\Configuration">
<plugin name="Amasty_HidePrice::hide-bundle-options" type="Amasty\HidePrice\Plugin\Bundle\Helper\Catalog\Product\ConfigurationPlugin" />
</type>
<type name="Magento\Quote\Model\Quote">
<plugin name="Amasty_HidePrice::disable_add_to_cart" type="Amasty\HidePrice\Plugin\Quote\Model\QuotePlugin" />
</type>
<type name="Magento\Wishlist\Model\Wishlist">
<plugin name="Amasty_HidePrice::disable_add_to_wishlist" type="Amasty\HidePrice\Plugin\Wishlist\Model\WishlistPlugin" />
</type>
<type name="Magento\Catalog\Model\Product\Option\Type\Select">
<plugin name="Amasty_HidePrice::disable_hideprice_for_options_in_quote"
type="Amasty\HidePrice\Plugin\Catalog\Model\Product\Option\Type\DisableOptionsHidePriceInQuote"/>
</type>
<type name="Magento\GroupedProduct\Model\Product\Type\Grouped">
<plugin name="Amasty_HidePrice::add-hideprice-attributes-to-grouped-collection"
type="Amasty\HidePrice\Plugin\GroupedProduct\Model\Product\Type\Grouped\AddHidepriceAttributesToGroupedCollection"/>
</type>
<type name="\Amasty\Xsearch\Block\Search\Product">
<plugin name="Amasty_HidePrice:hide_price_xsearch_popup"
type="Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product\HidePrice" />
</type>
<type name="Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product\HidePrice">
<arguments>
<argument name="hide_popup_data" xsi:type="object">Amasty\HidePrice\Model\Xsearch\HidePopupData\Proxy</argument>
</arguments>
</type>
<type name="\Amasty\Xsearch\Block\Search\Product">
<plugin name="Amasty_HidePrice:hide_wishlist_xsearch_popup"
type="Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product\HideWishlist" />
</type>
<type name="\Amasty\Xsearch\Block\Search\Product">
<plugin name="Amasty_HidePrice:hide_compare_xsearch_popup"
type="Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product\HideCompare" />
</type>
<type name="Magento\Framework\Pricing\Render">
<plugin name="Amasty_HidePrice:product_price_hide" type="Amasty\HidePrice\Plugin\Framework\Pricing\Render" />
</type>
<type name="\Amasty\Xsearch\Block\Search\Product">
<plugin name="Amasty_HidePrice:hide_add_to_cart_xsearch_popup"
type="Amasty\HidePrice\Plugin\Xsearch\Block\Search\Product\HideAddToCart" />
</type>
<type name="Magento\Catalog\Pricing\Price\FinalPrice">
<plugin name="Amasty_HidePrice::hide_min_and_max_price"
type="Amasty\HidePrice\Plugin\Catalog\Pricing\Price\FinalPrice\HideMinAndMaxPrice"/>
</type>
</config>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="amasty_hide_price" frontName="amasty_hide_price">
<module name="Amasty_HidePrice" />
</route>
</router>
</config>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Amasty_HidePrice">
<sequence>
<module name="Magento_Catalog" />
</sequence>
</module>
</config>
+147
View File
@@ -0,0 +1,147 @@
"Hide Price","Hide Price"
Change,Change
"Get a Quote Requests","Get a Quote Requests"
"Send Email","Send Email"
Back,Back
Delete,Delete
"You are about to delete this request. Are you sure you want to do that?","You are about to delete this request. Are you sure you want to do that?"
"Customer Name","Customer Name"
"Customer Email","Customer Email"
"Customer Phone","Customer Phone"
Product,Product
Store,Store
Created,Created
Status,Status
Comment,Comment
"Admin Answer Text","Admin Answer Text"
"Please update Amasty Base module. Re-upload it and replace all the files.","Please update Amasty Base module. Re-upload it and replace all the files."
"Laminas DOM package is not installed (The package is required for hiding ""Add to Cart"" button on Category Page). Please, run the following command in the SSH: composer require laminas/laminas-dom","Laminas DOM package is not installed (The package is required for hiding ""Add to Cart"" button on Category Page). Please, run the following command in the SSH: composer require laminas/laminas-dom"
"Amasty Hide Price","Amasty Hide Price"
Requests,Requests
"Request was deleted.","Request was deleted."
"Can't delete item right now. Please review the log and try again.","Can't delete item right now. Please review the log and try again."
"Can't find a item to delete.","Can't find a item to delete."
"This request no longer exists.","This request no longer exists."
"Get a Quote Request from ","Get a Quote Request from "
"Please select items.","Please select items."
"Get a Quote requests are deleted.","Get a Quote requests are deleted."
"Can't delete items right now. Please review the log and try again.","Can't delete items right now. Please review the log and try again."
"Please enter a Email Text.","Please enter a Email Text."
"Email Answer was sent.","Email Answer was sent."
"Please select request id.","Please select request id."
"Sorry. There is a problem with Your Quote Request. Please try again or use Contact Us link in the menu.","Sorry. There is a problem with Your Quote Request. Please try again or use Contact Us link in the menu."
"Thanks for contacting us. We'll respond to you as soon as possible. ","Thanks for contacting us. We'll respond to you as soon as possible. "
"Form key is not valid. Please try to reload the page.","Form key is not valid. Please try to reload the page."
"Please enter a valid email address.","Please enter a valid email address."
"Please enter a name.","Please enter a name."
"Please enter a phone.","Please enter a phone."
"There are no product for your request.","There are no product for your request."
"Please agree to the Privacy Policy","Please agree to the Privacy Policy"
"Custom Forms module was not installed.","Custom Forms module was not installed."
"Unable to save request with ID %1. Error: %2","Unable to save request with ID %1. Error: %2"
"Unable to save new request. Error: %1","Unable to save new request. Error: %1"
"Request with specified ID ""%1"" not found.","Request with specified ID ""%1"" not found."
"Unable to remove request with ID %1. Error: %2","Unable to remove request with ID %1. Error: %2"
"Unable to remove request rule. Error: %1","Unable to remove request rule. Error: %1"
None,None
NONE,NONE
"NOT LOGGED IN","NOT LOGGED IN"
No,No
Yes,Yes
"Replace with custom button","Replace with custom button"
Hide,Hide
Show,Show
"-- Default Config --","-- Default Config --"
"Link to Custom URL","Link to Custom URL"
"Amasty Hide Price Popup","Amasty Hide Price Popup"
"Popup with Custom Form","Popup with Custom Form"
"not installed","not installed"
Pending,Pending
Viewed,Viewed
Answered,Answered
"Adding to the cart is disabled","Adding to the cart is disabled"
"%1 can't be added to your wishlist","%1 can't be added to your wishlist"
"Use Current Price Mode By Customer Group","Use Current Price Mode By Customer Group"
"General Information","General Information"
"Display Price Mode","Display Price Mode"
"Get a Quote Information","Get a Quote Information"
"Email Text","Email Text"
"If you use Custom Form for Get a Quote Requests please click <a href=""%1"">here</a> to review the submitted data.","If you use Custom Form for Get a Quote Requests please click <a href=""%1"">here</a> to review the submitted data."
"Get a Quote for","Get a Quote for"
"Phone Number","Phone Number"
GDPR,GDPR
Submit,Submit
"Hello %name,","Hello %name,"
"Sincerely, %store Team.","Sincerely, %store Team."
"You have a new quote request placed by","You have a new quote request placed by"
"Request details:","Request details:"
"Name: %name","Name: %name"
"Email: %email","Email: %email"
"Phone Number: %phone","Phone Number: %phone"
"Product: %product","Product: %product"
"Comment: %comment","Comment: %comment"
"Best Regards, %store Team.","Best Regards, %store Team."
"Thank you for contacting us!","Thank you for contacting us!"
"Your quote request is being processed at the moment.","Your quote request is being processed at the moment."
"We’ll get back to you as soon as possible","We’ll get back to you as soon as possible"
Information,Information
"General Settings","General Settings"
"Enable Extension","Enable Extension"
"Choose ‘Yes’ to hide the price for the selected product categories and customer groups","Choose ‘Yes’ to hide the price for the selected product categories and customer groups"
"Hide Price for Selected Group(s)","Hide Price for Selected Group(s)"
"Product price will be hidden for the selected customer groups only","Product price will be hidden for the selected customer groups only"
"Hide Price for Selected Category(s)","Hide Price for Selected Category(s)"
"Product price will be hidden for the selected product categories only","Product price will be hidden for the selected product categories only"
"Do not Apply to Product ID’s","Do not Apply to Product ID’s"
"Specify comma separated product id’s to show the price for. This setting has the maximum priority","Specify comma separated product id’s to show the price for. This setting has the maximum priority"
"Do not Apply to Customer ID’s","Do not Apply to Customer ID’s"
"Specify comma separated customer id’s to show price for. This setting has the maximum priority","Specify comma separated customer id’s to show price for. This setting has the maximum priority"
"Email Sender for Admin Reply Email","Email Sender for Admin Reply Email"
"Email Template for Admin Reply Email","Email Template for Admin Reply Email"
"Email template chosen based on theme fallback when ""Default"" option is selected","Email template chosen based on theme fallback when ""Default"" option is selected"
"Hide Price Options","Hide Price Options"
"Hide ""Add to Cart""","Hide ""Add to Cart"""
"Hide ‘Add to Cart’ or replace it with the custom button, e.g. ‘Sign up’ or ‘Get a Quote’","Hide ‘Add to Cart’ or replace it with the custom button, e.g. ‘Sign up’ or ‘Get a Quote’"
"Replace ""Add to Cart"" Title with","Replace ""Add to Cart"" Title with"
"Replace ""Add to Cart"" Link with","Replace ""Add to Cart"" Link with"
"Custom URL","Custom URL"
"Custom Form","Custom Form"
"Css Styles for Replaced Link","Css Styles for Replaced Link"
"Hide ""Add to Wishlist""","Hide ""Add to Wishlist"""
"Hide wishlist link when price is hidden","Hide wishlist link when price is hidden"
"Hide ""Add to Compare""","Hide ""Add to Compare"""
"Frontend Options","Frontend Options"
"Hide Price Text","Hide Price Text"
"Display the above text when price is hidden, e.g. ‘Call for Price’","Display the above text when price is hidden, e.g. ‘Call for Price’"
"Custom CSS Styles for Hide Price Link","Custom CSS Styles for Hide Price Link"
"Customize the CSS Styles for the Hide Price Link","Customize the CSS Styles for the Hide Price Link"
"Upload Image","Upload Image"
"Show the uploaded image instead of price","Show the uploaded image instead of price"
"Link Url","Link Url"
"Use text ‘AmastyHidePricePopup’ for opening Ajax Popup with a ‘Get a Quote’ form. Insert the page URL to redirect customers to any page you need","Use text ‘AmastyHidePricePopup’ for opening Ajax Popup with a ‘Get a Quote’ form. Insert the page URL to redirect customers to any page you need"
"Admin Email Notifications","Admin Email Notifications"
"Send Email to","Send Email to"
"Leave Empty to Disable Notifications","Leave Empty to Disable Notifications"
"Email Sender","Email Sender"
"Email Template","Email Template"
"Auto Reply Email Options","Auto Reply Email Options"
Enable,Enable
"GDPR Consent","GDPR Consent"
Enabled,Enabled
"Сonsent Text","Сonsent Text"
"Custom Stock Status","Custom Stock Status"
"Hide Price for Custom Stock Status","Hide Price for Custom Stock Status"
"Installation of Amasty Custom Stock Status module is required","Installation of Amasty Custom Stock Status module is required"
"Developer Options","Developer Options"
"""Add to Cart"" Selector","""Add to Cart"" Selector"
"Default value: form[data-role=""tocart-form""], button.tocart","Default value: form[data-role=""tocart-form""], button.tocart"
"Category Item Selector","Category Item Selector"
"Are you sure?","Are you sure?"
"Request ID","Request ID"
Name,Name
Email,Email
Phone,Phone
"Product Id","Product Id"
"Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings","Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings"
"Enable Display Price Mode for the selected customer groups only","Enable Display Price Mode for the selected customer groups only"
"[STORE VIEW]","[STORE VIEW]"
1 Hide Price Hide Price
2 Change Change
3 Get a Quote Requests Get a Quote Requests
4 Send Email Send Email
5 Back Back
6 Delete Delete
7 You are about to delete this request. Are you sure you want to do that? You are about to delete this request. Are you sure you want to do that?
8 Customer Name Customer Name
9 Customer Email Customer Email
10 Customer Phone Customer Phone
11 Product Product
12 Store Store
13 Created Created
14 Status Status
15 Comment Comment
16 Admin Answer Text Admin Answer Text
17 Please update Amasty Base module. Re-upload it and replace all the files. Please update Amasty Base module. Re-upload it and replace all the files.
18 Laminas DOM package is not installed (The package is required for hiding "Add to Cart" button on Category Page). Please, run the following command in the SSH: composer require laminas/laminas-dom Laminas DOM package is not installed (The package is required for hiding "Add to Cart" button on Category Page). Please, run the following command in the SSH: composer require laminas/laminas-dom
19 Amasty Hide Price Amasty Hide Price
20 Requests Requests
21 Request was deleted. Request was deleted.
22 Can't delete item right now. Please review the log and try again. Can't delete item right now. Please review the log and try again.
23 Can't find a item to delete. Can't find a item to delete.
24 This request no longer exists. This request no longer exists.
25 Get a Quote Request from Get a Quote Request from
26 Please select items. Please select items.
27 Get a Quote requests are deleted. Get a Quote requests are deleted.
28 Can't delete items right now. Please review the log and try again. Can't delete items right now. Please review the log and try again.
29 Please enter a Email Text. Please enter a Email Text.
30 Email Answer was sent. Email Answer was sent.
31 Please select request id. Please select request id.
32 Sorry. There is a problem with Your Quote Request. Please try again or use Contact Us link in the menu. Sorry. There is a problem with Your Quote Request. Please try again or use Contact Us link in the menu.
33 Thanks for contacting us. We'll respond to you as soon as possible. Thanks for contacting us. We'll respond to you as soon as possible.
34 Form key is not valid. Please try to reload the page. Form key is not valid. Please try to reload the page.
35 Please enter a valid email address. Please enter a valid email address.
36 Please enter a name. Please enter a name.
37 Please enter a phone. Please enter a phone.
38 There are no product for your request. There are no product for your request.
39 Please agree to the Privacy Policy Please agree to the Privacy Policy
40 Custom Forms module was not installed. Custom Forms module was not installed.
41 Unable to save request with ID %1. Error: %2 Unable to save request with ID %1. Error: %2
42 Unable to save new request. Error: %1 Unable to save new request. Error: %1
43 Request with specified ID "%1" not found. Request with specified ID "%1" not found.
44 Unable to remove request with ID %1. Error: %2 Unable to remove request with ID %1. Error: %2
45 Unable to remove request rule. Error: %1 Unable to remove request rule. Error: %1
46 None None
47 NONE NONE
48 NOT LOGGED IN NOT LOGGED IN
49 No No
50 Yes Yes
51 Replace with custom button Replace with custom button
52 Hide Hide
53 Show Show
54 -- Default Config -- -- Default Config --
55 Link to Custom URL Link to Custom URL
56 Amasty Hide Price Popup Amasty Hide Price Popup
57 Popup with Custom Form Popup with Custom Form
58 not installed not installed
59 Pending Pending
60 Viewed Viewed
61 Answered Answered
62 Adding to the cart is disabled Adding to the cart is disabled
63 %1 can't be added to your wishlist %1 can't be added to your wishlist
64 Use Current Price Mode By Customer Group Use Current Price Mode By Customer Group
65 General Information General Information
66 Display Price Mode Display Price Mode
67 Get a Quote Information Get a Quote Information
68 Email Text Email Text
69 If you use Custom Form for Get a Quote Requests please click <a href="%1">here</a> to review the submitted data. If you use Custom Form for Get a Quote Requests please click <a href="%1">here</a> to review the submitted data.
70 Get a Quote for Get a Quote for
71 Phone Number Phone Number
72 GDPR GDPR
73 Submit Submit
74 Hello %name, Hello %name,
75 Sincerely, %store Team. Sincerely, %store Team.
76 You have a new quote request placed by You have a new quote request placed by
77 Request details: Request details:
78 Name: %name Name: %name
79 Email: %email Email: %email
80 Phone Number: %phone Phone Number: %phone
81 Product: %product Product: %product
82 Comment: %comment Comment: %comment
83 Best Regards, %store Team. Best Regards, %store Team.
84 Thank you for contacting us! Thank you for contacting us!
85 Your quote request is being processed at the moment. Your quote request is being processed at the moment.
86 We’ll get back to you as soon as possible We’ll get back to you as soon as possible
87 Information Information
88 General Settings General Settings
89 Enable Extension Enable Extension
90 Choose ‘Yes’ to hide the price for the selected product categories and customer groups Choose ‘Yes’ to hide the price for the selected product categories and customer groups
91 Hide Price for Selected Group(s) Hide Price for Selected Group(s)
92 Product price will be hidden for the selected customer groups only Product price will be hidden for the selected customer groups only
93 Hide Price for Selected Category(s) Hide Price for Selected Category(s)
94 Product price will be hidden for the selected product categories only Product price will be hidden for the selected product categories only
95 Do not Apply to Product ID’s Do not Apply to Product ID’s
96 Specify comma separated product id’s to show the price for. This setting has the maximum priority Specify comma separated product id’s to show the price for. This setting has the maximum priority
97 Do not Apply to Customer ID’s Do not Apply to Customer ID’s
98 Specify comma separated customer id’s to show price for. This setting has the maximum priority Specify comma separated customer id’s to show price for. This setting has the maximum priority
99 Email Sender for Admin Reply Email Email Sender for Admin Reply Email
100 Email Template for Admin Reply Email Email Template for Admin Reply Email
101 Email template chosen based on theme fallback when "Default" option is selected Email template chosen based on theme fallback when "Default" option is selected
102 Hide Price Options Hide Price Options
103 Hide "Add to Cart" Hide "Add to Cart"
104 Hide ‘Add to Cart’ or replace it with the custom button, e.g. ‘Sign up’ or ‘Get a Quote’ Hide ‘Add to Cart’ or replace it with the custom button, e.g. ‘Sign up’ or ‘Get a Quote’
105 Replace "Add to Cart" Title with Replace "Add to Cart" Title with
106 Replace "Add to Cart" Link with Replace "Add to Cart" Link with
107 Custom URL Custom URL
108 Custom Form Custom Form
109 Css Styles for Replaced Link Css Styles for Replaced Link
110 Hide "Add to Wishlist" Hide "Add to Wishlist"
111 Hide wishlist link when price is hidden Hide wishlist link when price is hidden
112 Hide "Add to Compare" Hide "Add to Compare"
113 Frontend Options Frontend Options
114 Hide Price Text Hide Price Text
115 Display the above text when price is hidden, e.g. ‘Call for Price’ Display the above text when price is hidden, e.g. ‘Call for Price’
116 Custom CSS Styles for Hide Price Link Custom CSS Styles for Hide Price Link
117 Customize the CSS Styles for the Hide Price Link Customize the CSS Styles for the Hide Price Link
118 Upload Image Upload Image
119 Show the uploaded image instead of price Show the uploaded image instead of price
120 Link Url Link Url
121 Use text ‘AmastyHidePricePopup’ for opening Ajax Popup with a ‘Get a Quote’ form. Insert the page URL to redirect customers to any page you need Use text ‘AmastyHidePricePopup’ for opening Ajax Popup with a ‘Get a Quote’ form. Insert the page URL to redirect customers to any page you need
122 Admin Email Notifications Admin Email Notifications
123 Send Email to Send Email to
124 Leave Empty to Disable Notifications Leave Empty to Disable Notifications
125 Email Sender Email Sender
126 Email Template Email Template
127 Auto Reply Email Options Auto Reply Email Options
128 Enable Enable
129 GDPR Consent GDPR Consent
130 Enabled Enabled
131 Сonsent Text Сonsent Text
132 Custom Stock Status Custom Stock Status
133 Hide Price for Custom Stock Status Hide Price for Custom Stock Status
134 Installation of Amasty Custom Stock Status module is required Installation of Amasty Custom Stock Status module is required
135 Developer Options Developer Options
136 "Add to Cart" Selector "Add to Cart" Selector
137 Default value: form[data-role="tocart-form"], button.tocart Default value: form[data-role="tocart-form"], button.tocart
138 Category Item Selector Category Item Selector
139 Are you sure? Are you sure?
140 Request ID Request ID
141 Name Name
142 Email Email
143 Phone Phone
144 Product Id Product Id
145 Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings
146 Enable Display Price Mode for the selected customer groups only Enable Display Price Mode for the selected customer groups only
147 [STORE VIEW] [STORE VIEW]
+11
View File
@@ -0,0 +1,11 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Amasty_HidePrice',
__DIR__
);
@@ -0,0 +1,114 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="amasty.hideprice.adminhtml.request.grid.container">
<block class="Magento\Backend\Block\Widget\Grid" name="amasty.hideprice.adminhtml.request.grid" as="grid">
<arguments>
<argument name="id" xsi:type="string">amasty_hideprice_rule_grid</argument>
<argument name="dataSource" xsi:type="object">Amasty\HidePrice\Model\ResourceModel\Request\Collection</argument>
<argument name="default_sort" xsi:type="string">created_at</argument>
<argument name="default_dir" xsi:type="string">DESC</argument>
<argument name="save_parameters_in_session" xsi:type="string">1</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\Massaction"
name="amasty.hideprice.adminhtml.request.grid.massaction" as="grid.massaction">
<arguments>
<argument name="massaction_id_field" xsi:type="string">request_id</argument>
<argument name="form_field_name" xsi:type="string">request_ids</argument>
<argument name="use_select_all" xsi:type="string">1</argument>
<argument name="options" xsi:type="array">
<item name="change_mode_onthefly" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="string">*/*/massDelete</item>
<item name="confirm" xsi:type="string" translate="true">Are you sure?</item>
</item>
</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet"
name="amasty.hideprice.block.adminhtml.requestcolumnSet">
<arguments>
<argument name="rowUrl" xsi:type="array">
<item name="path" xsi:type="string">amasty_hideprice/*/edit</item>
<item name="extraParamsTemplate" xsi:type="array">
<item name="id" xsi:type="string">getId</item>
</item>
</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="id">
<arguments>
<argument name="header" xsi:type="string" translate="true">Request ID</argument>
<argument name="index" xsi:type="string">request_id</argument>
<argument name="type" xsi:type="string">text</argument>
<argument name="column_css_class" xsi:type="string">col-id</argument>
<argument name="header_css_class" xsi:type="string">col-id</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="name">
<arguments>
<argument name="header" xsi:type="string" translate="true">Name</argument>
<argument name="index" xsi:type="string">name</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="email">
<arguments>
<argument name="header" xsi:type="string" translate="true">Email</argument>
<argument name="index" xsi:type="string">email</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="phone">
<arguments>
<argument name="header" xsi:type="string" translate="true">Phone</argument>
<argument name="index" xsi:type="string">phone</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="product_id">
<arguments>
<argument name="header" xsi:type="string" translate="true">Product Id</argument>
<argument name="index" xsi:type="string">product_id</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="comment">
<arguments>
<argument name="header" xsi:type="string" translate="true">Comment</argument>
<argument name="index" xsi:type="string">comment</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column\Multistore" as="store_id">
<arguments>
<argument name="header" xsi:type="string" translate="true">Store</argument>
<argument name="index" xsi:type="string">store_id</argument>
<argument name="sortable" xsi:type="string">0</argument>
<argument name="type" xsi:type="string">store</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="created_at">
<arguments>
<argument name="header" xsi:type="string" translate="true">Created</argument>
<argument name="index" xsi:type="string">created_at</argument>
<argument name="gmtoffset" xsi:type="string">1</argument>
<argument name="type" xsi:type="string">datetime</argument>
<argument name="column_css_class" xsi:type="string">col-date</argument>
<argument name="header_css_class" xsi:type="string">col-date</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="status">
<arguments>
<argument name="header" xsi:type="string" translate="true">Status</argument>
<argument name="index" xsi:type="string">status</argument>
<argument name="type" xsi:type="string">options</argument>
<argument name="options" xsi:type="options" model="Amasty\HidePrice\Model\Source\Status"/>
</arguments>
</block>
</block>
</block>
</referenceBlock>
</body>
</page>
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Amasty\HidePrice\Block\Adminhtml\Request\Edit\Info" name="reqiest_view"
template="Amasty_HidePrice::info.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="amasty_hideprice_request_block"/>
<head>
<css src="Amasty_HidePrice::css/quote_request.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Amasty\HidePrice\Block\Adminhtml\Request\Comment"
template="Amasty_HidePrice::quote_comment.phtml"
before="amasty.hideprice.adminhtml.request.grid.container"/>
<block class="Amasty\HidePrice\Block\Adminhtml\Request"
name="amasty.hideprice.adminhtml.request.grid.container"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="attributes_tabs">
<block class="Amasty\HidePrice\Block\Adminhtml\Catalog\Product\Edit\Action\Attribute\Tab\HidePrice"
name="amasty_hide_price"/>
<action method="addTab">
<argument name="name" xsi:type="string">amasty_hide_price</argument>
<argument name="block" xsi:type="string">amasty_hide_price</argument>
</action>
</referenceBlock>
</body>
</page>
@@ -0,0 +1,53 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
/**
* @var \Amasty\HidePrice\Block\Adminhtml\Request\Edit\Info $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<section class="admin__page-section request-view-information">
<div class="admin__page-section-title">
<span class="title"><?= $escaper->escapeHtml(__('Get a Quote Information')) ?></span>
</div>
<div class="admin__page-section-content">
<table class="admin__table-secondary request-information-table">
<?php foreach ($block->getRequestData() as $data): ?>
<tr>
<th><?= $escaper->escapeHtml($data['label']) ?></th>
<td><?= $escaper->escapeHtml($data['value'], ['a']) ?></td>
</tr>
<?php endforeach;?>
</table>
</div>
</section>
<section class="admin__page-section request-view-answer-section">
<div id="request-view-answer" class="request-view-answer">
<form action="<?= $escaper->escapeUrl($block->getSubmitUrl()) ?>" method="post">
<input name="form_key" type="hidden" value="<?= $escaper->escapeHtml($block->getFormKey()) ?>" />
<div class="request-answer-block">
<div class="admin__field field-row">
<label class="admin__field-label"
for="email_text"><?= $escaper->escapeHtml(__('Email Text')) ?></label>
<div class="admin__field-control">
<textarea name="email_text"
class="admin__control-textarea"
rows="3"
cols="5"
id="email_text"
required></textarea>
</div>
</div>
<div class="admin__field">
<div class="review-actions">
<?= $block->getChildHtml('submit_button') ?>
</div>
</div>
</div>
</form>
</div>
</section>
@@ -0,0 +1,15 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/
/** \Amasty\HidePrice\Block\Adminhtml\Request\Comment $block */
?>
<?php if ($block->isNeedShow()) : ?>
<div class="hide-quote-comment"><?= __(
'If you use Custom Form for Get a Quote Requests please click <a href="%1">here</a> to review the submitted data.',
$block->getLink()
) ?></div>
<?php endif; ?>
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="amasty_hide_price">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Hide Price</item>
<item name="sortOrder" xsi:type="number">100</item>
<item name="collapsible" xsi:type="boolean">true</item>
</item>
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">catalogstaging_category_update_form.catalogstaging_category_update_form_data_source</item>
<item name="deps" xsi:type="string">catalogstaging_category_update_form.catalogstaging_category_update_form_data_source</item>
</item>
</argument>
<container name="container_amasty_hide_price_mode">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">container</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
<item name="dataScope" xsi:type="string"/>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<field name="am_hide_price_mode_cat">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Amasty\HidePrice\Model\Source\PriceMode</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Display Price Mode</item>
<item name="comment" xsi:type="string" translate="true">Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings</item>
<item name="formElement" xsi:type="string">select</item>
<item name="scopeLabel" xsi:type="string">[STORE VIEW]</item>
<item name="dataScope" xsi:type="string">am_hide_price_mode_cat</item>
<item name="caption" xsi:type="string" translate="true">-- Default Config --</item>
</item>
</argument>
</field>
</container>
<container name="container_amasty_hide_price_customer_group">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">container</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
<item name="dataScope" xsi:type="string"/>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
<field name="am_hide_price_customer_gr_cat">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Amasty\HidePrice\Model\Source\Group</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Use Current Price Mode By Customer Group</item>
<item name="comment" xsi:type="string" translate="true">Enable Display Price Mode for the selected customer groups only</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="dataScope" xsi:type="string">am_hide_price_customer_gr_cat</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="scopeLabel" xsi:type="string">[STORE VIEW]</item>
</item>
</argument>
</field>
</container>
</fieldset>
</form>
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="amasty_hide_price">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Hide Price</item>
<item name="sortOrder" xsi:type="number">100</item>
<item name="collapsible" xsi:type="boolean">true</item>
</item>
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">category_form.category_form_data_source</item>
<item name="deps" xsi:type="string">category_form.category_form_data_source</item>
</item>
</argument>
<container name="container_amasty_hide_price_mode">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">container</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
<item name="dataScope" xsi:type="string"/>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<field name="am_hide_price_mode_cat">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Amasty\HidePrice\Model\Source\PriceMode</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Display Price Mode</item>
<item name="comment" xsi:type="string" translate="true">Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings</item>
<item name="formElement" xsi:type="string">select</item>
<item name="scopeLabel" xsi:type="string">[STORE VIEW]</item>
<item name="dataScope" xsi:type="string">am_hide_price_mode_cat</item>
<item name="caption" xsi:type="string" translate="true">-- Default Config --</item>
</item>
</argument>
</field>
</container>
<container name="container_amasty_hide_price_customer_group">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">container</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
<item name="dataScope" xsi:type="string"/>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
<field name="am_hide_price_customer_gr_cat">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Amasty\HidePrice\Model\Source\Group</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Use Current Price Mode By Customer Group</item>
<item name="comment" xsi:type="string" translate="true">Enable Display Price Mode for the selected customer groups only</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="dataScope" xsi:type="string">am_hide_price_customer_gr_cat</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="scopeLabel" xsi:type="string">[STORE VIEW]</item>
</item>
</argument>
</field>
</container>
</fieldset>
</form>
@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="amasty_hide_price">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data.product</item>
<item name="provider" xsi:type="string">product_form.product_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Hide Price</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="number">100</item>
</item>
</argument>
<container name="container_amasty_hide_price_mode">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">container</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
<item name="dataScope" xsi:type="string"/>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<field name="am_hide_price_mode">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Amasty\HidePrice\Model\Source\PriceMode</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Display Price Mode</item>
<item name="comment" xsi:type="string" translate="true">Leave -- Default Config -- to keep using the Stores > Configuration > Hide Price settings</item>
<item name="formElement" xsi:type="string">select</item>
<item name="scopeLabel" xsi:type="string" translate="true">[STORE VIEW]</item>
<item name="dataScope" xsi:type="string">am_hide_price_mode</item>
<item name="caption" xsi:type="string" translate="true">-- Default Config --</item>
</item>
</argument>
</field>
</container>
<container name="container_amasty_hide_price_customer_group">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">container</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
<item name="dataScope" xsi:type="string"/>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
<field name="am_hide_price_customer_gr">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Amasty\HidePrice\Model\Source\Group</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Use Current Price Mode By Customer Group</item>
<item name="comment" xsi:type="string" translate="true">Enable Display Price Mode for the selected customer groups only</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="dataScope" xsi:type="string">am_hide_price_customer_gr</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="scopeLabel" xsi:type="string">[STORE VIEW]</item>
</item>
</argument>
</field>
</container>
</fieldset>
</form>
@@ -0,0 +1,3 @@
.hide-quote-comment {
margin-bottom: 20px;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

@@ -0,0 +1,22 @@
<!--@subject Get a Quote Answer from {{var store_name}} @-->
<!--@vars {
"var customer_name":"Sender Name",
"var store.frontend_name":"Store Name",
"var message":"Message from Admin",
"var request":"Request Model"
} @-->
{{template config_path="design/email/header_template"}}
<table>
<tr class="email-intro">
<td valign="top">
<p><strong>{{trans "Hello %name," name=$request.name}}</strong></p>
<p>{{var message}}</p>
<p>{{trans "Sincerely, %store Team." store=$store.frontend_name}}</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
@@ -0,0 +1,32 @@
<!--@subject Get a Quote Notification from {{var customer_name}} @-->
<!--@vars {
"var customer_name":"Sender Name",
"var request.comment":"Comment",
"var request.email":"Sender Email",
"var request.name":"Sender Name",
"var request.phone":"Sender Telephone",
"var request.product_name":"Product",
"var request.comment":"Comment"
} @-->
{{template config_path="design/email/header_template"}}
<table>
<tr class="email-intro">
<td valign="top">
<p><strong>{{trans "You have a new quote request placed by"}} {{var customer_name}},</strong></p>
<p>{{trans "Request details:"}}</p>
<p>{{trans "Name: %name" name=$request.name}}</p>
<p>{{trans "Email: %email" email=$request.email}}</p>
<p>{{trans "Phone Number: %phone" phone=$request.phone}}</p>
<p>{{trans "Product: %product" product=$request.product_name}}</p>
<p>{{trans "Comment: %comment" comment=$request.comment}}</p>
<p>{{trans "Best Regards, %store Team." store=$store.frontend_name}}</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
@@ -0,0 +1,28 @@
<!--@subject Get a Quote from {{var store_name}} @-->
<!--@vars {
"var website_name":"Website Name",
"var store.frontend_name":"Store Name",
"var customer_name":"Customer Name",
"var request":"Request Model"
} @-->
{{template config_path="design/email/header_template"}}
<table>
<tr class="email-intro">
<td valign="top">
<p><strong>{{trans "Hello %name," name=$request.name}}</strong></p>
<p>{{trans "Thank you for contacting us!"}}</p>
<p>{{trans "Your quote request is being processed at the moment."}}</p>
<p>{{trans "We’ll get back to you as soon as possible"}}</p>
<p>{{trans "Best Regards, %store Team." store=$store.frontend_name}}</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Amasty_HidePrice::css/amhideprice-styles.css"/>
</head>
</page>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Amasty_HidePrice::js/fancyambox/jquery.fancyambox.min.css"/>
<css src="Amasty_HidePrice::css/amhideprice.css"/>
</head>
<body>
<referenceContainer name="content">
<block after="-" name="Amasty_HidePrice_Form" class="Amasty\HidePrice\Block\Form"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,20 @@
var config = {
map: {
'*': {
'amasty-fancyambox' : 'Amasty_HidePrice/js/fancyambox/jquery.fancyambox.min'
}
},
config: {
mixins: {
'mage/validation': {
'Amasty_HidePrice/js/validation-mixin': true
},
'Magento_Swatches/js/swatch-renderer': {
'Amasty_HidePrice/js/swatch-renderer-mixin': true
},
'Amasty_Conf/js/swatch-renderer': {
'Amasty_HidePrice/js/swatch-renderer-mixin': true
}
}
}
};
@@ -0,0 +1,87 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Hide Price (Call for Price) for Magento 2
*/ /** @var \Amasty\HidePrice\Block\Form $block */ ?>
<form class="amhideprice-form" id="amhideprice-form" method="post" style="display: none;" data-nofocus="true">
<span class="amhideprice-close" data-amhide-js="close-popup"></span>
<input name="form_key" type="hidden" value="<?php echo $block->escapeHtml($block->getFormKey()) ?>" />
<input name="product_id" type="hidden" value="" />
<fieldset class="fieldset">
<legend class="legend amhideprice-form-ledend">
<span><?= __('Get a Quote for') ?></span>
<span style="font-weight: bolder;" class="product-name"></span>
</legend>
<br>
<div class="field required">
<label for="amhideprice-name" class="label">
<span><?= __('Customer Name') ?></span>
</label>
<div class="control">
<input type="text" name="name" class="input-text"
id="amhideprice-name" data-validate="{required:true}">
</div>
</div>
<div class="field required">
<label for="amhideprice-email" class="label">
<span><?= __('Customer Email') ?></span>
</label>
<div class="control">
<input type="email"
name="email"
id="amhideprice-email"
autocomplete="email"
value="" class="input-text"
data-validate="{required:true, 'validate-email':true}"
aria-required="true">
</div>
</div>
<div class="field required">
<label for="amhideprice-phone" class="label">
<span><?= __('Phone Number') ?></span>
</label>
<div class="control">
<input type="text" name="phone" class="input-text "
id="amhideprice-phone" data-validate="{required:true}">
</div>
</div>
<div class="field">
<label for="amhideprice-comment" class="label">
<span><?= __('Comment') ?></span>
</label>
<div class="control">
<textarea title="<?= __('Comment') ?>"
name="comment" class="input-text"
id="amhideprice-comment"
data-validate="{'validate-no-html-tags':true}"></textarea>
</div>
</div>
<?php if ($block->isGDPREnabled()) : ?>
<div class="field required">
<label class="label" for="amhideprice-gdpr">
<input type="checkbox"
name="gdpr"
id="amhideprice-gdpr"
title="<?= __('GDPR'); ?>"
data-validate="{required:true}"
value="1">
<?= $block->getGDPRText(); ?>
</label>
</div>
<?php endif; ?>
</fieldset>
<div class="actions-toolbar">
<div class="primary">
<button type="submit" class="action submit primary"
title="<?= __('Submit') ?>">
<span><?= __('Submit') ?></span>
</button>
</div>
</div>
</form>

Some files were not shown because too many files have changed in this diff Show More