Hello, i need help with magento 2.
i am developing a module in magento 2.2.2.
http://docs.magento.com/m2/ee/user_guide/shipping/shipping-flat-rate.html
in my module i need modify values of shipping-flat-rate.
eg: title, price.
how get and update values of shipping-flat-rate since my module.
thank you.
Solved! Go to Solution.
<?php
namespace Proveedor\Gnuxdar\Block\Adminhtml\Filter\Edit\Tab;
use Magento\Backend\Block\Widget\Form\Generic;
...
class Info extends Generic implements TabInterface
{
protected $_scopeConfigInterface;
...
public function __construct(
...
)
{
parent::__construct($context, $registry, $formFactory, $data);
$this->_scopeConfigInterface = $scopeConfigInterface;
$this->_countryCollectionFactory = $countryCollectionFactory;
}
protected function _prepareForm()
{
$path = 'carriers/flatrate/';
$country = $this->_scopeConfigInterface->getValue($path.'specificcountry', \Magento\Store\Model\ScopeInterface:COPE_STORE);
$form = $this->_formFactory->create(['data'=>['id'=>'edit_form', 'action'=>$this->....
$fieldset->addField(
'enabled',
'select',
[
'name'=>'enabled',
'label'=>__('Enabled'),
'required'=>true,
'values'=>array(0=>'No', 1=>'Yes'),
'value'=>$this->_scopeConfigInterface->getValue($path.'active', \Magento\Store\Model\ScopeInterface:COPE_STORE)
]
);
for more info, my https://www.twitter.com/gnuxdar
Hi there,
We’d recommend creating a separate proprietary/own shipping method based on Magento\OfflineShipping\Model\Carrier\Flatrate, and rewrite getShippingPrice() method in it. Enter your conditions with the calculations there.
---------------------------------------------------------
If you've found one of our answers useful, please give 'Kudos' or 'Accept as Solution'.
<?php
namespace Proveedor\Gnuxdar\Block\Adminhtml\Filter\Edit\Tab;
use Magento\Backend\Block\Widget\Form\Generic;
...
class Info extends Generic implements TabInterface
{
protected $_scopeConfigInterface;
...
public function __construct(
...
)
{
parent::__construct($context, $registry, $formFactory, $data);
$this->_scopeConfigInterface = $scopeConfigInterface;
$this->_countryCollectionFactory = $countryCollectionFactory;
}
protected function _prepareForm()
{
$path = 'carriers/flatrate/';
$country = $this->_scopeConfigInterface->getValue($path.'specificcountry', \Magento\Store\Model\ScopeInterface:COPE_STORE);
$form = $this->_formFactory->create(['data'=>['id'=>'edit_form', 'action'=>$this->....
$fieldset->addField(
'enabled',
'select',
[
'name'=>'enabled',
'label'=>__('Enabled'),
'required'=>true,
'values'=>array(0=>'No', 1=>'Yes'),
'value'=>$this->_scopeConfigInterface->getValue($path.'active', \Magento\Store\Model\ScopeInterface:COPE_STORE)
]
);
for more info, my https://www.twitter.com/gnuxdar