I'm trying to create a plugin for Magento 2.1.3 that disables the flat rate shipping method in the cart, but keeps it enabled in the admin panel.
I've followed the instructions to the best of my knowledge, and Magento doesn't seem to be picking up my plugin.
Here's what I've got:
app/code/MaadDecor/DisableFlatRate/etc/di.xml:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\OfflineShipping\Model\Carrier\Flatrate">
<plugin name="hidePlug" type="MaadDecor\DisableFlatRate\Plugin\Hide" sortOrder="1" disabled="false"/>
</type>
app/code/MaadDecor/DisableFlatRate/Plugin/Hide.php
<?php
namespace MaadDecor\DisableFlatRate\Plugin;
use Magento\Backend\Model\Auth\Session;
use Psr\Log\LoggerInterface;
class Hide
{
protected $backendSession;
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(Session $session, LoggerInterface $logger)
{
$this->backendSession = $session;
$this->logger = $logger;
}
public function aroundCollectRates($subject, callable $proceed)
{
$this->logger->info('hit before the auth check');
if ($this->backendSession->isLoggedIn()) {
return $proceed();
}
$this->logger->info('hit after the auth check');
// return $proceed();
return false;
}
}
For some reason none of the logs are being added, and the shipping rate still displays on the front end.
Any ideas?