I am simply looking to get the shipping rates from the current quote and override them via a plugin/interceptor but have no idea where I'm going wrong here:
<?php
namespace Vendor\Module\Plugin\Model\Quote\Address\RateResult;
use \Psr\Log\LoggerInterface;
class MethodPlugin
{
protected $_customerSession;
protected $_logger;
public function __construct(
LoggerInterface $logger,
\Magento\Customer\Model\Session $customerSession
)
{
$this->_logger = $logger;
$this->_customerSession = $customerSession;
}
public function beforeSetPrice($subject, $price)
{
$this->_logger->debug("Current price is " . $price);
return $price;
}
public function afterSetPrice($subject, $price)
{
$price = 3.33;
$this->_logger->debug("New price is " . $price);
return $price;
}
}
My thinking was that the beforeSetPrice()
method would log the current price (which it does) and the afterSetPrice()
method would log the new price (which it does) AND update the price shown in the shipping rates on checkout (which it doesn't)