Magento2 Shipping City For Shipping Amount CaluculationsUnit Test for overwrite collection class in magento2Price not getting updated for second product…Magento 2.1.6 Cannot save shipmentmagento Plugin is not working on CollectRates method shipping method classMagento offline custom Payment method with drop down listMonolog Error After 2.2 UpgradeHow to solve Front controller reached 100 router match iterations in magento2Add configure product in Cart using Magento 2 API facing an issueMagento 2.3 Can't view module's front end page output?when click on place order then paypal showing error in Magento2

How can Internet speed be 10 times slower without a router than when using the same connection with a router?

What to use instead of cling film to wrap pastry

Why do people keep telling me that I am a bad photographer?

Why does sound not move through a wall?

Is there precedent or are there procedures for a US president refusing to concede to an electoral defeat?

How in the world do I place line of text EVENLY between two horizontal tikz lines?

All of my Firefox add-ons been disabled suddenly, how can I re-enable them?

To kill a cuckoo

Should I simplify my writing in a foreign country?

Correct way of drawing empty, half-filled and fully filled circles?

Does XQuartz work on macOS Mojave?

What was Bran's plan to kill the Night King?

Is there a word for food that's gone 'bad', but is still edible?

Does "Captain Marvel" contain spoilers for "Avengers: Infinity War"?

Which US defense organization would respond to an invasion like this?

Hostile Divisor Numbers

Where to draw the line between quantum mechanics theory and its interpretation(s)?

Are there terms in German for different skull shapes?

Would a life form with the intelligence of a human but without an appendage for manipulating its environment be able to have advanced technology?

Is disk brake effectiveness mitigated by tyres losing traction under strong braking?

Has the Hulk always been able to talk?

SOQL query WHERE filter by specific months

How to pass hash as password to ssh server

Would a small hole in a Faraday cage drastically reduce its effectiveness at blocking interference?



Magento2 Shipping City For Shipping Amount Caluculations


Unit Test for overwrite collection class in magento2Price not getting updated for second product…Magento 2.1.6 Cannot save shipmentmagento Plugin is not working on CollectRates method shipping method classMagento offline custom Payment method with drop down listMonolog Error After 2.2 UpgradeHow to solve Front controller reached 100 router match iterations in magento2Add configure product in Cart using Magento 2 API facing an issueMagento 2.3 Can't view module's front end page output?when click on place order then paypal showing error in Magento2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I need to apply table rate shipping based on following conditions




City to City



Metro to City



Metro to Metro



City to Other



City to Special Locations




I written my own module but i am getting only the postal code and country id in $request



Array ( [shipping_details] => Array ( [0] => Array ( [seller_id] => 0 [items_weight] => 4.05 [product_name] => My Tshirt) [item_id] => 812 ) ) [dest_country_id] => IN [dest_postal] => 500049 ) 


My code which is caluculating carrier amount as follows. How can i get the city name and state/region id in $request.



namespace MyTableRateShippingModel;

use MagentoQuoteModelQuoteAddressRateResultError;
use MagentoQuoteModelQuoteAddressRateRequest;
use MyTableRateShippingModelShippingmethodFactory;
use MagentoCatalogModelProductFactory;
use MagentoFrameworkSessionSessionManager;
use MagentoQuoteModelQuoteItemOptionFactory;
use MyTableRateShippingModelTableRateShippingFactory;
use MagentoFrameworkUnserializeUnserialize;

class Carrier extends MagentoShippingModelCarrierAbstractCarrier implements
MagentoShippingModelCarrierCarrierInterface
{
/**
* Code of the carrier.
*
* @var string
*/
const CODE = 'mytablerateshipping';
/**
* Code of the carrier.
*
* @var string
*/
protected $_code = self::CODE;
/**
* Rate request data.
*
* @var MagentoQuoteModelQuoteAddressRateRequest|null
*/
protected $_request;
/**
* @var MagentoCatalogModelProduct
*/
protected $_productFactory;
/**
* Rate result data.
*
* @var Result|null
*/
protected $_result;
/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;
/**
* @var array
*/
protected $_errors = [];

protected $_isFixed = true;
/**
* @var MagentoShippingModelRateResultFactory
*/
protected $_rateResultFactory;
/**
* @var MagentoQuoteModelQuoteAddressRateResultMethodFactory
*/
protected $_rateMethodFactory;
/**
* Raw rate request data.
*
* @var MagentoFrameworkDataObject|null
*/
protected $_rawRequest = null;
/**
* @var MyTableRateShippingModelShippingmethodFactory
*/
protected $_mpshippingMethod;
/**
* @var MagentoFrameworkSessionSessionManager
*/
protected $_coreSession;
/**
* @var OptionFactory
*/
protected $_itemOptionModel;
/**
* @var MyMarketplaceModelProductFactory
*/
protected $_mpProductFactory;
/**
* @var TableRateShippingFactory
*/
protected $_mpShippingModel;
/**
* @var Unserialize
*/
protected $_unserialize;
/**
* @var Unserialize
*/
protected $collectionFactory;
/**
* @param MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
* @param MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory
* @param PsrLogLoggerInterface $logger
* @param MagentoShippingModelRateResultFactory $rateResultFactory
* @param MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory
* @param ProductFactory $productFactory
* @param MagentoFrameworkObjectManagerInterface $objectManager
* @param ShippingmethodFactory $shippingmethodFactory
* @param SessionManager $coreSession
* @param OptionFactory $itemOptionModel
* @param TableRateShippingFactory $mpshippingModel
* @param array $data
*/

public function __construct(
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory,
PsrLogLoggerInterface $logger,
MagentoShippingModelRateResultFactory $rateResultFactory,
MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory,
ProductFactory $productFactory,
MagentoFrameworkObjectManagerInterface $objectManager,
ShippingmethodFactory $shippingmethodFactory,
SessionManager $coreSession,
OptionFactory $itemOptionModel,
ShippingFactory $mpshippingModel,
Unserialize $unserialize,
MagentoFrameworkDataCollectionFactory $collectionFactory,
array $data = []
)
$this->collectionFactory = $collectionFactory;
$this->_productFactory = $productFactory;
$this->_objectManager = $objectManager;
$this->_rateResultFactory = $rateResultFactory;
$this->_rateMethodFactory = $rateMethodFactory;
$this->_mpshippingMethod = $shippingmethodFactory;
$this->_coreSession = $coreSession;
$this->_itemOptionModel = $itemOptionModel;
$this->_mpShippingModel = $mpshippingModel;
$this->_unserialize = $unserialize;
parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);

/**
* Collect and get rates.
*
* @param RateRequest $request
*
* @return MagentoQuoteModelQuoteAddressRateResultError|bool|Result
*/
public function collectRates(RateRequest $request)

$this->setRequest($request);
$shippingpricedetail = $this->getShippingPricedetail($this->_rawRequest);

return $shippingpricedetail;

/**
* @param MagentoFrameworkDataObject|null $request
* @return $this
* @api
*/
public function setRawRequest($request)

$this->_rawRequest = $request;

return $this;

/**
* Prepare and set request to this instance.
*
* @param MagentoQuoteModelQuoteAddressRateRequest $request
*
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function setRequest(MagentoQuoteModelQuoteAddressRateRequest $request)

$this->_request = $request;
$requestData = new MagentoFrameworkDataObject();
$product = $this->_productFactory->create();
$mpassignproductId = 0;
$shippingdetail = [];
$partner = 0;
$handling = 0;
foreach ($request->getAllItems() as $item)

//$request->getDestCity();
//$request->getDestRegionId();
//$request->getDestPostcode();

//$request->getSourceCity();



if ($request->getShippingDetails())
$shippingdetail = $request->getShippingDetails();

$requestData->setShippingDetails($shippingdetail);

$requestData->setDestCountryId($request->getDestCountryId());

if ($request->getDestPostcode())
$requestData->setDestPostal(str_replace('-', '', $request->getDestPostcode()));



$this->setRawRequest($requestData);

return $this;



Calling my own function like this



if ($shipping->getSize() != 0) 
$priceArr = $this->getDpriceArrForRate($shipping,$request);
else
$msg = $this->getErrorMsg($msg, $shipdetail);



My getDpriceArrForRate function is like below



 public function getDpriceArrForRate($shipping,$request)

//$request->getDestCity();
//$request->getDestRegionId();
//$request->getDestPostcode();

//$request->getSourceCity();


print_r($request->getDestCity());
exit;



Its giving empty










share|improve this question






























    2















    I need to apply table rate shipping based on following conditions




    City to City



    Metro to City



    Metro to Metro



    City to Other



    City to Special Locations




    I written my own module but i am getting only the postal code and country id in $request



    Array ( [shipping_details] => Array ( [0] => Array ( [seller_id] => 0 [items_weight] => 4.05 [product_name] => My Tshirt) [item_id] => 812 ) ) [dest_country_id] => IN [dest_postal] => 500049 ) 


    My code which is caluculating carrier amount as follows. How can i get the city name and state/region id in $request.



    namespace MyTableRateShippingModel;

    use MagentoQuoteModelQuoteAddressRateResultError;
    use MagentoQuoteModelQuoteAddressRateRequest;
    use MyTableRateShippingModelShippingmethodFactory;
    use MagentoCatalogModelProductFactory;
    use MagentoFrameworkSessionSessionManager;
    use MagentoQuoteModelQuoteItemOptionFactory;
    use MyTableRateShippingModelTableRateShippingFactory;
    use MagentoFrameworkUnserializeUnserialize;

    class Carrier extends MagentoShippingModelCarrierAbstractCarrier implements
    MagentoShippingModelCarrierCarrierInterface
    {
    /**
    * Code of the carrier.
    *
    * @var string
    */
    const CODE = 'mytablerateshipping';
    /**
    * Code of the carrier.
    *
    * @var string
    */
    protected $_code = self::CODE;
    /**
    * Rate request data.
    *
    * @var MagentoQuoteModelQuoteAddressRateRequest|null
    */
    protected $_request;
    /**
    * @var MagentoCatalogModelProduct
    */
    protected $_productFactory;
    /**
    * Rate result data.
    *
    * @var Result|null
    */
    protected $_result;
    /**
    * @var MagentoFrameworkObjectManagerInterface
    */
    protected $_objectManager;
    /**
    * @var array
    */
    protected $_errors = [];

    protected $_isFixed = true;
    /**
    * @var MagentoShippingModelRateResultFactory
    */
    protected $_rateResultFactory;
    /**
    * @var MagentoQuoteModelQuoteAddressRateResultMethodFactory
    */
    protected $_rateMethodFactory;
    /**
    * Raw rate request data.
    *
    * @var MagentoFrameworkDataObject|null
    */
    protected $_rawRequest = null;
    /**
    * @var MyTableRateShippingModelShippingmethodFactory
    */
    protected $_mpshippingMethod;
    /**
    * @var MagentoFrameworkSessionSessionManager
    */
    protected $_coreSession;
    /**
    * @var OptionFactory
    */
    protected $_itemOptionModel;
    /**
    * @var MyMarketplaceModelProductFactory
    */
    protected $_mpProductFactory;
    /**
    * @var TableRateShippingFactory
    */
    protected $_mpShippingModel;
    /**
    * @var Unserialize
    */
    protected $_unserialize;
    /**
    * @var Unserialize
    */
    protected $collectionFactory;
    /**
    * @param MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
    * @param MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory
    * @param PsrLogLoggerInterface $logger
    * @param MagentoShippingModelRateResultFactory $rateResultFactory
    * @param MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory
    * @param ProductFactory $productFactory
    * @param MagentoFrameworkObjectManagerInterface $objectManager
    * @param ShippingmethodFactory $shippingmethodFactory
    * @param SessionManager $coreSession
    * @param OptionFactory $itemOptionModel
    * @param TableRateShippingFactory $mpshippingModel
    * @param array $data
    */

    public function __construct(
    MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
    MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory,
    PsrLogLoggerInterface $logger,
    MagentoShippingModelRateResultFactory $rateResultFactory,
    MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory,
    ProductFactory $productFactory,
    MagentoFrameworkObjectManagerInterface $objectManager,
    ShippingmethodFactory $shippingmethodFactory,
    SessionManager $coreSession,
    OptionFactory $itemOptionModel,
    ShippingFactory $mpshippingModel,
    Unserialize $unserialize,
    MagentoFrameworkDataCollectionFactory $collectionFactory,
    array $data = []
    )
    $this->collectionFactory = $collectionFactory;
    $this->_productFactory = $productFactory;
    $this->_objectManager = $objectManager;
    $this->_rateResultFactory = $rateResultFactory;
    $this->_rateMethodFactory = $rateMethodFactory;
    $this->_mpshippingMethod = $shippingmethodFactory;
    $this->_coreSession = $coreSession;
    $this->_itemOptionModel = $itemOptionModel;
    $this->_mpShippingModel = $mpshippingModel;
    $this->_unserialize = $unserialize;
    parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);

    /**
    * Collect and get rates.
    *
    * @param RateRequest $request
    *
    * @return MagentoQuoteModelQuoteAddressRateResultError|bool|Result
    */
    public function collectRates(RateRequest $request)

    $this->setRequest($request);
    $shippingpricedetail = $this->getShippingPricedetail($this->_rawRequest);

    return $shippingpricedetail;

    /**
    * @param MagentoFrameworkDataObject|null $request
    * @return $this
    * @api
    */
    public function setRawRequest($request)

    $this->_rawRequest = $request;

    return $this;

    /**
    * Prepare and set request to this instance.
    *
    * @param MagentoQuoteModelQuoteAddressRateRequest $request
    *
    * @return $this
    * @SuppressWarnings(PHPMD.CyclomaticComplexity)
    * @SuppressWarnings(PHPMD.NPathComplexity)
    * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
    */
    public function setRequest(MagentoQuoteModelQuoteAddressRateRequest $request)

    $this->_request = $request;
    $requestData = new MagentoFrameworkDataObject();
    $product = $this->_productFactory->create();
    $mpassignproductId = 0;
    $shippingdetail = [];
    $partner = 0;
    $handling = 0;
    foreach ($request->getAllItems() as $item)

    //$request->getDestCity();
    //$request->getDestRegionId();
    //$request->getDestPostcode();

    //$request->getSourceCity();



    if ($request->getShippingDetails())
    $shippingdetail = $request->getShippingDetails();

    $requestData->setShippingDetails($shippingdetail);

    $requestData->setDestCountryId($request->getDestCountryId());

    if ($request->getDestPostcode())
    $requestData->setDestPostal(str_replace('-', '', $request->getDestPostcode()));



    $this->setRawRequest($requestData);

    return $this;



    Calling my own function like this



    if ($shipping->getSize() != 0) 
    $priceArr = $this->getDpriceArrForRate($shipping,$request);
    else
    $msg = $this->getErrorMsg($msg, $shipdetail);



    My getDpriceArrForRate function is like below



     public function getDpriceArrForRate($shipping,$request)

    //$request->getDestCity();
    //$request->getDestRegionId();
    //$request->getDestPostcode();

    //$request->getSourceCity();


    print_r($request->getDestCity());
    exit;



    Its giving empty










    share|improve this question


























      2












      2








      2








      I need to apply table rate shipping based on following conditions




      City to City



      Metro to City



      Metro to Metro



      City to Other



      City to Special Locations




      I written my own module but i am getting only the postal code and country id in $request



      Array ( [shipping_details] => Array ( [0] => Array ( [seller_id] => 0 [items_weight] => 4.05 [product_name] => My Tshirt) [item_id] => 812 ) ) [dest_country_id] => IN [dest_postal] => 500049 ) 


      My code which is caluculating carrier amount as follows. How can i get the city name and state/region id in $request.



      namespace MyTableRateShippingModel;

      use MagentoQuoteModelQuoteAddressRateResultError;
      use MagentoQuoteModelQuoteAddressRateRequest;
      use MyTableRateShippingModelShippingmethodFactory;
      use MagentoCatalogModelProductFactory;
      use MagentoFrameworkSessionSessionManager;
      use MagentoQuoteModelQuoteItemOptionFactory;
      use MyTableRateShippingModelTableRateShippingFactory;
      use MagentoFrameworkUnserializeUnserialize;

      class Carrier extends MagentoShippingModelCarrierAbstractCarrier implements
      MagentoShippingModelCarrierCarrierInterface
      {
      /**
      * Code of the carrier.
      *
      * @var string
      */
      const CODE = 'mytablerateshipping';
      /**
      * Code of the carrier.
      *
      * @var string
      */
      protected $_code = self::CODE;
      /**
      * Rate request data.
      *
      * @var MagentoQuoteModelQuoteAddressRateRequest|null
      */
      protected $_request;
      /**
      * @var MagentoCatalogModelProduct
      */
      protected $_productFactory;
      /**
      * Rate result data.
      *
      * @var Result|null
      */
      protected $_result;
      /**
      * @var MagentoFrameworkObjectManagerInterface
      */
      protected $_objectManager;
      /**
      * @var array
      */
      protected $_errors = [];

      protected $_isFixed = true;
      /**
      * @var MagentoShippingModelRateResultFactory
      */
      protected $_rateResultFactory;
      /**
      * @var MagentoQuoteModelQuoteAddressRateResultMethodFactory
      */
      protected $_rateMethodFactory;
      /**
      * Raw rate request data.
      *
      * @var MagentoFrameworkDataObject|null
      */
      protected $_rawRequest = null;
      /**
      * @var MyTableRateShippingModelShippingmethodFactory
      */
      protected $_mpshippingMethod;
      /**
      * @var MagentoFrameworkSessionSessionManager
      */
      protected $_coreSession;
      /**
      * @var OptionFactory
      */
      protected $_itemOptionModel;
      /**
      * @var MyMarketplaceModelProductFactory
      */
      protected $_mpProductFactory;
      /**
      * @var TableRateShippingFactory
      */
      protected $_mpShippingModel;
      /**
      * @var Unserialize
      */
      protected $_unserialize;
      /**
      * @var Unserialize
      */
      protected $collectionFactory;
      /**
      * @param MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
      * @param MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory
      * @param PsrLogLoggerInterface $logger
      * @param MagentoShippingModelRateResultFactory $rateResultFactory
      * @param MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory
      * @param ProductFactory $productFactory
      * @param MagentoFrameworkObjectManagerInterface $objectManager
      * @param ShippingmethodFactory $shippingmethodFactory
      * @param SessionManager $coreSession
      * @param OptionFactory $itemOptionModel
      * @param TableRateShippingFactory $mpshippingModel
      * @param array $data
      */

      public function __construct(
      MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
      MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory,
      PsrLogLoggerInterface $logger,
      MagentoShippingModelRateResultFactory $rateResultFactory,
      MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory,
      ProductFactory $productFactory,
      MagentoFrameworkObjectManagerInterface $objectManager,
      ShippingmethodFactory $shippingmethodFactory,
      SessionManager $coreSession,
      OptionFactory $itemOptionModel,
      ShippingFactory $mpshippingModel,
      Unserialize $unserialize,
      MagentoFrameworkDataCollectionFactory $collectionFactory,
      array $data = []
      )
      $this->collectionFactory = $collectionFactory;
      $this->_productFactory = $productFactory;
      $this->_objectManager = $objectManager;
      $this->_rateResultFactory = $rateResultFactory;
      $this->_rateMethodFactory = $rateMethodFactory;
      $this->_mpshippingMethod = $shippingmethodFactory;
      $this->_coreSession = $coreSession;
      $this->_itemOptionModel = $itemOptionModel;
      $this->_mpShippingModel = $mpshippingModel;
      $this->_unserialize = $unserialize;
      parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);

      /**
      * Collect and get rates.
      *
      * @param RateRequest $request
      *
      * @return MagentoQuoteModelQuoteAddressRateResultError|bool|Result
      */
      public function collectRates(RateRequest $request)

      $this->setRequest($request);
      $shippingpricedetail = $this->getShippingPricedetail($this->_rawRequest);

      return $shippingpricedetail;

      /**
      * @param MagentoFrameworkDataObject|null $request
      * @return $this
      * @api
      */
      public function setRawRequest($request)

      $this->_rawRequest = $request;

      return $this;

      /**
      * Prepare and set request to this instance.
      *
      * @param MagentoQuoteModelQuoteAddressRateRequest $request
      *
      * @return $this
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
      public function setRequest(MagentoQuoteModelQuoteAddressRateRequest $request)

      $this->_request = $request;
      $requestData = new MagentoFrameworkDataObject();
      $product = $this->_productFactory->create();
      $mpassignproductId = 0;
      $shippingdetail = [];
      $partner = 0;
      $handling = 0;
      foreach ($request->getAllItems() as $item)

      //$request->getDestCity();
      //$request->getDestRegionId();
      //$request->getDestPostcode();

      //$request->getSourceCity();



      if ($request->getShippingDetails())
      $shippingdetail = $request->getShippingDetails();

      $requestData->setShippingDetails($shippingdetail);

      $requestData->setDestCountryId($request->getDestCountryId());

      if ($request->getDestPostcode())
      $requestData->setDestPostal(str_replace('-', '', $request->getDestPostcode()));



      $this->setRawRequest($requestData);

      return $this;



      Calling my own function like this



      if ($shipping->getSize() != 0) 
      $priceArr = $this->getDpriceArrForRate($shipping,$request);
      else
      $msg = $this->getErrorMsg($msg, $shipdetail);



      My getDpriceArrForRate function is like below



       public function getDpriceArrForRate($shipping,$request)

      //$request->getDestCity();
      //$request->getDestRegionId();
      //$request->getDestPostcode();

      //$request->getSourceCity();


      print_r($request->getDestCity());
      exit;



      Its giving empty










      share|improve this question
















      I need to apply table rate shipping based on following conditions




      City to City



      Metro to City



      Metro to Metro



      City to Other



      City to Special Locations




      I written my own module but i am getting only the postal code and country id in $request



      Array ( [shipping_details] => Array ( [0] => Array ( [seller_id] => 0 [items_weight] => 4.05 [product_name] => My Tshirt) [item_id] => 812 ) ) [dest_country_id] => IN [dest_postal] => 500049 ) 


      My code which is caluculating carrier amount as follows. How can i get the city name and state/region id in $request.



      namespace MyTableRateShippingModel;

      use MagentoQuoteModelQuoteAddressRateResultError;
      use MagentoQuoteModelQuoteAddressRateRequest;
      use MyTableRateShippingModelShippingmethodFactory;
      use MagentoCatalogModelProductFactory;
      use MagentoFrameworkSessionSessionManager;
      use MagentoQuoteModelQuoteItemOptionFactory;
      use MyTableRateShippingModelTableRateShippingFactory;
      use MagentoFrameworkUnserializeUnserialize;

      class Carrier extends MagentoShippingModelCarrierAbstractCarrier implements
      MagentoShippingModelCarrierCarrierInterface
      {
      /**
      * Code of the carrier.
      *
      * @var string
      */
      const CODE = 'mytablerateshipping';
      /**
      * Code of the carrier.
      *
      * @var string
      */
      protected $_code = self::CODE;
      /**
      * Rate request data.
      *
      * @var MagentoQuoteModelQuoteAddressRateRequest|null
      */
      protected $_request;
      /**
      * @var MagentoCatalogModelProduct
      */
      protected $_productFactory;
      /**
      * Rate result data.
      *
      * @var Result|null
      */
      protected $_result;
      /**
      * @var MagentoFrameworkObjectManagerInterface
      */
      protected $_objectManager;
      /**
      * @var array
      */
      protected $_errors = [];

      protected $_isFixed = true;
      /**
      * @var MagentoShippingModelRateResultFactory
      */
      protected $_rateResultFactory;
      /**
      * @var MagentoQuoteModelQuoteAddressRateResultMethodFactory
      */
      protected $_rateMethodFactory;
      /**
      * Raw rate request data.
      *
      * @var MagentoFrameworkDataObject|null
      */
      protected $_rawRequest = null;
      /**
      * @var MyTableRateShippingModelShippingmethodFactory
      */
      protected $_mpshippingMethod;
      /**
      * @var MagentoFrameworkSessionSessionManager
      */
      protected $_coreSession;
      /**
      * @var OptionFactory
      */
      protected $_itemOptionModel;
      /**
      * @var MyMarketplaceModelProductFactory
      */
      protected $_mpProductFactory;
      /**
      * @var TableRateShippingFactory
      */
      protected $_mpShippingModel;
      /**
      * @var Unserialize
      */
      protected $_unserialize;
      /**
      * @var Unserialize
      */
      protected $collectionFactory;
      /**
      * @param MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
      * @param MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory
      * @param PsrLogLoggerInterface $logger
      * @param MagentoShippingModelRateResultFactory $rateResultFactory
      * @param MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory
      * @param ProductFactory $productFactory
      * @param MagentoFrameworkObjectManagerInterface $objectManager
      * @param ShippingmethodFactory $shippingmethodFactory
      * @param SessionManager $coreSession
      * @param OptionFactory $itemOptionModel
      * @param TableRateShippingFactory $mpshippingModel
      * @param array $data
      */

      public function __construct(
      MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
      MagentoQuoteModelQuoteAddressRateResultErrorFactory $rateErrorFactory,
      PsrLogLoggerInterface $logger,
      MagentoShippingModelRateResultFactory $rateResultFactory,
      MagentoQuoteModelQuoteAddressRateResultMethodFactory $rateMethodFactory,
      ProductFactory $productFactory,
      MagentoFrameworkObjectManagerInterface $objectManager,
      ShippingmethodFactory $shippingmethodFactory,
      SessionManager $coreSession,
      OptionFactory $itemOptionModel,
      ShippingFactory $mpshippingModel,
      Unserialize $unserialize,
      MagentoFrameworkDataCollectionFactory $collectionFactory,
      array $data = []
      )
      $this->collectionFactory = $collectionFactory;
      $this->_productFactory = $productFactory;
      $this->_objectManager = $objectManager;
      $this->_rateResultFactory = $rateResultFactory;
      $this->_rateMethodFactory = $rateMethodFactory;
      $this->_mpshippingMethod = $shippingmethodFactory;
      $this->_coreSession = $coreSession;
      $this->_itemOptionModel = $itemOptionModel;
      $this->_mpShippingModel = $mpshippingModel;
      $this->_unserialize = $unserialize;
      parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);

      /**
      * Collect and get rates.
      *
      * @param RateRequest $request
      *
      * @return MagentoQuoteModelQuoteAddressRateResultError|bool|Result
      */
      public function collectRates(RateRequest $request)

      $this->setRequest($request);
      $shippingpricedetail = $this->getShippingPricedetail($this->_rawRequest);

      return $shippingpricedetail;

      /**
      * @param MagentoFrameworkDataObject|null $request
      * @return $this
      * @api
      */
      public function setRawRequest($request)

      $this->_rawRequest = $request;

      return $this;

      /**
      * Prepare and set request to this instance.
      *
      * @param MagentoQuoteModelQuoteAddressRateRequest $request
      *
      * @return $this
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
      public function setRequest(MagentoQuoteModelQuoteAddressRateRequest $request)

      $this->_request = $request;
      $requestData = new MagentoFrameworkDataObject();
      $product = $this->_productFactory->create();
      $mpassignproductId = 0;
      $shippingdetail = [];
      $partner = 0;
      $handling = 0;
      foreach ($request->getAllItems() as $item)

      //$request->getDestCity();
      //$request->getDestRegionId();
      //$request->getDestPostcode();

      //$request->getSourceCity();



      if ($request->getShippingDetails())
      $shippingdetail = $request->getShippingDetails();

      $requestData->setShippingDetails($shippingdetail);

      $requestData->setDestCountryId($request->getDestCountryId());

      if ($request->getDestPostcode())
      $requestData->setDestPostal(str_replace('-', '', $request->getDestPostcode()));



      $this->setRawRequest($requestData);

      return $this;



      Calling my own function like this



      if ($shipping->getSize() != 0) 
      $priceArr = $this->getDpriceArrForRate($shipping,$request);
      else
      $msg = $this->getErrorMsg($msg, $shipdetail);



      My getDpriceArrForRate function is like below



       public function getDpriceArrForRate($shipping,$request)

      //$request->getDestCity();
      //$request->getDestRegionId();
      //$request->getDestPostcode();

      //$request->getSourceCity();


      print_r($request->getDestCity());
      exit;



      Its giving empty







      magento2 magento-2.1 php






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 21 at 4:37







      Dinesh

















      asked Mar 20 at 13:26









      DineshDinesh

      11711




      11711




















          2 Answers
          2






          active

          oldest

          votes


















          0














          You can get request city name from $request



          For city use $request->getDestCity()



          For getting region Id use $request->getDestRegionId()



          For getting region use $request->getDestRegion()






          share|improve this answer























          • Its giving empty value.

            – Dinesh
            Mar 20 at 13:45











          • I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

            – Dinesh
            Mar 20 at 13:59











          • You have to pass the $request to this function

            – Amit Bera
            Mar 20 at 14:02











          • I passed $request but not able to get the city name. I shared my code in my question.

            – Dinesh
            Mar 21 at 4:39


















          0














          Finally I changed my code in my modal as follows.



           $requestData->setDestCountryId($request->getDestCountryId());
          $requestData->setDestCity($request->getDestCity());
          $requestData->setDestRegionId($request->getDestRegionId());
          $this->setRawRequest($requestData);


          Now i can access the City , Region and CountryId by calling Raw Request As follows.



           $dest_city=$this->_rawRequest->getDestCity();
          $dest_regionid=$this->_rawRequest->getDestRegionId();
          $dest_postcode=$this->_rawRequest->getDestPostcode();





          share|improve this answer























          • I Want to add buffer weight of currently selected shipping method. How can i do it?

            – Dinesh
            Apr 4 at 10:31











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266713%2fmagento2-shipping-city-for-shipping-amount-caluculations%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can get request city name from $request



          For city use $request->getDestCity()



          For getting region Id use $request->getDestRegionId()



          For getting region use $request->getDestRegion()






          share|improve this answer























          • Its giving empty value.

            – Dinesh
            Mar 20 at 13:45











          • I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

            – Dinesh
            Mar 20 at 13:59











          • You have to pass the $request to this function

            – Amit Bera
            Mar 20 at 14:02











          • I passed $request but not able to get the city name. I shared my code in my question.

            – Dinesh
            Mar 21 at 4:39















          0














          You can get request city name from $request



          For city use $request->getDestCity()



          For getting region Id use $request->getDestRegionId()



          For getting region use $request->getDestRegion()






          share|improve this answer























          • Its giving empty value.

            – Dinesh
            Mar 20 at 13:45











          • I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

            – Dinesh
            Mar 20 at 13:59











          • You have to pass the $request to this function

            – Amit Bera
            Mar 20 at 14:02











          • I passed $request but not able to get the city name. I shared my code in my question.

            – Dinesh
            Mar 21 at 4:39













          0












          0








          0







          You can get request city name from $request



          For city use $request->getDestCity()



          For getting region Id use $request->getDestRegionId()



          For getting region use $request->getDestRegion()






          share|improve this answer













          You can get request city name from $request



          For city use $request->getDestCity()



          For getting region Id use $request->getDestRegionId()



          For getting region use $request->getDestRegion()







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 20 at 13:37









          Amit BeraAmit Bera

          60.4k1678178




          60.4k1678178












          • Its giving empty value.

            – Dinesh
            Mar 20 at 13:45











          • I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

            – Dinesh
            Mar 20 at 13:59











          • You have to pass the $request to this function

            – Amit Bera
            Mar 20 at 14:02











          • I passed $request but not able to get the city name. I shared my code in my question.

            – Dinesh
            Mar 21 at 4:39

















          • Its giving empty value.

            – Dinesh
            Mar 20 at 13:45











          • I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

            – Dinesh
            Mar 20 at 13:59











          • You have to pass the $request to this function

            – Amit Bera
            Mar 20 at 14:02











          • I passed $request but not able to get the city name. I shared my code in my question.

            – Dinesh
            Mar 21 at 4:39
















          Its giving empty value.

          – Dinesh
          Mar 20 at 13:45





          Its giving empty value.

          – Dinesh
          Mar 20 at 13:45













          I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

          – Dinesh
          Mar 20 at 13:59





          I am getting City Name in setRequest function , but i need to use this value in another function. How can i pass this value as global value?

          – Dinesh
          Mar 20 at 13:59













          You have to pass the $request to this function

          – Amit Bera
          Mar 20 at 14:02





          You have to pass the $request to this function

          – Amit Bera
          Mar 20 at 14:02













          I passed $request but not able to get the city name. I shared my code in my question.

          – Dinesh
          Mar 21 at 4:39





          I passed $request but not able to get the city name. I shared my code in my question.

          – Dinesh
          Mar 21 at 4:39













          0














          Finally I changed my code in my modal as follows.



           $requestData->setDestCountryId($request->getDestCountryId());
          $requestData->setDestCity($request->getDestCity());
          $requestData->setDestRegionId($request->getDestRegionId());
          $this->setRawRequest($requestData);


          Now i can access the City , Region and CountryId by calling Raw Request As follows.



           $dest_city=$this->_rawRequest->getDestCity();
          $dest_regionid=$this->_rawRequest->getDestRegionId();
          $dest_postcode=$this->_rawRequest->getDestPostcode();





          share|improve this answer























          • I Want to add buffer weight of currently selected shipping method. How can i do it?

            – Dinesh
            Apr 4 at 10:31















          0














          Finally I changed my code in my modal as follows.



           $requestData->setDestCountryId($request->getDestCountryId());
          $requestData->setDestCity($request->getDestCity());
          $requestData->setDestRegionId($request->getDestRegionId());
          $this->setRawRequest($requestData);


          Now i can access the City , Region and CountryId by calling Raw Request As follows.



           $dest_city=$this->_rawRequest->getDestCity();
          $dest_regionid=$this->_rawRequest->getDestRegionId();
          $dest_postcode=$this->_rawRequest->getDestPostcode();





          share|improve this answer























          • I Want to add buffer weight of currently selected shipping method. How can i do it?

            – Dinesh
            Apr 4 at 10:31













          0












          0








          0







          Finally I changed my code in my modal as follows.



           $requestData->setDestCountryId($request->getDestCountryId());
          $requestData->setDestCity($request->getDestCity());
          $requestData->setDestRegionId($request->getDestRegionId());
          $this->setRawRequest($requestData);


          Now i can access the City , Region and CountryId by calling Raw Request As follows.



           $dest_city=$this->_rawRequest->getDestCity();
          $dest_regionid=$this->_rawRequest->getDestRegionId();
          $dest_postcode=$this->_rawRequest->getDestPostcode();





          share|improve this answer













          Finally I changed my code in my modal as follows.



           $requestData->setDestCountryId($request->getDestCountryId());
          $requestData->setDestCity($request->getDestCity());
          $requestData->setDestRegionId($request->getDestRegionId());
          $this->setRawRequest($requestData);


          Now i can access the City , Region and CountryId by calling Raw Request As follows.



           $dest_city=$this->_rawRequest->getDestCity();
          $dest_regionid=$this->_rawRequest->getDestRegionId();
          $dest_postcode=$this->_rawRequest->getDestPostcode();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 8:22









          DineshDinesh

          11711




          11711












          • I Want to add buffer weight of currently selected shipping method. How can i do it?

            – Dinesh
            Apr 4 at 10:31

















          • I Want to add buffer weight of currently selected shipping method. How can i do it?

            – Dinesh
            Apr 4 at 10:31
















          I Want to add buffer weight of currently selected shipping method. How can i do it?

          – Dinesh
          Apr 4 at 10:31





          I Want to add buffer weight of currently selected shipping method. How can i do it?

          – Dinesh
          Apr 4 at 10:31

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266713%2fmagento2-shipping-city-for-shipping-amount-caluculations%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Masuk log Menu navigasi

          Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

          Старые Смолеговицы Содержание История | География | Демография | Достопримечательности | Примечания | НавигацияHGЯOLHGЯOL41 206 832 01641 606 406 141Административно-территориальное деление Ленинградской области«Переписная оброчная книга Водской пятины 1500 года», С. 793«Карта Ингерманландии: Ивангорода, Яма, Копорья, Нотеборга», по материалам 1676 г.«Генеральная карта провинции Ингерманландии» Э. Белинга и А. Андерсина, 1704 г., составлена по материалам 1678 г.«Географический чертёж над Ижорскою землей со своими городами» Адриана Шонбека 1705 г.Новая и достоверная всей Ингерманландии ланткарта. Грав. А. Ростовцев. СПб., 1727 г.Топографическая карта Санкт-Петербургской губернии. 5-и верстка. Шуберт. 1834 г.Описание Санкт-Петербургской губернии по уездам и станамСпецкарта западной части России Ф. Ф. Шуберта. 1844 г.Алфавитный список селений по уездам и станам С.-Петербургской губернииСписки населённых мест Российской Империи, составленные и издаваемые центральным статистическим комитетом министерства внутренних дел. XXXVII. Санкт-Петербургская губерния. По состоянию на 1862 год. СПб. 1864. С. 203Материалы по статистике народного хозяйства в С.-Петербургской губернии. Вып. IX. Частновладельческое хозяйство в Ямбургском уезде. СПб, 1888, С. 146, С. 2, 7, 54Положение о гербе муниципального образования Курское сельское поселениеСправочник истории административно-территориального деления Ленинградской области.Топографическая карта Ленинградской области, квадрат О-35-23-В (Хотыницы), 1930 г.АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1933, С. 27, 198АрхивированоАдминистративно-экономический справочник по Ленинградской области. — Л., 1936, с. 219АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1966, с. 175АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1973, С. 180АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1990, ISBN 5-289-00612-5, С. 38АрхивированоАдминистративно-территориальное деление Ленинградской области. — СПб., 2007, с. 60АрхивированоКоряков Юрий База данных «Этно-языковой состав населённых пунктов России». Ленинградская область.Административно-территориальное деление Ленинградской области. — СПб, 1997, ISBN 5-86153-055-6, С. 41АрхивированоКультовый комплекс Старые Смолеговицы // Электронная энциклопедия ЭрмитажаПроблемы выявления, изучения и сохранения культовых комплексов с каменными крестами: по материалам работ 2016-2017 гг. в Ленинградской области