This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -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'
);
}
}