Example #1
0
 /**
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     if ($this->getRequest()->getParam('website') != '') {
         $priceScope = $this->_scopeConfig->getValue(\Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         if ($priceScope == \Magento\Store\Model\Store::PRICE_SCOPE_GLOBAL) {
             return '';
         }
     }
     return parent::render($element);
 }
Example #2
0
 public function testRenderInheritCheckbox()
 {
     $this->_elementMock->expects($this->any())->method('getInherit')->will($this->returnValue(true));
     $this->_elementMock->expects($this->any())->method('getCanUseWebsiteValue')->will($this->returnValue(true));
     $this->_elementMock->expects($this->any())->method('getCanUseDefaultValue')->will($this->returnValue(true));
     $this->_elementMock->expects($this->once())->method('setDisabled')->with(true);
     $expected = '<td class="use-default">';
     $expected .= '<input id="' . $this->_testData['htmlId'] . '_inherit" name="' . $this->_testData['name'] . '[inherit]" type="checkbox" value="1"' . ' class="checkbox config-inherit" checked="checked"' . ' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> ';
     $expected .= '<label for="' . $this->_testData['htmlId'] . '_inherit" class="inherit">Use Website</label>';
     $actual = $this->_object->render($this->_elementMock);
     $this->assertContains($expected, $actual);
 }
Example #3
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $html = parent::_getElementHtml($element);
     $js = '<script type="text/javascript">
            var updater = new RegionUpdater("tax_defaults_country", "none", "tax_defaults_region", %s, "nullify");
            if(updater.lastCountryId) {
                var tmpRegionId = $("tax_defaults_region").value;
                var tmpCountryId = updater.lastCountryId;
                updater.lastCountryId=false;
                updater.update();
                updater.lastCountryId = tmpCountryId;
                $("tax_defaults_region").value = tmpRegionId;
            } else {
                updater.update();
            }
            </script>';
     $html .= sprintf($js, $this->_directoryHelper->getRegionJson());
     return $html;
 }
Example #4
0
 /**
  * Render block HTML
  *
  * @return string
  * @throws \Exception
  */
 protected function _toHtml()
 {
     if (!$this->_isPreparedToRender) {
         $this->_prepareToRender();
         $this->_isPreparedToRender = true;
     }
     if (empty($this->_columns)) {
         throw new \Exception('At least one column must be defined.');
     }
     return parent::_toHtml();
 }
Example #5
0
 /**
  * Render button
  *
  * @param  \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     // Remove scope label
     $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
     return parent::render($element);
 }
Example #6
0
 /**
  * Retrieve Element HTML fragment
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     return parent::_getElementHtml($element) . $this->_toHtml();
 }
Example #7
0
 /**
  * @param AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(AbstractElement $element)
 {
     $html = parent::_getElementHtml($element);
     $html .= "<script type=\"text/javascript\">var updater = new RegionUpdater('tax_defaults_country'," . " 'tax_region', 'tax_defaults_region', " . $this->_directoryHelper->getRegionJson() . ", 'disable');</script>";
     return $html;
 }
Example #8
0
 /**
  * Get country selector html
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return string
  */
 protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
     $urlParams = ['section' => $this->getRequest()->getParam('section'), 'website' => $this->getRequest()->getParam('website'), 'store' => $this->getRequest()->getParam('store'), StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__'];
     $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams));
     $jsString = '
         $("' . $element->getHtmlId() . '").observe("change", function () {
             location.href = \'' . $urlString . '\'.replace("__country__", this.value);
         });
     ';
     if ($this->_defaultCountry) {
         $urlParams[self::REQUEST_PARAM_DEFAULT_COUNTRY] = '__default__';
         $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams));
         $jsParentCountry = $this->_escaper->escapeJsQuote($this->_defaultCountry);
         $jsString .= '
             $("' . $element->getHtmlId() . '_inherit").observe("click", function () {
                 if (this.checked) {
                     location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\')
                         .replace("__default__", "1");
                 }
             });
         ';
     }
     return parent::_getElementHtml($element) . $this->_jsHelper->getScript('document.observe("dom:loaded", function() {' . $jsString . '});');
 }