How to disable cash on delivery payment based on cod availability. etc/di.xml
<type name="Magento\OfflinePayments\Model\Cashondelivery">
<plugin name="cashondeliveryplugin" type="Xxx\Yyy\Plugin\Model\Cashondelivery" sortOrder="10" disabled="false" /> </type>
Cashondelivery.php
public function aroundIsAvailable(\Magento\OfflinePayments\Model\Cashondelivery $subject, callable $proceed)
{
$result = $proceed();
$zipCode = $this->_checkoutSession->getQuote()->getShippingAddress()->getPostcode();
$codAvailability = $this->_pincodeModel->isCODAvailable($zipCode) ? "yes" : "no";
if ($codAvailability == 'no') {
return false;
}
return $result;
}
}
Its not working in backend...Any modification in my code .....