cancel
Showing results for 
Search instead for 
Did you mean: 

How to get information of a field from a magento module?

How to get information of a field from a magento module?

I am developing a shipping restriction plugin for magento 2, looking at the documentation I found the detailed information of the initial creation process. One of the validations I need is:

Depending on the name of the store, enable or disable a type of delivery, in the red box I show the select that allows choosing the name of the store.

 

From my php code I want to be able to obtain that value to activate or deactivate the send method. The following is the base code of the module that I am developing, I would like to obtain the name of the store chosen in this field to activate or deactivate a shipping type.

292ix
```
public function collectRates(RateRequest $request) {
if (!$this->isActive())
{
return false;
}
$result = $this->_rateResultFactory->create();
$shippingPrice = $this->getConfigData('price');
$method = $this->_rateMethodFactory->create();
$method->setCarrier($this->getCarrierCode());
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod($this->getCarrierCode());
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
return $result;
}
```
I am currently using this code to get the address, but I am not very clear how to use it to obtain the value of the select that loads the stores
```
$object_manager = \Magento\Framework\App\ObjectManager::getInstance();

$get_cart = $object_manager->get('\Magento\Checkout\Model\Cart');

$getAdress = $get_cart->getQuote()->getShippingAddress();

$distance = $getAdress->getData('street');
```