-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathConditions.php
More file actions
executable file
·85 lines (72 loc) · 2.38 KB
/
Conditions.php
File metadata and controls
executable file
·85 lines (72 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Astound\Affirm\Block\Adminhtml\Rule\Edit\Tab;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Backend\Block\Widget\Tab\TabInterface;
class Conditions extends Generic implements TabInterface
{
protected $_rendererFieldset;
protected $_conditions;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Rule\Block\Conditions $conditions,
\Magento\Backend\Block\Widget\Form\Renderer\Fieldset $rendererFieldset,
array $data
) {
$this->_rendererFieldset = $rendererFieldset;
$this->_conditions = $conditions;
parent::__construct($context, $registry, $formFactory, $data);
}
public function getTabLabel()
{
return __('Conditions');
}
public function getTabTitle()
{
return __('Conditions');
}
public function canShowTab()
{
return true;
}
public function isHidden()
{
return false;
}
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('affirm_payment_restriction_rule');
$om = \Magento\Framework\App\ObjectManager::getInstance();
$hlp = $om->get('Astound\Affirm\Helper\Data');
$form = $this->_formFactory->create();
$renderer = $this->_rendererFieldset->setTemplate(
'Magento_CatalogRule::promo/fieldset.phtml'
)->setNewChildUrl(
$this->getUrl('*/*/newConditionHtml/form/rule_conditions_fieldset')
);
$fieldset = $form->addFieldset(
'rule_conditions_fieldset',
[
'legend' => __(
'Apply the rule only if the following conditions are met (leave blank for all products).'
)
]
)->setRenderer(
$renderer
);
$fieldset->addField(
'conditions',
'text',
['name' => 'conditions', 'label' => __('Conditions'), 'title' => __('Conditions')]
)->setRule(
$model
)->setRenderer(
$this->_conditions
);
$form->setValues($model->getData());
$form->addValues(['id'=>$model->getId()]);
$this->setForm($form);
return parent::_prepareForm();
}
}