Hello,
You can use default magento table rate for same.
or you can use
etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Shipping\Model\Rate\Result">
<plugin name="restrict_shippingmethod" type="[Vendor]\[Module]\Plugin\ShippingMethod" sortOrder="500" />
</type>
</config>
<?php
namespace [Vendor]\[Module]\Plugin;
class ShippingMethod
{
public function beforeAppend($subject, $result)
{
if (!$result instanceof \Magento\Quote\Model\Quote\Address\RateResult\Method) {
return [$result];
}
if ($this->isMethodRestricted($result)) {
$result->setIsDisabled(true);
}
return [$result];
}
public function isMethodRestricted($shippingModel)
{
$code = $shippingModel->getCarrier();
$restrictedMethod = ['replace_method_code'];
if ($restrictedMethod && in_array($code, $restrictedMethod)) {
return true;
}
return false;
}
}
or use amasty shipping method module
https://amasty.com/shipping-table-rates-for-magento-2.html
hope it will help you.
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer