diff --git a/Block/Adminhtml/Rule.php b/Block/Adminhtml/Rule.php index 39ef62a2..0743117f 100755 --- a/Block/Adminhtml/Rule.php +++ b/Block/Adminhtml/Rule.php @@ -1,13 +1,13 @@ -_controller = 'adminhtml_rule'; - $this->_headerText = __('Payment Restriction Rules'); - $this->_addButtonLabel = __('Add Rule'); - parent::_construct(); - } -} \ No newline at end of file +_controller = 'adminhtml_rule'; + $this->_headerText = __('Payment Restriction Rules'); + $this->_addButtonLabel = __('Add Rule'); + parent::_construct(); + } +} diff --git a/Block/Adminhtml/Rule/Edit.php b/Block/Adminhtml/Rule/Edit.php index 4b5457bf..fd85bc9e 100755 --- a/Block/Adminhtml/Rule/Edit.php +++ b/Block/Adminhtml/Rule/Edit.php @@ -1,48 +1,47 @@ -_coreRegistry = $registry; - parent::__construct($context, $data); - } - - protected function _construct() - { - $this->_objectId = 'id'; - $this->_controller = 'adminhtml_rule'; - $this->_blockGroup = 'Astound_Affirm'; - - parent::_construct(); - - $this->buttonList->add( - 'save_and_continue_edit', - [ - 'class' => 'save', - 'label' => __('Save and Continue Edit'), - 'data_attribute' => [ - 'mage-init' => ['button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form']], - ] - ], - 10 - ); - } - - public function getHeaderText() - { - $model = $this->_coreRegistry->registry('affirm_payment_restriction_rule'); - if($model->getId()) { - $title = __('Edit Payment Restriction Rule `%1`', $model->getName()); - } else { - $title = __("Add new Payment Restriction Rule"); - } - } - -} \ No newline at end of file +_coreRegistry = $registry; + parent::__construct($context, $data); + } + + protected function _construct() + { + $this->_objectId = 'id'; + $this->_controller = 'adminhtml_rule'; + $this->_blockGroup = 'Astound_Affirm'; + + parent::_construct(); + + $this->buttonList->add( + 'save_and_continue_edit', + [ + 'class' => 'save', + 'label' => __('Save and Continue Edit'), + 'data_attribute' => [ + 'mage-init' => ['button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form']], + ] + ], + 10 + ); + } + + public function getHeaderText() + { + $model = $this->_coreRegistry->registry('affirm_payment_restriction_rule'); + if ($model->getId()) { + $title = __('Edit Payment Restriction Rule `%1`', $model->getName()); + } else { + $title = __("Add new Payment Restriction Rule"); + } + } +} diff --git a/Block/Adminhtml/Rule/Edit/Form.php b/Block/Adminhtml/Rule/Edit/Form.php index a9f19463..b18c164c 100755 --- a/Block/Adminhtml/Rule/Edit/Form.php +++ b/Block/Adminhtml/Rule/Edit/Form.php @@ -1,29 +1,29 @@ -setId('affirm_rule_edit_form'); - $this->setTitle(__('Payment Restriction Information')); - } - - protected function _prepareForm() - { - $form = $this->_formFactory->create( - [ - 'data' => [ - 'id' => 'edit_form', - 'action' => $this->getUrl('*/*/save'), - 'method' => 'post', - 'enctype' => 'multipart/form-data', - ], - ] - ); - $form->setUseContainer(true); - $this->setForm($form); - return parent::_prepareForm(); - } -} \ No newline at end of file +setId('affirm_rule_edit_form'); + $this->setTitle(__('Payment Restriction Information')); + } + + protected function _prepareForm() + { + $form = $this->_formFactory->create( + [ + 'data' => [ + 'id' => 'edit_form', + 'action' => $this->getUrl('*/*/save'), + 'method' => 'post', + 'enctype' => 'multipart/form-data', + ], + ] + ); + $form->setUseContainer(true); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/Block/Adminhtml/Rule/Edit/Tab/Conditions.php b/Block/Adminhtml/Rule/Edit/Tab/Conditions.php index 2f2e1cb3..5d102699 100755 --- a/Block/Adminhtml/Rule/Edit/Tab/Conditions.php +++ b/Block/Adminhtml/Rule/Edit/Tab/Conditions.php @@ -1,84 +1,85 @@ -_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(); - } -} \ No newline at end of file +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(); + } +} diff --git a/Block/Adminhtml/Rule/Edit/Tab/General.php b/Block/Adminhtml/Rule/Edit/Tab/General.php index 078fd83f..596bc393 100755 --- a/Block/Adminhtml/Rule/Edit/Tab/General.php +++ b/Block/Adminhtml/Rule/Edit/Tab/General.php @@ -1,95 +1,94 @@ -_systemStore = $systemStore; - parent::__construct($context, $registry, $formFactory, $data); - } - - public function getTabLabel() - { - return __('General'); - } - - public function getTabTitle() - { - return __('General'); - } - - 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(); - $form->setHtmlIdPrefix('rule_'); - - $fieldset = $form->addFieldset('general', ['legend' => __('General')]); - if ($model->getId()) { - $fieldset->addField('id', 'hidden', ['name' => 'id']); - } - $fieldset->addField( - 'name', - 'text', - ['name' => 'name', 'label' => __('Rule Name'), 'title' => __('Rule Name'), 'required' => true] - ); - - $fieldset->addField('is_active', 'select', [ - 'label' => __('Status'), - 'name' => 'is_active', - 'options' => $hlp->getStatuses(), - ]); - - $fieldset->addField('methods', 'multiselect', [ - 'label' => __('Disable Selected Payment Methods'), - 'name' => 'methods[]', - 'values' => $hlp->getAllMethods(), - 'required' => true, - ]); - - $fieldset->addField('cust_groups', 'multiselect', [ - 'name' => 'cust_groups[]', - 'label' => __('Customer Groups'), - 'values' => $hlp->getAllGroups(), - 'note' => __('Leave empty or select all to apply the rule to any group'), - ]); - - $fieldset->addField('stores', 'multiselect', [ - 'label' => __('Stores'), - 'name' => 'stores[]', - 'values' => $this->_systemStore->getStoreValuesForForm(), - 'note' => __('Leave empty or select all to apply the rule to any'), - ]); - - $form->setValues($model->getData()); - $form->addValues(['id' => $model->getId()]); - $this->setForm($form); - return parent::_prepareForm(); - } -} \ No newline at end of file +_systemStore = $systemStore; + parent::__construct($context, $registry, $formFactory, $data); + } + + public function getTabLabel() + { + return __('General'); + } + + public function getTabTitle() + { + return __('General'); + } + + 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(); + $form->setHtmlIdPrefix('rule_'); + + $fieldset = $form->addFieldset('general', ['legend' => __('General')]); + if ($model->getId()) { + $fieldset->addField('id', 'hidden', ['name' => 'id']); + } + $fieldset->addField( + 'name', + 'text', + ['name' => 'name', 'label' => __('Rule Name'), 'title' => __('Rule Name'), 'required' => true] + ); + + $fieldset->addField('is_active', 'select', [ + 'label' => __('Status'), + 'name' => 'is_active', + 'options' => $hlp->getStatuses(), + ]); + + $fieldset->addField('methods', 'multiselect', [ + 'label' => __('Disable Selected Payment Methods'), + 'name' => 'methods[]', + 'values' => $hlp->getAllMethods(), + 'required' => true, + ]); + + $fieldset->addField('cust_groups', 'multiselect', [ + 'name' => 'cust_groups[]', + 'label' => __('Customer Groups'), + 'values' => $hlp->getAllGroups(), + 'note' => __('Leave empty or select all to apply the rule to any group'), + ]); + + $fieldset->addField('stores', 'multiselect', [ + 'label' => __('Stores'), + 'name' => 'stores[]', + 'values' => $this->_systemStore->getStoreValuesForForm(), + 'note' => __('Leave empty or select all to apply the rule to any'), + ]); + + $form->setValues($model->getData()); + $form->addValues(['id' => $model->getId()]); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/Block/Adminhtml/Rule/Edit/Tabs.php b/Block/Adminhtml/Rule/Edit/Tabs.php index aa57718f..4803a9c2 100755 --- a/Block/Adminhtml/Rule/Edit/Tabs.php +++ b/Block/Adminhtml/Rule/Edit/Tabs.php @@ -1,13 +1,13 @@ -setId('affirm_rule_edit_tabs'); - $this->setDestElementId('edit_form'); - $this->setTitle(__('Payment Restriction Rules Options')); - } -} \ No newline at end of file +setId('affirm_rule_edit_tabs'); + $this->setDestElementId('edit_form'); + $this->setTitle(__('Payment Restriction Rules Options')); + } +} diff --git a/Block/Adminhtml/Rule/Grid/Renderer/Color.php b/Block/Adminhtml/Rule/Grid/Renderer/Color.php index 4571d6d6..cb430bb7 100755 --- a/Block/Adminhtml/Rule/Grid/Renderer/Color.php +++ b/Block/Adminhtml/Rule/Grid/Renderer/Color.php @@ -1,21 +1,20 @@ -getData($this->getColumn()->getIndex()); - if ($status == 1) { - $color = "10a900"; - $value = "Active"; - } else { - $color = "ff031b"; - $value = "Inactive"; - } - - return '
' . $value . '
'; - } - -} \ No newline at end of file +getData($this->getColumn()->getIndex()); + if ($status == 1) { + $color = "10a900"; + $value = "Active"; + } else { + $color = "ff031b"; + $value = "Inactive"; + } + + return '
' . $value . '
'; + } +} diff --git a/Block/Adminhtml/Rule/Grid/Renderer/Groups.php b/Block/Adminhtml/Rule/Grid/Renderer/Groups.php index a0f74434..518a426d 100755 --- a/Block/Adminhtml/Rule/Grid/Renderer/Groups.php +++ b/Block/Adminhtml/Rule/Grid/Renderer/Groups.php @@ -1,24 +1,24 @@ -get('Astound\Affirm\Helper\Data'); - $groups = $row->getData('cust_groups'); - if (!$groups) { - return __('Restricts For All'); - } - $groups = explode(',', $groups); - - $html = ''; - foreach($hlp->getAllGroups() as $row) - { - if (in_array($row['value'], $groups)){ - $html .= $row['label'] . "
"; - } - } - return $html; - } -} \ No newline at end of file +get('Astound\Affirm\Helper\Data'); + $groups = $row->getData('cust_groups'); + if (!$groups) { + return __('Restricts For All'); + } + $groups = explode(',', $groups); + + $html = ''; + foreach ($hlp->getAllGroups() as $row) { + if (in_array($row['value'], $groups)) { + $html .= $row['label'] . "
"; + } + } + return $html; + } +} diff --git a/Block/Adminhtml/Rule/Grid/Renderer/Methods.php b/Block/Adminhtml/Rule/Grid/Renderer/Methods.php index a63f4e39..e0a1d1b1 100755 --- a/Block/Adminhtml/Rule/Grid/Renderer/Methods.php +++ b/Block/Adminhtml/Rule/Grid/Renderer/Methods.php @@ -1,27 +1,25 @@ -get('Astound\Affirm\Helper\Data'); - - $v = $row->getData('methods'); - if (!$v) { - return __('Allows All'); - } - $v = explode(',', $v); - - $html = ''; - foreach($hlp->getAllMethods() as $row) - { - if (in_array($row['value'], $v)){ - $html .= $row['label'] . "
"; - } - } - return $html; - } - -} \ No newline at end of file +get('Astound\Affirm\Helper\Data'); + + $v = $row->getData('methods'); + if (!$v) { + return __('Allows All'); + } + $v = explode(',', $v); + + $html = ''; + foreach ($hlp->getAllMethods() as $row) { + if (in_array($row['value'], $v)) { + $html .= $row['label'] . "
"; + } + } + return $html; + } +} diff --git a/Block/Adminhtml/Rule/Grid/Renderer/Stores.php b/Block/Adminhtml/Rule/Grid/Renderer/Stores.php index 30552347..fa356316 100755 --- a/Block/Adminhtml/Rule/Grid/Renderer/Stores.php +++ b/Block/Adminhtml/Rule/Grid/Renderer/Stores.php @@ -1,28 +1,29 @@ -get('Astound\Affirm\Helper\Data'); - $sys = $om->get('Magento\Store\Model\System\Store'); - $stores = $row->getData('stores'); - if (!$stores) { - return __('Restricts in All'); - } - - $html = ''; - $data = $sys->getStoresStructure(false, explode(',', $stores)); - foreach ($data as $website) { - $html .= $website['label'] . '
'; - foreach ($website['children'] as $group) { - $html .= str_repeat(' ', 3) . $group['label'] . '
'; - foreach ($group['children'] as $store) { - $html .= str_repeat(' ', 6) . $store['label'] . '
'; - } - } - } - return $html; - } -} \ No newline at end of file +get('Astound\Affirm\Helper\Data'); + $sys = $om->get('Magento\Store\Model\System\Store'); + $stores = $row->getData('stores'); + if (!$stores) { + return __('Restricts in All'); + } + + $html = ''; + $data = $sys->getStoresStructure(false, explode(',', $stores)); + foreach ($data as $website) { + $html .= $website['label'] . '
'; + foreach ($website['children'] as $group) { + $html .= str_repeat(' ', 3) . $group['label'] . '
'; + foreach ($group['children'] as $store) { + $html .= str_repeat(' ', 6) . $store['label'] . '
'; + } + } + } + return $html; + } +} diff --git a/Block/Info.php b/Block/Info.php index c6b89ba9..f6b42734 100644 --- a/Block/Info.php +++ b/Block/Info.php @@ -98,7 +98,10 @@ protected function getLoanId() protected function getAdminAffirmUrl() { $loanId = $this->getLoanId(); - return sprintf('https://%s/dashboard/#/details/%s?trk=%s', $this->getDomainUrl(), $loanId, + return sprintf( + 'https://%s/dashboard/#/details/%s?trk=%s', + $this->getDomainUrl(), + $loanId, $this->getPublicApiKey() ); } diff --git a/Block/Onepage/ClearCart.php b/Block/Onepage/ClearCart.php index 1877afca..1ad8db21 100644 --- a/Block/Onepage/ClearCart.php +++ b/Block/Onepage/ClearCart.php @@ -28,13 +28,12 @@ class ClearCart extends Template { /** - * Clear mini cart - * - */ + * Clear mini cart + * + */ public function __construct( Template\Context $context ) { parent::__construct($context); } - } diff --git a/Block/Promotion/AslowasAbstract.php b/Block/Promotion/AslowasAbstract.php index d5738240..107420c1 100644 --- a/Block/Promotion/AslowasAbstract.php +++ b/Block/Promotion/AslowasAbstract.php @@ -185,7 +185,7 @@ public function getWidgetData() */ public function getDataAffirmColor() { - if(in_array($this->getData('logo'), $this->dataColors)) { + if (in_array($this->getData('logo'), $this->dataColors)) { return 'data-affirm-color="' . $this->getData('logo') . '"'; } return ''; @@ -256,5 +256,4 @@ protected function _toHtml() * @return boolean */ abstract public function validate(); - } diff --git a/Block/Promotion/Banners.php b/Block/Promotion/Banners.php index ef0caf4a..a3388410 100644 --- a/Block/Promotion/Banners.php +++ b/Block/Promotion/Banners.php @@ -208,7 +208,7 @@ protected function _toHtml() return ''; } - if ( $this->affirmPaymentConfig->getBmlSize($this->section) == '"Pay over time banner sizes"' || $this->affirmPaymentConfig->getBmlSize($this->section) == '"Make Monthly Payments banner sizes"' ) { + if ($this->affirmPaymentConfig->getBmlSize($this->section) == '"Pay over time banner sizes"' || $this->affirmPaymentConfig->getBmlSize($this->section) == '"Make Monthly Payments banner sizes"') { return ''; } @@ -313,9 +313,9 @@ public function getPageType() { if ($this->isCartPage()) { return 'cart'; - } else if ($this->isCategoryPage()) { + } elseif ($this->isCategoryPage()) { return 'category'; - } else if ($this->isProductPage()) { + } elseif ($this->isProductPage()) { return 'product'; } else { return 'homepage'; diff --git a/Block/Promotion/CartPage/Aslowas.php b/Block/Promotion/CartPage/Aslowas.php index e6b8087a..13b2a514 100644 --- a/Block/Promotion/CartPage/Aslowas.php +++ b/Block/Promotion/CartPage/Aslowas.php @@ -122,7 +122,8 @@ public function getMFPValue() return $this->asLowAsHelper->getFinancingProgramValue(); } - public function getLearnMoreValue(){ + public function getLearnMoreValue() + { return $this->asLowAsHelper->isVisibleLearnmore() ? 'true' :'false'; } } diff --git a/Block/Promotion/Pixel/Confirm.php b/Block/Promotion/Pixel/Confirm.php index d57a6a26..7b23ddbb 100644 --- a/Block/Promotion/Pixel/Confirm.php +++ b/Block/Promotion/Pixel/Confirm.php @@ -94,12 +94,12 @@ public function __construct( */ public function getOrdersTrackingCode() { - $result = array(); + $result = []; $result['method'] = 'trackOrderConfirmed'; $order = $this->_checkoutSession->getLastRealOrder(); - $result['parameter'][0] = array(); + $result['parameter'][0] = []; $result['parameter'][0]['orderId'] = $order->getIncrementId(); $result['parameter'][0]['currency'] = $order->getOrderCurrencyCode(); $result['parameter'][0]['total'] = Util::formatToCents($order->getBaseGrandTotal()); @@ -107,10 +107,10 @@ public function getOrdersTrackingCode() $result['parameter'][1] = null; - $strictBool = True; + $strictBool = true; foreach ($result['parameter'][0] as $item) { if (empty($item)) { - $strictBool = False; + $strictBool = false; break; } } @@ -167,7 +167,7 @@ public function getCustomerSessionId() foreach ($collection as $order) { $customerId = ($order->getCustomerId()) ? $order->getCustomerId() : $guestId = "CUSTOMER-" . $this->affirmPixelHelper->getDateMicrotime(); - } + } return $customerId; } } diff --git a/Block/Promotion/ProductPage/Aslowas.php b/Block/Promotion/ProductPage/Aslowas.php index 60eabc46..98d10cfc 100644 --- a/Block/Promotion/ProductPage/Aslowas.php +++ b/Block/Promotion/ProductPage/Aslowas.php @@ -47,9 +47,9 @@ public function validate() if ($this->affirmPaymentConfig->getConfigData('active') && $this->affirmPaymentHelper->isAffirmAvailableForProduct($product) ) { - if ((float)$product->getFinalPrice() < (float)$this->affirmPaymentConfig->getAsLowAsMinMpp()) { - return false; - } + if ((float)$product->getFinalPrice() < (float)$this->affirmPaymentConfig->getAsLowAsMinMpp()) { + return false; + } return true; } return false; @@ -75,8 +75,8 @@ public function process() } $product = $this->affirmPaymentHelper->getProduct(); $this->setData( - 'backorders_options', - $this->affirmPaymentHelper->getConfigurableProductBackordersOptions($product) + 'backorders_options', + $this->affirmPaymentHelper->getConfigurableProductBackordersOptions($product) ); $this->setData('element_id', 'als_pdp'); @@ -106,7 +106,8 @@ public function getProductId() return $this->affirmPaymentHelper->getProduct()->getId(); } - public function getLearnMoreValue(){ + public function getLearnMoreValue() + { return $this->asLowAsHelper->isVisibleLearnmore() ? 'true' :'false'; } } diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php index 61bc2349..dd4566e2 100644 --- a/Block/System/Config/Form/Field/Version.php +++ b/Block/System/Config/Form/Field/Version.php @@ -5,7 +5,6 @@ use Magento\Framework\Registry; use Magento\Backend\Block\Template\Context; - /** * Class Date */ diff --git a/Controller/Adminhtml/Rule.php b/Controller/Adminhtml/Rule.php index cb5fef1b..fd2ee786 100755 --- a/Controller/Adminhtml/Rule.php +++ b/Controller/Adminhtml/Rule.php @@ -1,58 +1,61 @@ -_coreRegistry = $coreRegistry; - parent::__construct($context); - $this->resultPageFactory = $resultPageFactory; - } - - protected function _initAction() - { - $this->_view->loadLayout(); - $this->_setActiveMenu('Astound_Affirm::rule')->_addBreadcrumb(__('Promotions'), __('Promotions')); - return $this; - } - - protected function _isAllowed() - { - return $this->_authorization->isAllowed('Astound_Affirm::rule'); - } - - - public function newConditions($prefix) - { - $id = $this->getRequest()->getParam('id'); - $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type'))); - $type = $typeArr[0]; - - $model = $this->_objectManager->create($type) - ->setId($id) - ->setType($type) - ->setRule($this->_objectManager->create('Magento\CatalogRule\Model\Rule')) - ->setPrefix($prefix); - if (!empty($typeArr[1])) { - $model->setAttribute($typeArr[1]); - } - - if ($model instanceof \Magento\Rule\Model\Condition\AbstractCondition) { - $model->setJsFormObject($this->getRequest()->getParam('form')); - $html = $model->asHtmlRecursive(); - } else { - $html = ''; - } - $this->getResponse()->setBody($html); - } -} +_coreRegistry = $coreRegistry; + parent::__construct($context); + $this->resultPageFactory = $resultPageFactory; + } + + protected function _initAction() + { + $this->_view->loadLayout(); + $this->_setActiveMenu('Astound_Affirm::rule')->_addBreadcrumb(__('Promotions'), __('Promotions')); + return $this; + } + + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Astound_Affirm::rule'); + } + + + public function newConditions($prefix) + { + $id = $this->getRequest()->getParam('id'); + $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type'))); + $type = $typeArr[0]; + + $model = $this->_objectManager->create($type) + ->setId($id) + ->setType($type) + ->setRule($this->_objectManager->create('Magento\CatalogRule\Model\Rule')) + ->setPrefix($prefix); + if (!empty($typeArr[1])) { + $model->setAttribute($typeArr[1]); + } + + if ($model instanceof \Magento\Rule\Model\Condition\AbstractCondition) { + $model->setJsFormObject($this->getRequest()->getParam('form')); + $html = $model->asHtmlRecursive(); + } else { + $html = ''; + } + $this->getResponse()->setBody($html); + } +} diff --git a/Controller/Adminhtml/Rule/Delete.php b/Controller/Adminhtml/Rule/Delete.php index 209151c8..7146f94e 100755 --- a/Controller/Adminhtml/Rule/Delete.php +++ b/Controller/Adminhtml/Rule/Delete.php @@ -1,34 +1,35 @@ -getRequest()->getParam('id'); - if ($id) { - try { - $model = $this->_objectManager->create('Astound\Affirm\Model\Rule'); - $model->load($id); - $model->delete(); - $this->messageManager->addSuccess(__('You deleted the item.')); - $this->_redirect('*/*/'); - return; - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); - $this->_redirect('*/*/'); - return; - } catch (\Exception $e) { - $this->messageManager->addError( - __('We can\'t delete item right now. Please review the log and try again.') - ); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); - $this->_redirect('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); - return; - } - } - $this->messageManager->addError(__('We can\'t find a item to delete.')); - $this->_redirect('*/*/'); - } -} \ No newline at end of file +use Magento\Framework\App\ResponseInterface; + +class Delete extends \Astound\Affirm\Controller\Adminhtml\Rule +{ + public function execute() + { + $id = $this->getRequest()->getParam('id'); + if ($id) { + try { + $model = $this->_objectManager->create('Astound\Affirm\Model\Rule'); + $model->load($id); + $model->delete(); + $this->messageManager->addSuccess(__('You deleted the item.')); + $this->_redirect('*/*/'); + return; + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->messageManager->addError($e->getMessage()); + $this->_redirect('*/*/'); + return; + } catch (\Exception $e) { + $this->messageManager->addError( + __('We can\'t delete item right now. Please review the log and try again.') + ); + $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_redirect('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); + return; + } + } + $this->messageManager->addError(__('We can\'t find a item to delete.')); + $this->_redirect('*/*/'); + } +} diff --git a/Controller/Adminhtml/Rule/Duplicate.php b/Controller/Adminhtml/Rule/Duplicate.php index f01e352f..602dbbad 100755 --- a/Controller/Adminhtml/Rule/Duplicate.php +++ b/Controller/Adminhtml/Rule/Duplicate.php @@ -1,42 +1,43 @@ -getRequest()->getParam('rule_id'); - if (!$id) { - $this->messageManager->addError(__('Please select a rule to duplicate.')); - return $this->_redirect('*/*'); - } - try { - $model = $this->_objectManager->create('Astound\Affirm\Model\Rule')->load($id); - if (!$model->getId()) { - $this->messageManager->addError(__('This item no longer exists.')); - $this->_redirect('*/*'); - return; - } +setIsActive(0); - $rule->setId(null); - $rule->save(); - - $session = $this->_objectManager->get('Magento\Backend\Model\Session'); - $this->messageManager->addSuccess(__('The rule has been duplicated. Please feel free to activate it.')); - - return $this->_redirect('*/*/edit', array('id' => $rule->getId())); - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); - $this->_redirect('*/*'); - return; - } catch (\Exception $e) { - $this->messageManager->addError( - __('Something went wrong while saving the item data. Please review the error log.') - ); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); - $this->_redirect('*/*'); - return; - } - } -} \ No newline at end of file +class Duplicate extends \Astound\Affirm\Controller\Adminhtml\Rule +{ + public function execute() + { + $id = $this->getRequest()->getParam('rule_id'); + if (!$id) { + $this->messageManager->addError(__('Please select a rule to duplicate.')); + return $this->_redirect('*/*'); + } + try { + $model = $this->_objectManager->create('Astound\Affirm\Model\Rule')->load($id); + if (!$model->getId()) { + $this->messageManager->addError(__('This item no longer exists.')); + $this->_redirect('*/*'); + return; + } + + $rule = clone $model; + $rule->setIsActive(0); + $rule->setId(null); + $rule->save(); + + $session = $this->_objectManager->get('Magento\Backend\Model\Session'); + $this->messageManager->addSuccess(__('The rule has been duplicated. Please feel free to activate it.')); + + return $this->_redirect('*/*/edit', ['id' => $rule->getId()]); + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->messageManager->addError($e->getMessage()); + $this->_redirect('*/*'); + return; + } catch (\Exception $e) { + $this->messageManager->addError( + __('Something went wrong while saving the item data. Please review the error log.') + ); + $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_redirect('*/*'); + return; + } + } +} diff --git a/Controller/Adminhtml/Rule/Edit.php b/Controller/Adminhtml/Rule/Edit.php index 3d5c2361..2a0bf8c8 100755 --- a/Controller/Adminhtml/Rule/Edit.php +++ b/Controller/Adminhtml/Rule/Edit.php @@ -1,50 +1,50 @@ -getRequest()->getParam('id'); - $model = $this->_objectManager->create('Astound\Affirm\Model\Rule'); - - if ($id) { - $model->load($id); - if (!$model->getId()) { - $this->messageManager->addError(__('This item no longer exists.')); - $this->_redirect('*/*'); - return; - } - } - // set entered data if was error when we do save - $data = $this->_objectManager->get('Magento\Backend\Model\Session')->getPageData(true); - if (!empty($data)) { - $model->addData($data); - } else { - $this->_prepareForEdit($model); - } - $this->_coreRegistry->register('affirm_payment_restriction_rule', $model); - $this->_initAction(); - if($model->getId()) { - $title = __('Edit Payment Restrictions Rule `%1`', $model->getName()); - } else { - $title = __("Add new Payment Restriction Rule"); - } - $this->_view->getPage()->getConfig()->getTitle()->prepend($title); - $this->_view->renderLayout(); - } - - public function _prepareForEdit(\Astound\Affirm\Model\Rule $model) - { - $fields = array('stores', 'cust_groups', 'methods'); - foreach ($fields as $f){ - $val = $model->getData($f); - if (!is_array($val)){ - $model->setData($f, explode(',', $val ?? '')); - } - } - - $model->getConditions()->setJsFormObject('rule_conditions_fieldset'); - return true; - } -} \ No newline at end of file +getRequest()->getParam('id'); + $model = $this->_objectManager->create('Astound\Affirm\Model\Rule'); + + if ($id) { + $model->load($id); + if (!$model->getId()) { + $this->messageManager->addError(__('This item no longer exists.')); + $this->_redirect('*/*'); + return; + } + } + // set entered data if was error when we do save + $data = $this->_objectManager->get('Magento\Backend\Model\Session')->getPageData(true); + if (!empty($data)) { + $model->addData($data); + } else { + $this->_prepareForEdit($model); + } + $this->_coreRegistry->register('affirm_payment_restriction_rule', $model); + $this->_initAction(); + if ($model->getId()) { + $title = __('Edit Payment Restrictions Rule `%1`', $model->getName()); + } else { + $title = __("Add new Payment Restriction Rule"); + } + $this->_view->getPage()->getConfig()->getTitle()->prepend($title); + $this->_view->renderLayout(); + } + + public function _prepareForEdit(\Astound\Affirm\Model\Rule $model) + { + $fields = ['stores', 'cust_groups', 'methods']; + foreach ($fields as $f) { + $val = $model->getData($f); + if (!is_array($val)) { + $model->setData($f, explode(',', $val ?? '')); + } + } + + $model->getConditions()->setJsFormObject('rule_conditions_fieldset'); + return true; + } +} diff --git a/Controller/Adminhtml/Rule/Index.php b/Controller/Adminhtml/Rule/Index.php index 2c5cc09a..e30eb1d2 100755 --- a/Controller/Adminhtml/Rule/Index.php +++ b/Controller/Adminhtml/Rule/Index.php @@ -1,14 +1,14 @@ -resultPageFactory->create(); - $resultPage->setActiveMenu('Astound_Affirm::rule'); - $resultPage->getConfig()->getTitle()->prepend(__('Payment Restrictions Rules')); - $resultPage->addBreadcrumb(__('Payment Restrictions Rules'), __('Payment Restrictions Rules')); - return $resultPage; - } -} \ No newline at end of file +resultPageFactory->create(); + $resultPage->setActiveMenu('Astound_Affirm::rule'); + $resultPage->getConfig()->getTitle()->prepend(__('Payment Restrictions Rules')); + $resultPage->addBreadcrumb(__('Payment Restrictions Rules'), __('Payment Restrictions Rules')); + return $resultPage; + } +} diff --git a/Controller/Adminhtml/Rule/MassAction.php b/Controller/Adminhtml/Rule/MassAction.php index c54fbdda..25744f3d 100755 --- a/Controller/Adminhtml/Rule/MassAction.php +++ b/Controller/Adminhtml/Rule/MassAction.php @@ -1,55 +1,54 @@ -getRequest()->getParam('rules'); - $action = $this->getRequest()->getParam('action'); - if ($ids && in_array($action, ['activate', 'inactivate', 'delete'])) { - try { - $status = -1; - switch($action) { - case 'delete': - $collection = $this->_objectManager->create('Astound\Affirm\Model\ResourceModel\Rule\Collection'); - - $collection->addFieldToFilter('rule_id', array('in'=>$ids)); - $collection->walk($action); - $status = -1; - $message = __('You deleted the rule(s).'); - break; - case 'activate': - $status = 1; - $message = __('You activated the rule(s).'); - break; - case 'inactivate': - $status = 0; - $message = __('You deactivated the rule(s).'); - break; - } - - if($status > -1) { - $this->_objectManager->create('Astound\Affirm\Model\Rule')->massChangeStatus($ids, $status); - } - - $this->messageManager->addSuccess($message); - $this->_redirect('*/*/'); - return; - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); - } catch (\Exception $e) { - $this->messageManager->addError( - __('We can\'t delete/activate/deactivate rule(s) right now. Please review the log and try again.').$e->getMessage() - ); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); - $this->_redirect('*/*/'); - return; - } - } - $this->messageManager->addError(__('We can\'t find a rule(s) to delete/activate/deactivate.')); - $this->_redirect('*/*/'); - } -} \ No newline at end of file +getRequest()->getParam('rules'); + $action = $this->getRequest()->getParam('action'); + if ($ids && in_array($action, ['activate', 'inactivate', 'delete'])) { + try { + $status = -1; + switch ($action) { + case 'delete': + $collection = $this->_objectManager->create('Astound\Affirm\Model\ResourceModel\Rule\Collection'); + + $collection->addFieldToFilter('rule_id', ['in'=>$ids]); + $collection->walk($action); + $status = -1; + $message = __('You deleted the rule(s).'); + break; + case 'activate': + $status = 1; + $message = __('You activated the rule(s).'); + break; + case 'inactivate': + $status = 0; + $message = __('You deactivated the rule(s).'); + break; + } + + if ($status > -1) { + $this->_objectManager->create('Astound\Affirm\Model\Rule')->massChangeStatus($ids, $status); + } + + $this->messageManager->addSuccess($message); + $this->_redirect('*/*/'); + return; + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->messageManager->addError($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager->addError( + __('We can\'t delete/activate/deactivate rule(s) right now. Please review the log and try again.').$e->getMessage() + ); + $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_redirect('*/*/'); + return; + } + } + $this->messageManager->addError(__('We can\'t find a rule(s) to delete/activate/deactivate.')); + $this->_redirect('*/*/'); + } +} diff --git a/Controller/Adminhtml/Rule/NewAction.php b/Controller/Adminhtml/Rule/NewAction.php index d57a4461..3b493c59 100755 --- a/Controller/Adminhtml/Rule/NewAction.php +++ b/Controller/Adminhtml/Rule/NewAction.php @@ -1,11 +1,12 @@ -_forward('edit'); - } -} \ No newline at end of file +use Magento\Framework\App\ResponseInterface; + +class NewAction extends \Astound\Affirm\Controller\Adminhtml\Rule +{ + public function execute() + { + $this->_forward('edit'); + } +} diff --git a/Controller/Adminhtml/Rule/NewActionHtml.php b/Controller/Adminhtml/Rule/NewActionHtml.php index 95fffbd0..6dc64188 100755 --- a/Controller/Adminhtml/Rule/NewActionHtml.php +++ b/Controller/Adminhtml/Rule/NewActionHtml.php @@ -1,10 +1,10 @@ -newConditions('actions'); - } -} \ No newline at end of file +newConditions('actions'); + } +} diff --git a/Controller/Adminhtml/Rule/NewConditionHtml.php b/Controller/Adminhtml/Rule/NewConditionHtml.php index 67971ee2..4c17269c 100755 --- a/Controller/Adminhtml/Rule/NewConditionHtml.php +++ b/Controller/Adminhtml/Rule/NewConditionHtml.php @@ -1,10 +1,10 @@ -newConditions('conditions'); - } -} \ No newline at end of file +newConditions('conditions'); + } +} diff --git a/Controller/Adminhtml/Rule/Save.php b/Controller/Adminhtml/Rule/Save.php index 4135d042..cd9db2ef 100755 --- a/Controller/Adminhtml/Rule/Save.php +++ b/Controller/Adminhtml/Rule/Save.php @@ -1,81 +1,82 @@ -getRequest()->getPostValue()) { - try { - $model = $this->_objectManager->create('Astound\Affirm\Model\Rule'); - $data = $this->getRequest()->getPostValue(); - $inputFilter = new FilterInput( - [], - [], - $data - ); - $data = $inputFilter->getUnescaped(); - $id = $this->getRequest()->getParam('id'); - if ($id) { - $model->load($id); - if ($id != $model->getId()) { - throw new \Magento\Framework\Exception\LocalizedException(__('The wrong item is specified.')); - } - } - if (isset($data['rule']['conditions'])) { - $data['conditions'] = $data['rule']['conditions']; - } - unset($data['rule']); - - $model->addData($data); - $model->loadPost($data); // rules - $this->_prepareForSave($model); - - $session = $this->_objectManager->get('Magento\Backend\Model\Session'); - $session->setPageData($model->getData()); - $model->save(); - $this->messageManager->addSuccess(__('You saved the rule.')); - $session->setPageData(false); - if ($this->getRequest()->getParam('back')) { - $this->_redirect('*/*/edit', ['id' => $model->getId()]); - return; - } - $this->_redirect('*/*/'); - return; - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); - $id = (int)$this->getRequest()->getParam('id'); - if (!empty($id)) { - $this->_redirect('*/*/edit', ['id' => $id]); - } else { - $this->_redirect('*/*/new'); - } - return; - } catch (\Exception $e) { - $this->messageManager->addError( - __('Something went wrong while saving the item data. Please review the error log.') - ); - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); - $this->_objectManager->get('Magento\Backend\Model\Session')->setPageData($data); - $this->_redirect('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); - return; - } - } - $this->_redirect('*/*/'); - } - - protected function _prepareForSave($model) - { - $fields = array('stores', 'cust_groups', 'methods'); - foreach ($fields as $f){ - $val = $model->getData($f); - $model->setData($f, ''); - if (is_array($val)){ - $model->setData($f, ',' . implode(',', $val) . ','); - } - } - - return true; - } -} \ No newline at end of file +use Magento\Framework\Filter\FilterInput; + +class Save extends \Astound\Affirm\Controller\Adminhtml\Rule +{ + public function execute() + { + if ($this->getRequest()->getPostValue()) { + try { + $model = $this->_objectManager->create('Astound\Affirm\Model\Rule'); + $data = $this->getRequest()->getPostValue(); + $inputFilter = new FilterInput( + [], + [], + $data + ); + $data = $inputFilter->getUnescaped(); + $id = $this->getRequest()->getParam('id'); + if ($id) { + $model->load($id); + if ($id != $model->getId()) { + throw new \Magento\Framework\Exception\LocalizedException(__('The wrong item is specified.')); + } + } + if (isset($data['rule']['conditions'])) { + $data['conditions'] = $data['rule']['conditions']; + } + unset($data['rule']); + + $model->addData($data); + $model->loadPost($data); // rules + $this->_prepareForSave($model); + + $session = $this->_objectManager->get('Magento\Backend\Model\Session'); + $session->setPageData($model->getData()); + $model->save(); + $this->messageManager->addSuccess(__('You saved the rule.')); + $session->setPageData(false); + if ($this->getRequest()->getParam('back')) { + $this->_redirect('*/*/edit', ['id' => $model->getId()]); + return; + } + $this->_redirect('*/*/'); + return; + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->messageManager->addError($e->getMessage()); + $id = (int)$this->getRequest()->getParam('id'); + if (!empty($id)) { + $this->_redirect('*/*/edit', ['id' => $id]); + } else { + $this->_redirect('*/*/new'); + } + return; + } catch (\Exception $e) { + $this->messageManager->addError( + __('Something went wrong while saving the item data. Please review the error log.') + ); + $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $this->_objectManager->get('Magento\Backend\Model\Session')->setPageData($data); + $this->_redirect('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); + return; + } + } + $this->_redirect('*/*/'); + } + + protected function _prepareForSave($model) + { + $fields = ['stores', 'cust_groups', 'methods']; + foreach ($fields as $f) { + $val = $model->getData($f); + $model->setData($f, ''); + if (is_array($val)) { + $model->setData($f, ',' . implode(',', $val) . ','); + } + } + + return true; + } +} diff --git a/Controller/Payment/Confirm.php b/Controller/Payment/Confirm.php index d470213d..fca544c9 100644 --- a/Controller/Payment/Confirm.php +++ b/Controller/Payment/Confirm.php @@ -47,7 +47,6 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Request\InvalidRequestException; - /** * Class Confirm * @@ -119,7 +118,7 @@ public function createCsrfValidationException( public function validateForCsrf(RequestInterface $request): ?bool { return true; - } + } /** * Dispatch request diff --git a/Gateway/Command/CaptureStrategyCommand.php b/Gateway/Command/CaptureStrategyCommand.php index 0ed0c71c..81786d8f 100644 --- a/Gateway/Command/CaptureStrategyCommand.php +++ b/Gateway/Command/CaptureStrategyCommand.php @@ -105,14 +105,14 @@ public function execute(array $commandSubject) } } - if($this->getConfigData('payment_action') == 'authorize_capture'){ + if ($this->getConfigData('payment_action') == 'authorize_capture') { $last_invoice_amount = $paymentInfo->getAdditionalInformation(self::LAST_INVOICE_AMOUNT); $amountInCents = Util::formatToCents($last_invoice_amount); - if ($amountInCents == 0 ) { + if ($amountInCents == 0) { return $this->commandPool ->get(self::VOID) - ->execute($commandSubject); - } + ->execute($commandSubject); + } } diff --git a/Gateway/Helper/Util.php b/Gateway/Helper/Util.php index e898c3f3..adf78f29 100644 --- a/Gateway/Helper/Util.php +++ b/Gateway/Helper/Util.php @@ -111,5 +111,4 @@ public function generateIdempotencyKey() { return $this->_random->getUniqueHash(); } - } diff --git a/Gateway/Http/AbstractTransferFactory.php b/Gateway/Http/AbstractTransferFactory.php index dde4795a..925df41d 100644 --- a/Gateway/Http/AbstractTransferFactory.php +++ b/Gateway/Http/AbstractTransferFactory.php @@ -98,7 +98,7 @@ public function __construct( protected function getPublicApiKey($storeId, $country_code) { $country_suffix = $this->getApiKeyNameByCountry($country_code); - if(!empty($storeId)){ + if (!empty($storeId)) { return $this->config->getValue(self::MODE, $storeId) == self::SANDBOX ? $this->config->getValue('public_api_key_sandbox' . $country_suffix, $storeId) : $this->config->getValue('public_api_key_production' . $country_suffix, $storeId); @@ -107,7 +107,6 @@ protected function getPublicApiKey($storeId, $country_code) ? $this->config->getValue('public_api_key_sandbox' . $country_suffix) : $this->config->getValue('public_api_key_production' . $country_suffix); } - } /** @@ -120,7 +119,7 @@ protected function getPublicApiKey($storeId, $country_code) protected function getPrivateApiKey($storeId, $country_code) { $country_suffix = $this->getApiKeyNameByCountry($country_code); - if(!empty($storeId)){ + if (!empty($storeId)) { return $this->config->getValue('mode', $storeId) == self::SANDBOX ? $this->config->getValue('private_api_key_sandbox' . $country_suffix, $storeId) : $this->config->getValue('private_api_key_production' . $country_suffix, $storeId); @@ -150,10 +149,10 @@ protected function getStoreId() protected function getApiKeyNameByCountry($country_code) { $_suffix = ''; - $countryCodeToSuffix = array( + $countryCodeToSuffix = [ self::COUNTRY_CODE_CAN => self::SUFFIX_CANADA, self::COUNTRY_CODE_USA => '', - ); + ]; if (isset($country_code)) { $_suffix = $countryCodeToSuffix[$country_code] ?: ''; diff --git a/Gateway/Request/RefundRequest.php b/Gateway/Request/RefundRequest.php index 0012537c..9d0d1c3c 100644 --- a/Gateway/Request/RefundRequest.php +++ b/Gateway/Request/RefundRequest.php @@ -51,7 +51,7 @@ public function build(array $buildSubject) $payment->setAdditionalInformation(self::LAST_INVOICE_AMOUNT, $creditMemoAmount); $amountInCents = Util::formatToCents($creditMemoAmount); $order = $payment->getOrder(); - if($order) { + if ($order) { $storeId = $order->getStoreId(); } if (!$storeId) { diff --git a/Gateway/Request/VoidRequest.php b/Gateway/Request/VoidRequest.php index 50e1aed3..f8ec1085 100644 --- a/Gateway/Request/VoidRequest.php +++ b/Gateway/Request/VoidRequest.php @@ -47,7 +47,7 @@ public function build(array $buildSubject) $payment->getAdditionalInformation(self::CHARGE_ID); $countryCode = $payment->getAdditionalInformation(self::COUNTRY_CODE) ?: self::DEFAULT_COUNTRY_CODE; $order = $payment->getOrder(); - if($order) { + if ($order) { $storeId = $order->getStoreId(); } if (!$storeId) { diff --git a/Gateway/Validator/Client/PaymentActionsValidator.php b/Gateway/Validator/Client/PaymentActionsValidator.php index a01dca9b..c33ddde2 100644 --- a/Gateway/Validator/Client/PaymentActionsValidator.php +++ b/Gateway/Validator/Client/PaymentActionsValidator.php @@ -38,18 +38,18 @@ public function validate(array $validationSubject) $amount = ''; $_payment = $validationSubject['payment']->getPayment(); - if ( (isset($response['checkout_status']) && $response['checkout_status'] == 'confirmed') + if ((isset($response['checkout_status']) && $response['checkout_status'] == 'confirmed') || (isset($response['status']) && $response['status'] == 'authorized') ) { // Pre-Auth/Auth uses amount_ordered from payment $payment_data = $_payment->getData(); $amount = $payment_data['amount_ordered']; - } elseif ( (isset($response['type']) && $response['type'] == 'capture') + } elseif ((isset($response['type']) && $response['type'] == 'capture') || (isset($response['type']) && $response['type'] == 'split_capture') ) { // Capture or partial capture (US only) uses stored value from invoice total $amount = $_payment->getAdditionalInformation(self::LAST_INVOICE_AMOUNT); - } elseif ( (isset($response['type']) && $response['type'] == 'refund') + } elseif ((isset($response['type']) && $response['type'] == 'refund') ) { // Refund (including partial) uses grand_total from creditmemo (credit memo invoice) $_creditMemo = $_payment->getData()['creditmemo']; diff --git a/Gateway/Validator/Client/PaymentActionsValidatorCaptureFailVoid.php b/Gateway/Validator/Client/PaymentActionsValidatorCaptureFailVoid.php index 9c4fa42d..08bacc22 100644 --- a/Gateway/Validator/Client/PaymentActionsValidatorCaptureFailVoid.php +++ b/Gateway/Validator/Client/PaymentActionsValidatorCaptureFailVoid.php @@ -56,16 +56,15 @@ public function validate(array $validationSubject) $validationResult = $this->validateResponseCode($response) && $this->validateResponseType($response); - $this->affirmLogger->debug('Astound\Affirm\Gateway\Validator\Client\PaymentActionsValidator:validate', array('LAST_INVOICE_AMOUNT not set')); + $this->affirmLogger->debug('Astound\Affirm\Gateway\Validator\Client\PaymentActionsValidator:validate', ['LAST_INVOICE_AMOUNT not set']); if (!$validationResult) { - $this->affirmLogger->debug('Astound\Affirm\Gateway\Validator\Client\PaymentActionsValidator:validate', array('Affirm API Failed')); + $this->affirmLogger->debug('Astound\Affirm\Gateway\Validator\Client\PaymentActionsValidator:validate', ['Affirm API Failed']); } $errorMessages = [__('Transaction has been declined, please, try again later.')]; throw new \Magento\Framework\Validator\Exception(__($errorMessages[0])); - } /** diff --git a/Helper/AsLowAs.php b/Helper/AsLowAs.php index 18ee7c0b..bc4c6e32 100644 --- a/Helper/AsLowAs.php +++ b/Helper/AsLowAs.php @@ -56,8 +56,8 @@ protected function getCategoryCollection(Product\Collection $productCollection) /** @var Category\Collection $categoryProductCollection */ $categoryProductCollection = $product->getCategoryCollection(); $categoryProductCollection - ->addAttributeToFilter('affirm_category_mfp', array('neq' => '')) - ->addAttributeToFilter('affirm_category_mfp', array('notnull' => true)); + ->addAttributeToFilter('affirm_category_mfp', ['neq' => '']) + ->addAttributeToFilter('affirm_category_mfp', ['notnull' => true]); $categoryIds = $categoryProductCollection->getAllIds(); if (!empty($categoryIds)) { $categoryItemsIds = array_merge($categoryItemsIds, $categoryIds); @@ -68,7 +68,7 @@ protected function getCategoryCollection(Product\Collection $productCollection) /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ $categoryCollection = $this->categoryCollectionFactory->create() ->addAttributeToSelect(['affirm_category_mfp', 'affirm_category_mfp_type', 'affirm_category_mfp_priority', 'affirm_category_mfp_start_date', 'affirm_category_mfp_end_date']) - ->addAttributeToFilter('entity_id', array('in' => $categoryItemsIds)); + ->addAttributeToFilter('entity_id', ['in' => $categoryItemsIds]); if ($flagProductWithoutMfpCategories) { $categoryCollection->setFlag('productWithoutMfpCategories', true); } diff --git a/Helper/Data.php b/Helper/Data.php index be9da315..3d681e82 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,73 +1,73 @@ -objectManager = $objectManager; - $this->coreRegistry = $registry; - parent::__construct($context); - } - - public function getAllGroups() - { - $customerGroups = $this->objectManager->create('Magento\Customer\Model\ResourceModel\Group\Collection')->load()->toOptionArray(); - - $found = false; - foreach ($customerGroups as $group) { - if ($group['value']==0) { - $found = true; - } - } - if (!$found) { - array_unshift($customerGroups, array('value'=>0, 'label'=>__('NOT LOGGED IN'))); - } - - return $customerGroups; - } - - public function getAllMethods() - { - $hash = []; - foreach ($this->scopeConfig->getValue('payment') as $code=>$config){ - if (!empty($config['title'])){ - $label = ''; - if (!empty($config['group'])){ - $label = ucfirst($config['group']) . ' - '; - } - $label .= $config['title']; - $hash[$code] = $label; - - } - } - asort($hash); - - $methods = []; - foreach ($hash as $code => $label){ - $methods[] = ['value' => $code, 'label' => $label]; - } - - return $methods; - } - - public function getStatuses() - { - return array( - '1' => __('Active'), - '0' => __('Inactive'), - ); - } -} \ No newline at end of file +objectManager = $objectManager; + $this->coreRegistry = $registry; + parent::__construct($context); + } + + public function getAllGroups() + { + $customerGroups = $this->objectManager->create('Magento\Customer\Model\ResourceModel\Group\Collection')->load()->toOptionArray(); + + $found = false; + foreach ($customerGroups as $group) { + if ($group['value']==0) { + $found = true; + } + } + if (!$found) { + array_unshift($customerGroups, ['value'=>0, 'label'=>__('NOT LOGGED IN')]); + } + + return $customerGroups; + } + + public function getAllMethods() + { + $hash = []; + foreach ($this->scopeConfig->getValue('payment') as $code => $config) { + if (!empty($config['title'])) { + $label = ''; + if (!empty($config['group'])) { + $label = ucfirst($config['group']) . ' - '; + } + $label .= $config['title']; + $hash[$code] = $label; + + } + } + asort($hash); + + $methods = []; + foreach ($hash as $code => $label) { + $methods[] = ['value' => $code, 'label' => $label]; + } + + return $methods; + } + + public function getStatuses() + { + return [ + '1' => __('Active'), + '0' => __('Inactive'), + ]; + } +} diff --git a/Helper/FinancingProgram.php b/Helper/FinancingProgram.php index 28c43a20..e959cda6 100644 --- a/Helper/FinancingProgram.php +++ b/Helper/FinancingProgram.php @@ -231,7 +231,9 @@ public function getFinancingProgramCartSizeMaxOrderTotal() protected function isFinancingProgramValidCurrentDate() { return $this->getFinancingProgramDateRange() && - $this->_localeDate->isScopeDateInInterval(null, $this->getFinancingProgramStartDate(), + $this->_localeDate->isScopeDateInInterval( + null, + $this->getFinancingProgramStartDate(), $this->getFinancingProgramEndDate() ); } @@ -243,7 +245,9 @@ protected function isFinancingProgramValidCurrentDate() */ public function getCustomerFinancingProgram() { - if($this->isALS) return ''; + if ($this->isALS) { + return ''; + } if (null === $this->customerFP) { if ($this->customerSession->isLoggedIn()) { @@ -271,7 +275,7 @@ protected function getQuoteProductCollection() } $this->products = $this->productCollectionFactory->create() ->addAttributeToSelect(['affirm_product_mfp', 'affirm_product_promo_id', 'affirm_product_mfp_type', 'affirm_product_mfp_priority', 'affirm_product_mfp_start_date', 'affirm_product_mfp_end_date']) - ->addAttributeToFilter('entity_id', array('in' => $productIds)); + ->addAttributeToFilter('entity_id', ['in' => $productIds]); } return $this->products; } @@ -283,7 +287,7 @@ protected function getQuoteProductCollection() */ protected function getQuoteCategoryCollection($productCollection = null) { - if(is_null($productCollection)) { + if (is_null($productCollection)) { $productCollection = $this->getQuoteProductCollection(); } $categoryItemsIds = []; @@ -292,14 +296,14 @@ protected function getQuoteCategoryCollection($productCollection = null) foreach ($productCollection as $product) { /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryProductCollection */ $categoryProductCollection = $product->getCategoryCollection(); - if($this->isALS) { + if ($this->isALS) { $categoryProductCollection - ->addAttributeToFilter('affirm_category_promo_id', array('neq' => '')) - ->addAttributeToFilter('affirm_category_promo_id', array('notnull' => true)); + ->addAttributeToFilter('affirm_category_promo_id', ['neq' => '']) + ->addAttributeToFilter('affirm_category_promo_id', ['notnull' => true]); } else { $categoryProductCollection - ->addAttributeToFilter('affirm_category_mfp', array('neq' => '')) - ->addAttributeToFilter('affirm_category_mfp', array('notnull' => true)); + ->addAttributeToFilter('affirm_category_mfp', ['neq' => '']) + ->addAttributeToFilter('affirm_category_mfp', ['notnull' => true]); } $categoryIds = $categoryProductCollection->getAllIds(); @@ -312,7 +316,7 @@ protected function getQuoteCategoryCollection($productCollection = null) /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ $categoryCollection = $this->categoryCollectionFactory->create() ->addAttributeToSelect(['affirm_category_mfp', 'affirm_category_promo_id', 'affirm_category_mfp_type', 'affirm_category_mfp_priority', 'affirm_category_mfp_start_date', 'affirm_category_mfp_end_date']) - ->addAttributeToFilter('entity_id', array('in' => $categoryItemsIds)); + ->addAttributeToFilter('entity_id', ['in' => $categoryItemsIds]); if ($flagProductWithoutMfpCategories) { $categoryCollection->setFlag('productWithoutMfpCategories', true); } @@ -327,10 +331,10 @@ protected function getQuoteCategoryCollection($productCollection = null) */ protected function getFinancingProgramFromEntityItems(array $entityItems) { - $exclusiveMFP = array(); - $inclusiveMFP = array(); + $exclusiveMFP = []; + $inclusiveMFP = []; $existItemWithoutMFP = false; - $inclusiveMFPTemp = array(); + $inclusiveMFPTemp = []; $this->entityFP = ''; foreach ($entityItems as $entityItemMFP) { if (!$entityItemMFP['value']) { @@ -343,10 +347,10 @@ protected function getFinancingProgramFromEntityItems(array $entityItems) } else { if (!in_array($entityItemMFP['value'], $inclusiveMFPTemp)) { $inclusiveMFPTemp[] = $entityItemMFP['value']; - $inclusiveMFP[] = array( + $inclusiveMFP[] = [ 'value' => $entityItemMFP['value'], 'priority' => $entityItemMFP['priority'] - ); + ]; } } } @@ -383,10 +387,10 @@ protected function convertProductCollectionToItemsArray( $start_date = $entity->getAffirmProductMfpStartDate(); $end_date = $entity->getAffirmProductMfpEndDate(); $_value = $this->isALS ? $entity->getAffirmProductPromoId() : $entity->getAffirmProductMfp(); - if(empty($start_date) || empty($end_date)) { + if (empty($start_date) || empty($end_date)) { $mfpValue = $_value; } else { - if($this->_localeDate->isScopeDateInInterval(null, $start_date, $end_date)) { + if ($this->_localeDate->isScopeDateInInterval(null, $start_date, $end_date)) { $mfpValue = $_value; } else { $mfpValue = ""; @@ -416,10 +420,10 @@ protected function convertCategoryCollectionToItemsArray( $start_date = $entity->getAffirmCategoryMfpStartDate(); $end_date = $entity->getAffirmCategoryMfpEndDate(); $_value = $this->isALS ? $entity->getAffirmCategoryPromoId() : $entity->getAffirmCategoryMfp(); - if(empty($start_date) || empty($end_date)) { + if (empty($start_date) || empty($end_date)) { $mfpValue = $_value; } else { - if($this->_localeDate->isScopeDateInInterval(null, $start_date, $end_date)) { + if ($this->_localeDate->isScopeDateInInterval(null, $start_date, $end_date)) { $mfpValue = $_value; } else { $mfpValue = ""; @@ -524,20 +528,20 @@ protected function getFinancingProgramFromCartSize() && $cartTotal >= $minTotal && $cartTotal <= $maxTotal ) { - if($this->isALS) { + if ($this->isALS) { $this->cartSizePromoId = $cartSizeValue; } else { $this->cartSizeFP = $cartSizeValue; } } else { - if($this->isALS) { + if ($this->isALS) { $this->cartSizePromoId = ''; } else { $this->cartSizeFP = ''; } } } - if($this->isALS) { + if ($this->isALS) { return $this->cartSizePromoId; } else { return $this->cartSizeFP; diff --git a/Helper/Payment.php b/Helper/Payment.php index 0a217105..10ef8ef2 100644 --- a/Helper/Payment.php +++ b/Helper/Payment.php @@ -40,7 +40,7 @@ class Payment /** * Region (country) code for address validation */ - const VALID_REGIONS = array('US', 'CA'); + const VALID_REGIONS = ['US', 'CA']; const DEFAULT_REGION = 'US'; /** @@ -288,7 +288,7 @@ public function getConfigurableProductBackordersOptions(Product $product = null) $productTypeConfigurable = $product->getTypeInstance(); $childProducts = $productTypeConfigurable->getUsedProducts($product); $configurableAttributes = $productTypeConfigurable->getConfigurableAttributesAsArray($product); - $result = array(); + $result = []; /** @var Product $childProduct */ foreach ($childProducts as $childProduct) { foreach ($configurableAttributes as $configurableAttribute) { diff --git a/Helper/Payment/Data.php b/Helper/Payment/Data.php index bc54108f..0ca0448b 100755 --- a/Helper/Payment/Data.php +++ b/Helper/Payment/Data.php @@ -1,75 +1,76 @@ -getShippingAddress(); - foreach ($methods as $k => $method) { - foreach ($this->getRules($address) as $rule) { - if ($rule->restrict($method)) { - if ($rule->validate($address)) { - unset($methods[$k]); - } - } - } - } - - return $methods; - } - - public function getRules($address) - { - if (is_null($this->_allRules)) { - $om = \Magento\Framework\App\ObjectManager::getInstance(); - $hlp = $om->create('Astound\Affirm\Model\Rule'); - $this->_allRules = $hlp->getCollection()->addAddressFilter($address)->load(); - foreach ($this->_allRules as $rule) { - $rule->afterLoad(); - } - } - - return $this->_allRules; - } -} \ No newline at end of file +class Data extends \Magento\Payment\Helper\Data +{ + protected $_allRules = null; + + public function getStoreMethods($store = null, $quote = null) + { + $methods = parent::getStoreMethods($store, $quote); + if (!$quote) { + return $methods; + } + + $address = $quote->getShippingAddress(); + foreach ($methods as $k => $method) { + foreach ($this->getRules($address) as $rule) { + if ($rule->restrict($method)) { + if ($rule->validate($address)) { + unset($methods[$k]); + } + } + } + } + + return $methods; + } + + public function getRules($address) + { + if (is_null($this->_allRules)) { + $om = \Magento\Framework\App\ObjectManager::getInstance(); + $hlp = $om->create('Astound\Affirm\Model\Rule'); + $this->_allRules = $hlp->getCollection()->addAddressFilter($address)->load(); + foreach ($this->_allRules as $rule) { + $rule->afterLoad(); + } + } + + return $this->_allRules; + } +} diff --git a/Helper/Pixel.php b/Helper/Pixel.php index cbf3e70e..67bee890 100644 --- a/Helper/Pixel.php +++ b/Helper/Pixel.php @@ -124,12 +124,12 @@ public function escapeSingleQuotes($str) } /** - * Based on provided configuration path returns configuration value. - * - * @param string $configPath - * @param string|int $scope - * @return string - */ + * Based on provided configuration path returns configuration value. + * + * @param string $configPath + * @param string|int $scope + * @return string + */ public function getConfig($configPath, $scope = 'default') { return $this->scopeConfig->getValue( diff --git a/Helper/Rule.php b/Helper/Rule.php index 60a8be09..fb26f173 100644 --- a/Helper/Rule.php +++ b/Helper/Rule.php @@ -17,13 +17,12 @@ class Rule extends Payment public function getRules() { - if (is_null($this->_allRules)) - { + if (is_null($this->_allRules)) { $om = \Magento\Framework\App\ObjectManager::getInstance(); $hlp = $om->create('Astound\Affirm\Model\Rule'); $this->_allRules = $hlp->getCollection()->addFieldToFilter('is_active', 1); $this->_allRules->load(); - foreach ($this->_allRules as $rule){ + foreach ($this->_allRules as $rule) { $rule->afterLoad(); } } @@ -33,7 +32,7 @@ public function getRules() public function isAslowasAllowedPerRule($position) { - if(isset($position)) { + if (isset($position)) { switch ($position) { case 'cc': return $this->isQuoteItemsDisabledByPaymentRestRules(); @@ -47,8 +46,8 @@ public function isAslowasAllowedPerRule($position) public function isQuoteItemsDisabledByPaymentRestRules() { - foreach ($this->getRules() as $rule){ - if ($rule->restrictByName(\Astound\Affirm\Model\Ui\ConfigProvider::CODE)){ + foreach ($this->getRules() as $rule) { + if ($rule->restrictByName(\Astound\Affirm\Model\Ui\ConfigProvider::CODE)) { $om = \Magento\Framework\App\ObjectManager::getInstance(); $checkoutsession = $om->get('Magento\Checkout\Model\Session'); $quote = $checkoutsession->getQuote(); diff --git a/Logger/Handler.php b/Logger/Handler.php index 6af04930..8d72366b 100644 --- a/Logger/Handler.php +++ b/Logger/Handler.php @@ -17,4 +17,4 @@ class Handler extends BaseHandler * @var string */ protected $fileName = '/var/log/affirm.log'; -} \ No newline at end of file +} diff --git a/Logger/Logger.php b/Logger/Logger.php index 722ff890..e89fbd9f 100644 --- a/Logger/Logger.php +++ b/Logger/Logger.php @@ -3,4 +3,4 @@ class Logger extends \Monolog\Logger { -} \ No newline at end of file +} diff --git a/Model/Adminhtml/Feed.php b/Model/Adminhtml/Feed.php index a47a0321..3d06cdea 100644 --- a/Model/Adminhtml/Feed.php +++ b/Model/Adminhtml/Feed.php @@ -98,5 +98,4 @@ protected function _isNotificationSubscribed() { return $this->_backendConfig->getValue(self::XML_FEEDS_SUBSCRIBED) == 1; } - } diff --git a/Model/Adminhtml/Observer/PredispatchObserver.php b/Model/Adminhtml/Observer/PredispatchObserver.php index 05be4462..17b8035e 100644 --- a/Model/Adminhtml/Observer/PredispatchObserver.php +++ b/Model/Adminhtml/Observer/PredispatchObserver.php @@ -5,7 +5,6 @@ use Magento\Backend\Model\Auth\Session; use Astound\Affirm\Model\Adminhtml\FeedFactory; - /** * Customer Observer Model */ diff --git a/Model/AffirmCheckoutManager.php b/Model/AffirmCheckoutManager.php index 98d8df66..6c0940b5 100644 --- a/Model/AffirmCheckoutManager.php +++ b/Model/AffirmCheckoutManager.php @@ -212,7 +212,7 @@ public function initCheckout() } - $itemTypes = array(); + $itemTypes = []; $items = $this->quote->getAllVisibleItems(); foreach ($items as $item) { $itemTypes[] = $item->getProductType(); @@ -221,7 +221,7 @@ public function initCheckout() $response['product_types'] = array_unique($itemTypes); $productType = true; - if (count($response['product_types']) == 1 && ($response['product_types'][0] == 'downloadable' || $response['product_types'][0] == 'virtual' ) ) { + if (count($response['product_types']) == 1 && ($response['product_types'][0] == 'downloadable' || $response['product_types'][0] == 'virtual' )) { $productType = false; } @@ -249,47 +249,49 @@ public function initCheckout() return json_encode($response); } - private function getShippingAddress(){ + private function getShippingAddress() + { $shippingAddress = $this->quote->getShippingAddress(); - $shippingObject = array( - 'name' => array( + $shippingObject = [ + 'name' => [ 'full_name' => $shippingAddress->getName(), 'first' => $shippingAddress->getFirstname(), 'last' => $shippingAddress->getLastname() - ), - 'address'=>array( + ], + 'address'=>[ 'line' => $shippingAddress->getStreet(), 'city' => $shippingAddress->getCity(), 'state' => $shippingAddress->getRegionCode() ? $shippingAddress->getRegionCode() : $this->getRegionCode($shippingAddress->getRegionId()), 'postcode' =>$shippingAddress->getPostcode(), 'country' =>$shippingAddress->getCountryId() - ) - ); + ] + ]; return $shippingObject; } - private function getBillingAddress(){ + private function getBillingAddress() + { $billingAddress = $this->quote->getBillingAddress(); - $billingObject = array( - 'name' => array( + $billingObject = [ + 'name' => [ 'full_name' => $billingAddress->getName(), 'first' => $billingAddress->getFirstname(), 'last' => $billingAddress->getLastname() - ), - 'address'=>array( + ], + 'address'=>[ 'line' => $billingAddress->getStreet(), 'city' => $billingAddress->getCity(), 'state' => $billingAddress->getRegionCode() ? $billingAddress->getRegionCode() : $this->getRegionCode($billingAddress->getRegionId()), 'postcode' =>$billingAddress->getPostcode(), 'country' =>$billingAddress->getCountryId() - ) - ); + ] + ]; return $billingObject; - } - private function getRegionCode( $regionID ){ + private function getRegionCode($regionID) + { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $region = $objectManager->create('Magento\Directory\Model\Region') ->load($regionID); diff --git a/Model/Checkout.php b/Model/Checkout.php index 4a5568b7..6017aa4b 100644 --- a/Model/Checkout.php +++ b/Model/Checkout.php @@ -115,7 +115,7 @@ public function __construct( \Magento\Checkout\Helper\Data $checkoutData, OrderSender $orderSender, AffirmConfig $config, - $params = array() + $params = [] ) { $this->checkoutSession = $checkoutSession; $this->quoteManagement = $cartManagement; @@ -172,8 +172,9 @@ public function place($token) case \Magento\Sales\Model\Order::STATE_PROCESSING: case \Magento\Sales\Model\Order::STATE_COMPLETE: case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW: - if (!$this->order->getEmailSent()) // Check if order confirmation has already been sent, prevent double email notification. + if (!$this->order->getEmailSent()) { // Check if order confirmation has already been sent, prevent double email notification. $this->orderSender->send(($this->order)); + } $this->checkoutSession->start(); break; default: @@ -311,10 +312,10 @@ public function setCustomerWithAddressChange( */ protected function getCountryCodeByCurrency($currencyCode) { - $currency_map = array( + $currency_map = [ "USD" => ['US','USA'], "CAD" => ['CA','CAN'] - ); + ]; return $currency_map[$currencyCode]; } } diff --git a/Model/Config.php b/Model/Config.php index 806cce0b..1aa60941 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -73,8 +73,8 @@ class Config implements ConfigInterface const METHOD_BML = 'affirm_promo'; const KEY_ASLOWAS = 'affirm_aslowas'; const KEY_MFP = 'affirm_mfp'; - const VALID_CURRENCIES = array('USD', 'CAD'); - const ACCEPTED_LOCALES = array('en_CA', 'fr_CA', 'en_US'); + const VALID_CURRENCIES = ['USD', 'CAD']; + const ACCEPTED_LOCALES = ['en_CA', 'fr_CA', 'en_US']; const COUNTRY_CODE_USA = 'USA'; const COUNTRY_CODE_CAN = 'CAN'; const CURRENCY_CODE_USD = 'USD'; @@ -181,8 +181,7 @@ public function __construct( Resolver $store, Currency $currency, TaxConfig $taxConfig - ) - { + ) { $this->scopeConfig = $scopeConfig; $this->storeManager = $storeManager; $this->_store = $store; @@ -523,7 +522,8 @@ public function isAsLowAsEnabled($position) public function getAsLowAsApr() { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_ASLOWAS . '/' . 'apr_value', ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_ASLOWAS . '/' . 'apr_value', + ScopeInterface::SCOPE_WEBSITE ); } @@ -535,7 +535,8 @@ public function getAsLowAsApr() public function getAsLowAsMonths() { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_ASLOWAS . '/' . 'month', ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_ASLOWAS . '/' . 'month', + ScopeInterface::SCOPE_WEBSITE ); } @@ -547,7 +548,8 @@ public function getAsLowAsMonths() public function getAsLowAsLogo() { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_ASLOWAS . '/' . 'logo', ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_ASLOWAS . '/' . 'logo', + ScopeInterface::SCOPE_WEBSITE ); } @@ -559,7 +561,8 @@ public function getAsLowAsLogo() public function getAsLowAsMinMpp() { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_ASLOWAS . '/' . 'min_mpp', ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_ASLOWAS . '/' . 'min_mpp', + ScopeInterface::SCOPE_WEBSITE ); } @@ -571,7 +574,8 @@ public function getAsLowAsMinMpp() public function getAsLowAsValue($key) { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_ASLOWAS . '/' . $key, ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_ASLOWAS . '/' . $key, + ScopeInterface::SCOPE_WEBSITE ); } @@ -583,7 +587,8 @@ public function getAsLowAsValue($key) public function getMfpValue($key) { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_MFP . '/' . $key, ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_MFP . '/' . $key, + ScopeInterface::SCOPE_WEBSITE ); } @@ -595,7 +600,8 @@ public function getMfpValue($key) public function getPixelValue($key) { return $this->scopeConfig->getValue( - 'affirm/' . self::KEY_PIXEL . '/' . $key, ScopeInterface::SCOPE_WEBSITE + 'affirm/' . self::KEY_PIXEL . '/' . $key, + ScopeInterface::SCOPE_WEBSITE ); } @@ -750,10 +756,10 @@ public function getPartialCapture($countryCode = self::COUNTRY_CODE_USA) protected function getApiKeyNameByCurrency($currency_code) { $_suffix = ''; - $currencyCodeToSuffix = array( + $currencyCodeToSuffix = [ self::CURRENCY_CODE_CAD => self::SUFFIX_CANADA, self::CURRENCY_CODE_USD => '', - ); + ]; if (array_key_exists($currency_code, $currencyCodeToSuffix)) { $_suffix = $currencyCodeToSuffix[$currency_code] ?: ''; diff --git a/Model/Config/System/Source/Size.php b/Model/Config/System/Source/Size.php index af67ea6a..f71a5999 100644 --- a/Model/Config/System/Source/Size.php +++ b/Model/Config/System/Source/Size.php @@ -59,9 +59,9 @@ class Size implements \Magento\Framework\Option\ArrayInterface */ public function toOptionArray() { - $options = array(); + $options = []; foreach (self::$sizes as $size) { - $options[] = array('value' => $size, 'label' => $size); + $options[] = ['value' => $size, 'label' => $size]; } return $options; } diff --git a/Model/InlineCheckout.php b/Model/InlineCheckout.php index eb8aaa12..b7830327 100644 --- a/Model/InlineCheckout.php +++ b/Model/InlineCheckout.php @@ -63,7 +63,7 @@ public function __construct( Util $util, QuoteValidator $quoteValidator, ObjectManagerInterface $objectManager - ){ + ) { $this->session = $checkoutSession; $this->quote = $checkoutSession->getQuote(); $this->urlBuilder = $urlInterface; @@ -74,54 +74,55 @@ public function __construct( $this->objectManager = $objectManager; } - public function initInline(){ + public function initInline() + { $quote = $this->quote; $quote->collectTotals(); - if(!$quote->getReservedOrderId()) { + if (!$quote->getReservedOrderId()) { $quote->reserveOrderId(); } - try{ + try { $this->quoteValidator->validateBeforeSubmit($quote); } catch (LocalizedException $e) { - return json_encode(array( - 'merchant' => array( + return json_encode([ + 'merchant' => [ 'user_confirmation_url' => $this->urlBuilder ->getUrl('affirm/payment/confirm', ['_secure' => true]), 'user_cancel_url' => $this->urlBuilder ->getUrl('affirm/payment/cancel', ['_secure' => true]), 'user_confirmation_url_action' => 'POST', - ), + ], 'order_id' => $quote->getReservedOrderId(), 'total' => $this->util->formatToCents($quote->getGrandTotal()) - )); + ]); - }catch (\Exception $e) { + } catch (\Exception $e) { } - $checkoutObject = array( - 'merchant' => array( + $checkoutObject = [ + 'merchant' => [ 'user_confirmation_url' => $this->urlBuilder ->getUrl('affirm/payment/confirm', ['_secure' => true]), 'user_cancel_url' => $this->urlBuilder ->getUrl('affirm/payment/cancel', ['_secure' => true]), 'user_confirmation_url_action' => 'POST', - ), + ], 'order_id' => $quote->getReservedOrderId(), 'shipping_amount' => $this->util->formatToCents($quote->getShippingAddress()->getShippingAmount()), 'total' => $this->util->formatToCents($quote->getGrandTotal()), 'tax_amount' => $this->util->formatToCents($quote->getShippingAddress()->getTaxAmount()), - 'metadata' => array( + 'metadata' => [ 'platform_type' => $this->productMetadata->getName() . ' 2', 'platform_version' => $this->productMetadata->getVersion() . ' ' . $this->productMetadata->getEdition(), 'platform_affirm' => $this->moduleResource->getDbVersion('Astound_Affirm'), 'mode' => 'inline' - ) - ); + ] + ]; - if($items = $this->formatItems($quote->getAllVisibleItems())) { + if ($items = $this->formatItems($quote->getAllVisibleItems())) { $checkoutObject['items'] = $items; } @@ -161,45 +162,47 @@ public function initInline(){ return json_encode($checkoutObject); } - private function formatAddress($address){ + private function formatAddress($address) + { $formattedAddress = false; - if($address->getCity()) { + if ($address->getCity()) { $street = $address->getStreet(); - $formattedAddress = array( - 'name' => array( + $formattedAddress = [ + 'name' => [ 'first' => $address->getFirstName(), 'last' => $address->getLastName(), - ), - 'address' => array( + ], + 'address' => [ 'street1' => isset($street[0]) ? $street[0] : '', 'street2' => isset($street[1]) ? $street[1] : '', 'city' => $address->getCity(), 'region1_code' => $address->getRegion(), 'postal_code' => $address->getPostcode(), 'country' => $address->getCountryId() - ), + ], 'phone_number' => $address->getTelephone() ? $address->getTelephone() : '', 'email' => $address->getEmail() ? $address->getEmail() : '' - ); + ]; } return $formattedAddress; } - private function formatItems($items) { - $formattedItems = array(); - foreach ( (object)$items as $item) { - if( is_object($item)){ + private function formatItems($items) + { + $formattedItems = []; + foreach ((object)$items as $item) { + if (is_object($item)) { $product = $item->getProduct(); - $formattedItems[] = array( + $formattedItems[] = [ 'display_name' => $item->getName(), 'sku' => $item->getSku(), 'unit_price' => $item->getPrice(), 'qty' => $item->getQty(), 'item_image_url' => $product->getData('thumbnail'), 'item_url' => $product->getUrlModel()->getUrl($product) - ); + ]; } } return $formattedItems; diff --git a/Model/Observer/AddressFormat.php b/Model/Observer/AddressFormat.php index a128d862..043afe30 100644 --- a/Model/Observer/AddressFormat.php +++ b/Model/Observer/AddressFormat.php @@ -26,8 +26,7 @@ class AddressFormat implements ObserverInterface protected $regionFactory; public function __construct( RegionFactory $regionFactory - ) - { + ) { $this->regionFactory = $regionFactory; } /** @@ -40,7 +39,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) { $address = $observer->getEvent()->getAddress(); - if($address->getAddressType()) { + if ($address->getAddressType()) { if ($address->getRegion() == null) { $regionId = $address->getRegionId(); /** @var \Magento\Directory\Model\Region $region */ diff --git a/Model/Observer/IdentifyFinancingProgram.php b/Model/Observer/IdentifyFinancingProgram.php index 56c2d7a0..89227468 100644 --- a/Model/Observer/IdentifyFinancingProgram.php +++ b/Model/Observer/IdentifyFinancingProgram.php @@ -23,17 +23,16 @@ use Magento\Customer\Model\Session; use Magento\Framework\App\RequestInterface; - /** * Identify Financing Program for customer */ class IdentifyFinancingProgram implements ObserverInterface { /** - * Customer session - * - * @var \Magento\Customer\Model\Session - */ + * Customer session + * + * @var \Magento\Customer\Model\Session + */ protected $customerSession; /** diff --git a/Model/Plugin/Category/ViewAbstract.php b/Model/Plugin/Category/ViewAbstract.php index 78f9165f..91e6a8e7 100755 --- a/Model/Plugin/Category/ViewAbstract.php +++ b/Model/Plugin/Category/ViewAbstract.php @@ -74,13 +74,12 @@ class ViewAbstract extends \Magento\Framework\DataObject * */ public function __construct( - StoreManagerInterface $storeManagerInterface, - ConfigProvider $configProvider, - Config $configAffirm, - AsLowAs $asLowAs, - ProductCollectionFactory $productCollectionFactory - ) - { + StoreManagerInterface $storeManagerInterface, + ConfigProvider $configProvider, + Config $configAffirm, + AsLowAs $asLowAs, + ProductCollectionFactory $productCollectionFactory + ) { $this->productCollectionFactory = $productCollectionFactory; $this->asLowAsHelper = $asLowAs; @@ -130,7 +129,7 @@ public function getWidgetData() */ public function getDataAffirmColor() { - if(in_array($this->getData('logo'), $this->dataColors)) { + if (in_array($this->getData('logo'), $this->dataColors)) { return 'data-affirm-color="' . $this->getData('logo') . '"'; } return ''; diff --git a/Model/Plugin/Checkout/CustomerData/Cart.php b/Model/Plugin/Checkout/CustomerData/Cart.php index 4c0f61aa..212618b7 100644 --- a/Model/Plugin/Checkout/CustomerData/Cart.php +++ b/Model/Plugin/Checkout/CustomerData/Cart.php @@ -79,7 +79,7 @@ class Cart /** * Checkout session - * + * * @var \Magento\Checkout\Model\Session */ protected $checkoutSession = null; @@ -94,14 +94,13 @@ class Cart * @param \Magento\Checkout\Model\Session $checkoutSession */ public function __construct( - Payment $helperAffirm, - StoreManagerInterface $storeManagerInterface, - Config $configAffirm, - AsLowAs $asLowAs, - ProductCollectionFactory $productCollectionFactory, - Session $checkoutSession - ) - { + Payment $helperAffirm, + StoreManagerInterface $storeManagerInterface, + Config $configAffirm, + AsLowAs $asLowAs, + ProductCollectionFactory $productCollectionFactory, + Session $checkoutSession + ) { $this->checkoutSession = $checkoutSession; $this->affirmPaymentHelper = $helperAffirm; @@ -141,11 +140,11 @@ public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject $result['learnMore'] = ''; $totals = $this->getQuote()->getTotals(); $subtotal = isset($totals['subtotal']) ? $totals['subtotal']->getValue() : 0; - if($subtotal > (float)$this->affirmPaymentConfig->getAsLowAsMinMpp()) { + if ($subtotal > (float)$this->affirmPaymentConfig->getAsLowAsMinMpp()) { $result['mfpValue'] = $this->asLowAsHelper->getFinancingProgramValue(); } $result['learnMore'] = $this->asLowAsHelper->isVisibleLearnmore() ? 'true' :'false'; $result['allow_affirm_quote_aslowas'] = $this->affirmPaymentHelper->isAffirmAvailable(); return $result; } -} \ No newline at end of file +} diff --git a/Model/Plugin/Order/AddressSave/Edit.php b/Model/Plugin/Order/AddressSave/Edit.php index 27a9e482..2da21cf0 100644 --- a/Model/Plugin/Order/AddressSave/Edit.php +++ b/Model/Plugin/Order/AddressSave/Edit.php @@ -99,7 +99,7 @@ public function __construct( * @param callable $method * @return \Magento\Framework\Controller\Result\Redirect */ - public function afterExecute($controller , $method) + public function afterExecute($controller, $method) { $addressId = $controller->getRequest()->getParam('address_id'); @@ -117,21 +117,21 @@ public function afterExecute($controller , $method) $newAddress = $order->getShippingAddress()->getData(); $street = explode(PHP_EOL, $newAddress['street']); $url = $this->getApiUrl("{$transactionId}"); - $data = array( - 'shipping' => array( - 'name' => array( + $data = [ + 'shipping' => [ + 'name' => [ 'full' => $newAddress['firstname'] . ' ' . $newAddress['lastname'] - ), - 'address' => array( + ], + 'address' => [ 'street1' => $street[0], 'street2' => isset($street[1]) ? $street[1]: '' , 'region1_code' => $newAddress['region'], 'city' => $newAddress['city'], 'postal_code' => $newAddress['postcode'], 'country' => $newAddress['country_id'] - ) - ) - ); + ] + ] + ]; $log = []; $log['data'] = $data; diff --git a/Model/Plugin/Payment/CanCapturePartial.php b/Model/Plugin/Payment/CanCapturePartial.php index 7096367b..f92f9de3 100644 --- a/Model/Plugin/Payment/CanCapturePartial.php +++ b/Model/Plugin/Payment/CanCapturePartial.php @@ -20,29 +20,28 @@ class CanCapturePartial { /** - * Affirm config model payment - * - * @var \Astound\Affirm\Model\Config - */ + * Affirm config model payment + * + * @var \Astound\Affirm\Model\Config + */ protected $affirmPaymentConfig; /** * Define constants */ - const DEFAULT_COUNTRY_CODE = 'USA'; + const DEFAULT_COUNTRY_CODE = 'USA'; /** * Constructor * * @param Config $configAffirm */ - public function __construct( - Config $configAffirm - ) - { - $this->affirmPaymentConfig = $configAffirm; - } + public function __construct( + Config $configAffirm + ) { + $this->affirmPaymentConfig = $configAffirm; + } /** * Plugin to verify if Partial Capture is enabled in config @@ -51,16 +50,16 @@ public function __construct( * @param callable $result * @return bool */ - public function afterCanCapturePartial(Payment $subject, $result) - { - $countryCode = self::DEFAULT_COUNTRY_CODE; - if (isset($subject->getData()['additional_information']['country_code'])) { - $countryCode = $subject->getData()['additional_information']['country_code']; - } + public function afterCanCapturePartial(Payment $subject, $result) + { + $countryCode = self::DEFAULT_COUNTRY_CODE; + if (isset($subject->getData()['additional_information']['country_code'])) { + $countryCode = $subject->getData()['additional_information']['country_code']; + } - if (!$this->affirmPaymentConfig->getPartialCapture() || $countryCode != self::DEFAULT_COUNTRY_CODE) { - return false; + if (!$this->affirmPaymentConfig->getPartialCapture() || $countryCode != self::DEFAULT_COUNTRY_CODE) { + return false; + } + return $result; } - return $result; - } } diff --git a/Model/ResourceModel/Rule.php b/Model/ResourceModel/Rule.php index b4dae8f7..864dc512 100755 --- a/Model/ResourceModel/Rule.php +++ b/Model/ResourceModel/Rule.php @@ -1,48 +1,51 @@ -_init('astound_affirm_rule', 'rule_id'); - } - - public function massChangeStatus($ids, $status) - { - $db = $this->getConnection(); - $ids = array_map('intval', $ids); - $db->update($this->getMainTable(), - array('is_active' => $status), 'rule_id IN(' . implode(',', $ids) . ') '); - - return true; - } - - public function getAttributes() - { - $db = $this->getConnection(); - $tbl = $this->getTable('astound_affirm_attribute'); - - $select = $db->select()->from($tbl, new \Zend_Db_Expr('DISTINCT code')); - return $db->fetchCol($select); - } - - public function saveAttributes($id, $attributes) - { - $db = $this->getConnection(); - $tbl = $this->getTable('astound_affirm_attribute'); - - $db->delete($tbl, array('rule_id=?' => $id)); - - $data = array(); - foreach ($attributes as $code){ - $data[] = array( - 'rule_id' => $id, - 'code' => $code, - ); - } - $db->insertMultiple($tbl, $data); - - return $this; - } -} \ No newline at end of file +_init('astound_affirm_rule', 'rule_id'); + } + + public function massChangeStatus($ids, $status) + { + $db = $this->getConnection(); + $ids = array_map('intval', $ids); + $db->update( + $this->getMainTable(), + ['is_active' => $status], + 'rule_id IN(' . implode(',', $ids) . ') ' + ); + + return true; + } + + public function getAttributes() + { + $db = $this->getConnection(); + $tbl = $this->getTable('astound_affirm_attribute'); + + $select = $db->select()->from($tbl, new \Zend_Db_Expr('DISTINCT code')); + return $db->fetchCol($select); + } + + public function saveAttributes($id, $attributes) + { + $db = $this->getConnection(); + $tbl = $this->getTable('astound_affirm_attribute'); + + $db->delete($tbl, ['rule_id=?' => $id]); + + $data = []; + foreach ($attributes as $code) { + $data[] = [ + 'rule_id' => $id, + 'code' => $code, + ]; + } + $db->insertMultiple($tbl, $data); + + return $this; + } +} diff --git a/Model/ResourceModel/Rule/Collection.php b/Model/ResourceModel/Rule/Collection.php index 424a8eb7..7489a77b 100755 --- a/Model/ResourceModel/Rule/Collection.php +++ b/Model/ResourceModel/Rule/Collection.php @@ -1,28 +1,28 @@ -_init('Astound\Affirm\Model\Rule', 'Astound\Affirm\Model\ResourceModel\Rule'); - } - - public function addAddressFilter($address) - { - $this->addFieldToFilter('is_active', 1); - - $storeId = $address->getQuote()->getStoreId(); - $storeId = intVal($storeId); - $this->getSelect()->where('stores="" OR stores LIKE "%,'.$storeId.',%"'); - - $groupId = 0; - if ($address->getQuote()->getCustomerId()){ - $groupId = $address->getQuote()->getCustomer()->getGroupId(); - } - $groupId = intVal($groupId); - $this->getSelect()->where('cust_groups="" OR cust_groups LIKE "%,'.$groupId.',%"'); - - return $this; - } -} \ No newline at end of file +_init('Astound\Affirm\Model\Rule', 'Astound\Affirm\Model\ResourceModel\Rule'); + } + + public function addAddressFilter($address) + { + $this->addFieldToFilter('is_active', 1); + + $storeId = $address->getQuote()->getStoreId(); + $storeId = intVal($storeId); + $this->getSelect()->where('stores="" OR stores LIKE "%,'.$storeId.',%"'); + + $groupId = 0; + if ($address->getQuote()->getCustomerId()) { + $groupId = $address->getQuote()->getCustomer()->getGroupId(); + } + $groupId = intVal($groupId); + $this->getSelect()->where('cust_groups="" OR cust_groups LIKE "%,'.$groupId.',%"'); + + return $this; + } +} diff --git a/Model/Rule.php b/Model/Rule.php index 0d6b3db1..8c271579 100755 --- a/Model/Rule.php +++ b/Model/Rule.php @@ -1,91 +1,95 @@ -objectManager = $objectManager; - $this->storeManager = $storeManager; - parent::__construct( - $context, $registry, $formFactory, $localeDate, null, null, $data - ); - - } - public function validate(\Magento\Framework\DataObject $object) - { - return $this->getConditions()->validateNotModel($object); - } - - protected function _construct() - { - $this->_init('Astound\Affirm\Model\ResourceModel\Rule'); - parent::_construct(); - } - - public function restrict($method) - { - return (false !== strpos($this->getMethods(), ',' . $method->getCode() . ',')); - } - - public function restrictByName($methodname) - { - return (false !== strpos($this->getMethods(), ',' . $methodname . ',')); - } - - public function getConditionsInstance() - { - return $this->objectManager->create('Astound\Affirm\Model\Rule\Condition\Combine'); - } - - public function getActionsInstance() - { - return $this->objectManager->create('Magento\SalesRule\Model\Rule\Condition\Product\Combine'); - } - - public function massChangeStatus($ids, $status) - { - return $this->getResource()->massChangeStatus($ids, $status); - } - - public function afterSave() - { - //Saving attributes used in rule - $ruleProductAttributes = array_merge( - $this->_getUsedAttributes($this->getConditionsSerialized()), - $this->_getUsedAttributes($this->getActionsSerialized()) - ); - if (count($ruleProductAttributes)) { - $this->getResource()->saveAttributes($this->getId(), $ruleProductAttributes); - } - - return parent::afterSave(); - } - - protected function _getUsedAttributes($serializedString) - { - $result = array(); - $pattern = '~s:46:"Magento\\\SalesRule\\\Model\\\Rule\\\Condition\\\Product";s:9:"attribute";s:\d+:"(.*?)"~s'; - $matches = array(); - if (preg_match_all($pattern, $serializedString, $matches)) - { - foreach ($matches[1] as $attributeCode) { - $result[] = $attributeCode; - } - } - - return $result; - } -} \ No newline at end of file +objectManager = $objectManager; + $this->storeManager = $storeManager; + parent::__construct( + $context, + $registry, + $formFactory, + $localeDate, + null, + null, + $data + ); + } + public function validate(\Magento\Framework\DataObject $object) + { + return $this->getConditions()->validateNotModel($object); + } + + protected function _construct() + { + $this->_init('Astound\Affirm\Model\ResourceModel\Rule'); + parent::_construct(); + } + + public function restrict($method) + { + return (false !== strpos($this->getMethods(), ',' . $method->getCode() . ',')); + } + + public function restrictByName($methodname) + { + return (false !== strpos($this->getMethods(), ',' . $methodname . ',')); + } + + public function getConditionsInstance() + { + return $this->objectManager->create('Astound\Affirm\Model\Rule\Condition\Combine'); + } + + public function getActionsInstance() + { + return $this->objectManager->create('Magento\SalesRule\Model\Rule\Condition\Product\Combine'); + } + + public function massChangeStatus($ids, $status) + { + return $this->getResource()->massChangeStatus($ids, $status); + } + + public function afterSave() + { + //Saving attributes used in rule + $ruleProductAttributes = array_merge( + $this->_getUsedAttributes($this->getConditionsSerialized()), + $this->_getUsedAttributes($this->getActionsSerialized()) + ); + if (count($ruleProductAttributes)) { + $this->getResource()->saveAttributes($this->getId(), $ruleProductAttributes); + } + + return parent::afterSave(); + } + + protected function _getUsedAttributes($serializedString) + { + $result = []; + $pattern = '~s:46:"Magento\\\SalesRule\\\Model\\\Rule\\\Condition\\\Product";s:9:"attribute";s:\d+:"(.*?)"~s'; + $matches = []; + if (preg_match_all($pattern, $serializedString, $matches)) { + foreach ($matches[1] as $attributeCode) { + $result[] = $attributeCode; + } + } + + return $result; + } +} diff --git a/Model/Rule/Condition/Address.php b/Model/Rule/Condition/Address.php index a13a07c9..ef077e90 100755 --- a/Model/Rule/Condition/Address.php +++ b/Model/Rule/Condition/Address.php @@ -1,192 +1,192 @@ -_directoryCountry = $directoryCountry; - $this->_directoryAllregion = $directoryAllregion; - } - - public function loadAttributeOptions() - { - parent::loadAttributeOptions(); - - $attributes = $this->getAttributeOption(); - unset($attributes['payment_method']); - $attributes['base_subtotal'] = __('Subtotal'); - $attributes['total_qty'] = __('Total Items Quantity'); - $attributes['weight'] = __('Total Weight'); - $attributes['shipping_method'] = __('Shipping Method'); - $attributes['postcode'] = __('Shipping Postcode'); - $attributes['region'] = __('Shipping Region'); - $attributes['region_id'] = __('Shipping State/Province'); - $attributes['country_id'] = __('Shipping Country'); - $attributes['street'] = __('Address Line'); - $attributes['city'] = __('City'); - - $this->setAttributeOption($attributes); - - return $this; - } - - public function getAttributeElement() - { - $element = parent::getAttributeElement(); - $element->setShowAsText(true); - return $element; - } - - public function getInputType() - { - switch ($this->getAttribute()) { - case 'base_subtotal': - case 'weight': - case 'total_qty': - return 'numeric'; - - case 'country_id': - case 'region_id': - return 'select'; - } - return 'string'; - } - - public function getValueElementType() - { - switch ($this->getAttribute()) { - case 'country_id': - case 'region_id': - return 'select'; - } - return 'text'; - } - - public function getOperatorSelectOptions() - { - $operators = $this->getOperatorOption(); - if ($this->getAttribute() == 'street') { - $operators = array( - '{}' => __('contains'), - '!{}' => __('does not contain'), - '{%' => __('starts from'), - '%}' => __('ends with'), - ); - } - - $type = $this->getInputType(); - $opt = array(); - $operatorByType = $this->getOperatorByInputType(); - foreach ($operators as $k => $v) { - if (!$operatorByType || in_array($k, $operatorByType[$type])) { - $opt[] = array('value' => $k, 'label' => $v); - } - } - return $opt; - } - - public function getValueSelectOptions() - { - if (!$this->hasData('value_select_options')) { - switch ($this->getAttribute()) { - case 'country_id': - $options = $this->_directoryCountry->toOptionArray(); - break; - - case 'region_id': - $options = $this->_directoryAllregion->toOptionArray(); - break; - - default: - $options = array(); - } - $this->setData('value_select_options', $options); - } - return $this->getData('value_select_options'); - } - - public function getDefaultOperatorInputByType() - { - $op = parent::getDefaultOperatorInputByType(); - $op['string'][] = '{%'; - $op['string'][] = '%}'; - return $op; - } - - public function getDefaultOperatorOptions() - { - $op = parent::getDefaultOperatorOptions(); - $op['{%'] = __('starts from'); - $op['%}'] = __('ends with'); - - return $op; - } - - public function validateAttribute($validatedValue) - { - if (is_object($validatedValue)) { - return false; - } - - /** - * Condition attribute value - */ - $value = $this->getValueParsed(); - - /** - * Comparison operator - */ - $op = $this->getOperatorForValidate(); - - // if operator requires array and it is not, or on opposite, return false - if ($this->isArrayOperatorType() xor is_array($value)) { - return false; - } - - $result = false; - switch ($op) { - case '{%': - if (!is_scalar($validatedValue)) { - return false; - } else { - $result = substr($validatedValue, 0, strlen($value)) == $value; - } - break; - case '%}': - if (!is_scalar($validatedValue)) { - return false; - } else { - $result = substr($validatedValue, -strlen($value)) == $value; - } - break; - default: - return parent::validateAttribute($validatedValue); - break; - } - return $result; - } - - protected function _isArrayOperatorType() - { - $ret = false; - if (method_exists($this, 'isArrayOperatorType')) { - $ret = $this->isArrayOperatorType(); - } else { - $op = $this->getOperator(); - $ret = ($op === '()' || $op === '!()'); - } - - return $ret; - } -} \ No newline at end of file +_directoryCountry = $directoryCountry; + $this->_directoryAllregion = $directoryAllregion; + } + + public function loadAttributeOptions() + { + parent::loadAttributeOptions(); + + $attributes = $this->getAttributeOption(); + unset($attributes['payment_method']); + $attributes['base_subtotal'] = __('Subtotal'); + $attributes['total_qty'] = __('Total Items Quantity'); + $attributes['weight'] = __('Total Weight'); + $attributes['shipping_method'] = __('Shipping Method'); + $attributes['postcode'] = __('Shipping Postcode'); + $attributes['region'] = __('Shipping Region'); + $attributes['region_id'] = __('Shipping State/Province'); + $attributes['country_id'] = __('Shipping Country'); + $attributes['street'] = __('Address Line'); + $attributes['city'] = __('City'); + + $this->setAttributeOption($attributes); + + return $this; + } + + public function getAttributeElement() + { + $element = parent::getAttributeElement(); + $element->setShowAsText(true); + return $element; + } + + public function getInputType() + { + switch ($this->getAttribute()) { + case 'base_subtotal': + case 'weight': + case 'total_qty': + return 'numeric'; + + case 'country_id': + case 'region_id': + return 'select'; + } + return 'string'; + } + + public function getValueElementType() + { + switch ($this->getAttribute()) { + case 'country_id': + case 'region_id': + return 'select'; + } + return 'text'; + } + + public function getOperatorSelectOptions() + { + $operators = $this->getOperatorOption(); + if ($this->getAttribute() == 'street') { + $operators = [ + '{}' => __('contains'), + '!{}' => __('does not contain'), + '{%' => __('starts from'), + '%}' => __('ends with'), + ]; + } + + $type = $this->getInputType(); + $opt = []; + $operatorByType = $this->getOperatorByInputType(); + foreach ($operators as $k => $v) { + if (!$operatorByType || in_array($k, $operatorByType[$type])) { + $opt[] = ['value' => $k, 'label' => $v]; + } + } + return $opt; + } + + public function getValueSelectOptions() + { + if (!$this->hasData('value_select_options')) { + switch ($this->getAttribute()) { + case 'country_id': + $options = $this->_directoryCountry->toOptionArray(); + break; + + case 'region_id': + $options = $this->_directoryAllregion->toOptionArray(); + break; + + default: + $options = []; + } + $this->setData('value_select_options', $options); + } + return $this->getData('value_select_options'); + } + + public function getDefaultOperatorInputByType() + { + $op = parent::getDefaultOperatorInputByType(); + $op['string'][] = '{%'; + $op['string'][] = '%}'; + return $op; + } + + public function getDefaultOperatorOptions() + { + $op = parent::getDefaultOperatorOptions(); + $op['{%'] = __('starts from'); + $op['%}'] = __('ends with'); + + return $op; + } + + public function validateAttribute($validatedValue) + { + if (is_object($validatedValue)) { + return false; + } + + /** + * Condition attribute value + */ + $value = $this->getValueParsed(); + + /** + * Comparison operator + */ + $op = $this->getOperatorForValidate(); + + // if operator requires array and it is not, or on opposite, return false + if ($this->isArrayOperatorType() xor is_array($value)) { + return false; + } + + $result = false; + switch ($op) { + case '{%': + if (!is_scalar($validatedValue)) { + return false; + } else { + $result = substr($validatedValue, 0, strlen($value)) == $value; + } + break; + case '%}': + if (!is_scalar($validatedValue)) { + return false; + } else { + $result = substr($validatedValue, -strlen($value)) == $value; + } + break; + default: + return parent::validateAttribute($validatedValue); + break; + } + return $result; + } + + protected function _isArrayOperatorType() + { + $ret = false; + if (method_exists($this, 'isArrayOperatorType')) { + $ret = $this->isArrayOperatorType(); + } else { + $op = $this->getOperator(); + $ret = ($op === '()' || $op === '!()'); + } + + return $ret; + } +} diff --git a/Model/Rule/Condition/Combine.php b/Model/Rule/Condition/Combine.php index 05aad6b9..edca152c 100755 --- a/Model/Rule/Condition/Combine.php +++ b/Model/Rule/Condition/Combine.php @@ -1,83 +1,82 @@ -objectManager = $objectManager; - $this->_eventManager = $eventManager; - $this->setType('Astound\Affirm\Model\Rule\Condition\Combine'); - } - - public function getNewChildSelectOptions() - { - $addressCondition = $this->objectManager->create('Astound\Affirm\Model\Rule\Condition\Address'); - $addressAttributes = $addressCondition->loadAttributeOptions()->getAttributeOption(); - - $attributes = array(); - foreach ($addressAttributes as $code=>$label) { - $attributes[] = array('value'=>'Astound\Affirm\Model\Rule\Condition\Address|'.$code, 'label'=>$label); - } - - $conditions = parent::getNewChildSelectOptions(); - $conditions = array_merge_recursive($conditions, array( - array('value' => 'Magento\SalesRule\Model\Rule\Condition\Product\Found', 'label'=>__('Product attribute combination')), - array('value' => 'Astound\Affirm\Model\Rule\Condition\Product\Subselect', 'label'=>__('Products subselection')), - array('label' => __('Conditions combination'), 'value' => $this->getType()), - array('label' => __('Cart Attribute'), 'value' => $attributes), - )); - - $additional = new \Magento\Framework\DataObject(); - $this->_eventManager->dispatch('salesrule_rule_condition_combine', ['additional' => $additional]); - $additionalConditions = $additional->getConditions(); - if ($additionalConditions) { - $conditions = array_merge_recursive($conditions, $additionalConditions); - } - - return $conditions; - } - - public function validateNotModel($entity) - { - if (!$this->getConditions()) { - return true; - } - - $all = $this->getAggregator() === 'all'; - $true = (bool)$this->getValue(); - - foreach ($this->getConditions() as $cond) { - if ($entity instanceof \Magento\Framework\Model\AbstractModel) { - $validated = $cond->validate($entity); - } elseif ($entity instanceof \Magento\Framework\DataObject - && method_exists($cond, 'validateNotModel') - ) { - $validated = $cond->validateNotModel($entity); - } elseif ($entity instanceof \Magento\Framework\DataObject) { - $attribute = $entity->getData($cond->getAttribute()); - $validated = $cond->validateAttribute($attribute); - } else { - $validated = $cond->validateByEntityId($entity); - } - if ($all && $validated !== $true) { - return false; - } elseif (!$all && $validated === $true) { - return true; - } - } - return $all ? true : false; - } - -} +use Magento\Rule\Model\Condition\Context; + +class Combine extends \Magento\Rule\Model\Condition\Combine +{ + protected $objectManager; + + protected $_eventManager = null; + + public function __construct( + Context $context, + \Magento\Framework\ObjectManagerInterface $objectManager, + \Magento\Framework\Event\ManagerInterface $eventManager, + array $data = [] + ) { + parent::__construct($context, $data); + $this->objectManager = $objectManager; + $this->_eventManager = $eventManager; + $this->setType('Astound\Affirm\Model\Rule\Condition\Combine'); + } + + public function getNewChildSelectOptions() + { + $addressCondition = $this->objectManager->create('Astound\Affirm\Model\Rule\Condition\Address'); + $addressAttributes = $addressCondition->loadAttributeOptions()->getAttributeOption(); + + $attributes = []; + foreach ($addressAttributes as $code => $label) { + $attributes[] = ['value'=>'Astound\Affirm\Model\Rule\Condition\Address|'.$code, 'label'=>$label]; + } + + $conditions = parent::getNewChildSelectOptions(); + $conditions = array_merge_recursive($conditions, [ + ['value' => 'Magento\SalesRule\Model\Rule\Condition\Product\Found', 'label'=>__('Product attribute combination')], + ['value' => 'Astound\Affirm\Model\Rule\Condition\Product\Subselect', 'label'=>__('Products subselection')], + ['label' => __('Conditions combination'), 'value' => $this->getType()], + ['label' => __('Cart Attribute'), 'value' => $attributes], + ]); + + $additional = new \Magento\Framework\DataObject(); + $this->_eventManager->dispatch('salesrule_rule_condition_combine', ['additional' => $additional]); + $additionalConditions = $additional->getConditions(); + if ($additionalConditions) { + $conditions = array_merge_recursive($conditions, $additionalConditions); + } + + return $conditions; + } + + public function validateNotModel($entity) + { + if (!$this->getConditions()) { + return true; + } + + $all = $this->getAggregator() === 'all'; + $true = (bool)$this->getValue(); + + foreach ($this->getConditions() as $cond) { + if ($entity instanceof \Magento\Framework\Model\AbstractModel) { + $validated = $cond->validate($entity); + } elseif ($entity instanceof \Magento\Framework\DataObject + && method_exists($cond, 'validateNotModel') + ) { + $validated = $cond->validateNotModel($entity); + } elseif ($entity instanceof \Magento\Framework\DataObject) { + $attribute = $entity->getData($cond->getAttribute()); + $validated = $cond->validateAttribute($attribute); + } else { + $validated = $cond->validateByEntityId($entity); + } + if ($all && $validated !== $true) { + return false; + } elseif (!$all && $validated === $true) { + return true; + } + } + return $all ? true : false; + } +} diff --git a/Model/Rule/Condition/Product/Subselect.php b/Model/Rule/Condition/Product/Subselect.php index a0ce0404..fa3d8ccc 100755 --- a/Model/Rule/Condition/Product/Subselect.php +++ b/Model/Rule/Condition/Product/Subselect.php @@ -1,79 +1,79 @@ -setType('Astound\Affirm\Model\Rule\Condition\Product\Subselect') - ->setValue(null); - } - - public function loadAttributeOptions() - { - $this->setAttributeOption(array( - 'qty' => __('total quantity'), - 'base_row_total' => __('total amount excl. tax'), - 'base_row_total_incl_tax' => __('total amount incl. tax'), - 'row_weight' => __('total weight'), - )); - return $this; - } - - /** - * validate - * - * @param Varien_Object $object Quote - * @return boolean - */ - public function validate(\Magento\Framework\Model\AbstractModel $object) - { - return $this->validateNotModel($object); - } - - public function validateNotModel($object) - { - $attr = $this->getAttribute(); - $total = 0; - if ($object->getAllItems()) { - $validIds = array(); - foreach ($object->getAllItems() as $item) { - - - if ($item->getProduct()->getTypeId() == 'configurable') { - $item->getProduct()->setTypeId('skip'); - } - - //can't use parent here - if (\Magento\SalesRule\Model\Rule\Condition\Product\Combine::validate( - $item - ) - ) { - $itemParentId = $item->getParentItemId(); - if (is_null($itemParentId)) { - $validIds[] = $item->getItemId(); - } else { - if (in_array($itemParentId, $validIds)) { - continue; - } else { - $validIds[] = $itemParentId; - } - } - - - $total += $item->getData($attr); - } - - if ($item->getProduct()->getTypeId() === 'skip') { - $item->getProduct()->setTypeId('configurable'); - } - } - } - - return $this->validateAttribute($total); - } -} \ No newline at end of file +setType('Astound\Affirm\Model\Rule\Condition\Product\Subselect') + ->setValue(null); + } + + public function loadAttributeOptions() + { + $this->setAttributeOption([ + 'qty' => __('total quantity'), + 'base_row_total' => __('total amount excl. tax'), + 'base_row_total_incl_tax' => __('total amount incl. tax'), + 'row_weight' => __('total weight'), + ]); + return $this; + } + + /** + * validate + * + * @param Varien_Object $object Quote + * @return boolean + */ + public function validate(\Magento\Framework\Model\AbstractModel $object) + { + return $this->validateNotModel($object); + } + + public function validateNotModel($object) + { + $attr = $this->getAttribute(); + $total = 0; + if ($object->getAllItems()) { + $validIds = []; + foreach ($object->getAllItems() as $item) { + + + if ($item->getProduct()->getTypeId() == 'configurable') { + $item->getProduct()->setTypeId('skip'); + } + + //can't use parent here + if (\Magento\SalesRule\Model\Rule\Condition\Product\Combine::validate( + $item + ) + ) { + $itemParentId = $item->getParentItemId(); + if (is_null($itemParentId)) { + $validIds[] = $item->getItemId(); + } else { + if (in_array($itemParentId, $validIds)) { + continue; + } else { + $validIds[] = $itemParentId; + } + } + + + $total += $item->getData($attr); + } + + if ($item->getProduct()->getTypeId() === 'skip') { + $item->getProduct()->setTypeId('configurable'); + } + } + } + + return $this->validateAttribute($total); + } +} diff --git a/Plugin/ProductAttributes.php b/Plugin/ProductAttributes.php index d2a6b3e9..1453f961 100755 --- a/Plugin/ProductAttributes.php +++ b/Plugin/ProductAttributes.php @@ -1,28 +1,26 @@ -objectManager = $objectManager; - } - - public function aroundGetProductAttributes(\Magento\Quote\Model\Quote\Config $subject, \Closure $closure) - { - $attributesTransfer = $closure(); - - $attributes = $this->objectManager->create('Astound\Affirm\Model\ResourceModel\Rule')->getAttributes(); - - foreach ($attributes as $code) { - $attributesTransfer[] = $code; - } - - return $attributesTransfer; - - } -} \ No newline at end of file +objectManager = $objectManager; + } + + public function aroundGetProductAttributes(\Magento\Quote\Model\Quote\Config $subject, \Closure $closure) + { + $attributesTransfer = $closure(); + + $attributes = $this->objectManager->create('Astound\Affirm\Model\ResourceModel\Rule')->getAttributes(); + + foreach ($attributes as $code) { + $attributesTransfer[] = $code; + } + + return $attributesTransfer; + } +} diff --git a/Plugin/RestrictPaymentMethods.php b/Plugin/RestrictPaymentMethods.php index 3573ed1e..3a99cc0f 100755 --- a/Plugin/RestrictPaymentMethods.php +++ b/Plugin/RestrictPaymentMethods.php @@ -1,53 +1,51 @@ -objectManager = $objectManager; - } - - public function afterGetActiveList(\Magento\Payment\Model\PaymentMethodList $subject, $result) - { - $methods = $result; - - $om = \Magento\Framework\App\ObjectManager::getInstance(); - $checkoutsession = $om->get('Magento\Checkout\Model\Session'); - $quote = $checkoutsession->getQuote(); - - $address = $quote->getShippingAddress(); - foreach ($methods as $k => $method) { - foreach ($this->getRules($address) as $rule) { - if ($rule->restrict($method)) { - if ($rule->validate($address)) { - unset($methods[$k]); - } - } - } - } - - return $methods; - - } - - public function getRules($address) - { - if (is_null($this->_allRules)) { - $om = \Magento\Framework\App\ObjectManager::getInstance(); - $hlp = $om->create('Astound\Affirm\Model\Rule'); - $this->_allRules = $hlp->getCollection()->addAddressFilter($address)->load(); - foreach ($this->_allRules as $rule) { - $rule->afterLoad(); - } - } - - return $this->_allRules; - } -} \ No newline at end of file +objectManager = $objectManager; + } + + public function afterGetActiveList(\Magento\Payment\Model\PaymentMethodList $subject, $result) + { + $methods = $result; + + $om = \Magento\Framework\App\ObjectManager::getInstance(); + $checkoutsession = $om->get('Magento\Checkout\Model\Session'); + $quote = $checkoutsession->getQuote(); + + $address = $quote->getShippingAddress(); + foreach ($methods as $k => $method) { + foreach ($this->getRules($address) as $rule) { + if ($rule->restrict($method)) { + if ($rule->validate($address)) { + unset($methods[$k]); + } + } + } + } + + return $methods; + } + + public function getRules($address) + { + if (is_null($this->_allRules)) { + $om = \Magento\Framework\App\ObjectManager::getInstance(); + $hlp = $om->create('Astound\Affirm\Model\Rule'); + $this->_allRules = $hlp->getCollection()->addAddressFilter($address)->load(); + foreach ($this->_allRules as $rule) { + $rule->afterLoad(); + } + } + + return $this->_allRules; + } +} diff --git a/Plugin/SaveInvoiceAmountToCapture.php b/Plugin/SaveInvoiceAmountToCapture.php index 8d1e2910..04e65761 100644 --- a/Plugin/SaveInvoiceAmountToCapture.php +++ b/Plugin/SaveInvoiceAmountToCapture.php @@ -1,6 +1,7 @@ getPayment()->getMethod(); if ($paymentMethod === 'affirm_gateway') { - if(array_key_exists( 'checkout_token' , $paymentData['affirm'] )) { + if (array_key_exists('checkout_token', $paymentData['affirm'])) { $payment = $cart->getPayment(); $token = $paymentData['affirm']['checkout_token']; $payment->setAdditionalInformation('checkout_token', $token); @@ -45,4 +43,3 @@ public function afterExecute( } } } - diff --git a/Setup/Patch/Data/AddProductCategoryAttributes.php b/Setup/Patch/Data/AddProductCategoryAttributes.php index b5252306..28826a3f 100644 --- a/Setup/Patch/Data/AddProductCategoryAttributes.php +++ b/Setup/Patch/Data/AddProductCategoryAttributes.php @@ -14,8 +14,8 @@ use Magento\Catalog\Setup\CategorySetupFactory; /** -* Patch is mechanism, that allows to do atomic upgrade data changes -*/ + * Patch is mechanism, that allows to do atomic upgrade data changes + */ class AddProductCategoryAttributes implements DataPatchInterface, PatchRevertableInterface @@ -352,17 +352,17 @@ public function revert() $eavSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]); $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_type'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_priority'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_type'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_priority'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_start_date'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_end_date'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_start_date'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_end_date'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_promo_id'); - $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_promo_id'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_type'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_priority'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_type'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_priority'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_start_date'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_mfp_end_date'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_start_date'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_mfp_end_date'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'affirm_category_promo_id'); + $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'affirm_product_promo_id'); $this->moduleDataSetup->getConnection()->endSetup(); } diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index e8b3eae0..aba1274a 100755 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -1,6 +1,6 @@ - - - - - - \ No newline at end of file + + + + + + diff --git a/view/adminhtml/layout/affirm_rule_edit.xml b/view/adminhtml/layout/affirm_rule_edit.xml index 145544db..bbb43485 100755 --- a/view/adminhtml/layout/affirm_rule_edit.xml +++ b/view/adminhtml/layout/affirm_rule_edit.xml @@ -1,30 +1,30 @@ - - - - - - - - - - astound_affirm_rule_edit_tabs - edit_form - Payment Restrictions Options - - - - - general - astound_affirm_rule_edit_tab_general - - - conditions - astound_affirm_rule_edit_tab_conditions - - - - - - - - \ No newline at end of file + + + + + + + + + + astound_affirm_rule_edit_tabs + edit_form + Payment Restrictions Options + + + + + general + astound_affirm_rule_edit_tab_general + + + conditions + astound_affirm_rule_edit_tab_conditions + + + + + + + + diff --git a/view/adminhtml/layout/affirm_rule_index.xml b/view/adminhtml/layout/affirm_rule_index.xml index cdc8e8f2..a107f7b1 100755 --- a/view/adminhtml/layout/affirm_rule_index.xml +++ b/view/adminhtml/layout/affirm_rule_index.xml @@ -1,133 +1,133 @@ - - - - - - - astound_affirm_rule_grid - Astound\Affirm\Model\ResourceModel\Rule\Collection - pos - ASC - 1 - - - - rule_id - rules - 1 - - - Activate - - 1 - activate - - - - Inactivate - - 1 - inactivate - - - - Delete - - 1 - delete - - Are you sure? - - - - - - - - */*/edit - - getId - - - - - - ID - rule_id - col-id - col-id - - - - - Name - name - - - - - Methods - methods - Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Methods - - - - - - Customer Groups - cust_groups - Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Groups - - - - - - Store Views - stores - Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Stores - - - - - - Status - is_active - options - Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Color - - - 0 - Inactive - - - 1 - Active - - - - - - - - Action - action - 0 - 0 - 1 - getId - - - Duplicate - - */*/duplicate - - rule_id - - - - - - - - - + + + + + + + astound_affirm_rule_grid + Astound\Affirm\Model\ResourceModel\Rule\Collection + pos + ASC + 1 + + + + rule_id + rules + 1 + + + Activate + + 1 + activate + + + + Inactivate + + 1 + inactivate + + + + Delete + + 1 + delete + + Are you sure? + + + + + + + + */*/edit + + getId + + + + + + ID + rule_id + col-id + col-id + + + + + Name + name + + + + + Methods + methods + Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Methods + + + + + + Customer Groups + cust_groups + Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Groups + + + + + + Store Views + stores + Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Stores + + + + + + Status + is_active + options + Astound\Affirm\Block\Adminhtml\Rule\Grid\Renderer\Color + + + 0 + Inactive + + + 1 + Active + + + + + + + + Action + action + 0 + 0 + 1 + getId + + + Duplicate + + */*/duplicate + + rule_id + + + + + + + + + diff --git a/view/adminhtml/templates/affirm/error.phtml b/view/adminhtml/templates/affirm/error.phtml index 4f8a9bd9..0c83bb4c 100644 --- a/view/adminhtml/templates/affirm/error.phtml +++ b/view/adminhtml/templates/affirm/error.phtml @@ -7,8 +7,9 @@ ?>

getVirtualUrl() . ">Affirm's Virtual Terminal + 'Affirm is not available as a payment method in Magento at this time. + Instead you may use %1', + "Affirm's Virtual Terminal to process payment." ); ?> diff --git a/view/frontend/templates/pixel/confirm.phtml b/view/frontend/templates/pixel/confirm.phtml index db9d4d7b..fe85d69e 100644 --- a/view/frontend/templates/pixel/confirm.phtml +++ b/view/frontend/templates/pixel/confirm.phtml @@ -35,14 +35,14 @@ ?> getRequest()->getFullActionName(); +$action = $block->getRequest()->getFullActionName(); if ($action == 'checkout_onepage_success') { - $pixelCode = $this->getOrdersTrackingCode(); + $pixelCode = $block->getOrdersTrackingCode(); $pixelCode['pixelConfig'] = $block->getOptions(); - $serializedPixelCode = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($pixelCode); + $serializedPixelCode = $block->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($pixelCode); } ?> diff --git a/view/frontend/templates/promotion/bml.phtml b/view/frontend/templates/promotion/bml.phtml index 96f86353..12461d3d 100644 --- a/view/frontend/templates/promotion/bml.phtml +++ b/view/frontend/templates/promotion/bml.phtml @@ -35,13 +35,13 @@ ?> getMFPValue(); - $size = str_replace("--",'',$block->getSize()); - list($width, $height) = explode('x',$size); + $size = str_replace("--", '', $block->getSize()); + list($width, $height) = explode('x', $size); $affirmAssetsUrl = $block->getAffirmAssetsUrl(); $options = $block->getOptions(); $pageType = $block->getPageType(); ?> -getStartContainerTag(); ?> +getStartContainerTag(); ?> @@ -49,4 +49,4 @@ '; ?> -getEndContainerTag(); ?> +getEndContainerTag(); ?>