I am making a magento 2 module, and I had to create a custom shipping method but I am not able to get the data of fields in the checkout page :
This is a part of my system.xml file
<section id="carriers" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="my_shipping_methode" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="myfield" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
and this is the constructor of my module :
<?php namespace A\B\Model\Carrier;
use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Shipping\Model\Rate\Result;
class Shipping extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
\Magento\Shipping\Model\Carrier\CarrierInterface
{
/**
* @var string
*/
protected $_code = 'my_shipping_methode';
/**
* @var string
*/
protected $myfield = 'test';
And this is part of my javascript file I call in the checkout to get the code of the shipping method :
this.selectedMethod = ko.computed(function() {
var method = quote.shippingMethod();
var selectedMethod = method != null ? method.method_code : null;
I tried to do the same for my field but it didn't work
var myfield = method != null ? method.method_myfield : null;
Please help I am lost