1
In shipping carrier class, there's a method to validate additional rules proccessAdditionalValidation, searching for that method in the code base will reveal processAdditionalValidation (less than 1 'c'). Then continue searching with that will lead collectCarrierRates
So in my opinion, there will be 2 approaches for this:
Extend the current Carrier, add ...
1
I haven't done something similar but as I checked the code right now, you can create an after Plugin for this method \Magento\Shipping\Model\CarrierFactory::createIfActive or also this method \Magento\Shipping\Model\Shipping::isShippingCarrierAvailable, there you can add your validation and return true or false for the shipping method you allow or not.
...
1
The best way to get current website id of selected website in admin panel
<?php
namespace Vendor\Namespace\Controller\Index;
class Index
{
protected $state;
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\App\State $state
){
$this->request = $request;
$...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
adminhtml × 1602magento2 × 557
magento-1.9 × 300
grid × 223
admin × 214
module × 110
adminform × 96
uicomponent × 93
magento-2.1 × 74
magento-1.7 × 73
layout × 67
overrides × 66
product × 64
blocks × 61
magento-1.8 × 57
forms × 56
magento-1 × 55
sales-order × 55
configuration × 45
backend × 44
customer × 43
javascript × 42
event-observer × 42
magento2.3 × 38
controllers × 37