init
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\CustomerCoupon\Observer;
|
||||
|
||||
use Esun\CustomerCoupon\Block\Adminhtml\Form\CustomerSelect;
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
|
||||
class AddCustomerSelectToCouponForm implements ObserverInterface
|
||||
{
|
||||
public function __construct(private readonly LayoutInterface $layout)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(Observer $observer): void
|
||||
{
|
||||
$form = $observer->getData('form');
|
||||
$fieldset = $form ? $form->getElement('information_fieldset') : null;
|
||||
if (!$fieldset || $form->getElement('customer_ids')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$html = $this->layout->createBlock(CustomerSelect::class)
|
||||
->setTemplate('Esun_CustomerCoupon::form/customer-select.phtml')
|
||||
->toHtml();
|
||||
|
||||
$fieldset->addField(
|
||||
'customer_ids',
|
||||
'note',
|
||||
[
|
||||
'label' => __('Assigned Customers'),
|
||||
'text' => $html,
|
||||
'note' => __('When customers are selected, one unique coupon is generated for each customer.'),
|
||||
],
|
||||
'dash'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user