Recently I create two after plugins, one that point to Magento\Catalog\Pricing\Price\FinalPrice::getValue() and other that point to Magento\Catalog\Model\Product::getPrice() and Magento\Catalog\Model\Product::getFinalPrice()
etc/frontend/di.xml
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Pricing\Price\FinalPrice">
<plugin disabled="false" name="morwifinalprice" sortOrder="99" type="Morwi\PrecioRegional\Plugin\FinalPrice"/>
</type>
<type name="Magento\Catalog\Model\Product">
<plugin disabled="false" name="morwifinalprice" sortOrder="99" type="Morwi\PrecioRegional\Plugin\Price"/>
</type>
</config>
Plugin/FinalPrice.php
<?php
namespace Morwi\PrecioRegional\Plugin;
class FinalPrice
{
...
/**
* @param \Magento\Catalog\Pricing\Price\FinalPrice $subject
* @param float $result
* @return float
*/
public function afterGetValue(\Magento\Catalog\Pricing\Price\FinalPrice $subject, $result){
...
return $result;
}
}
?>
Plugin/Price.php
<?php
namespace Morwi\PrecioRegional\Plugin;
class Price
{
...
/**
* @param \Magento\Catalog\Model\Product $subject
* @param float $result
* @return float
*/
public function afterGetPrice(\Magento\Catalog\Model\Product $subject, $result){
...
return $result;
}
/**
* @param \Magento\Catalog\Model\Product $subject
* @param float $result
* @return float
*/
public function afterGetFinalPrice(\Magento\Catalog\Model\Product $subject, $result){
...
return $result;
}
}
?>
The plugins work fine and are executed without problem on all the site. Except on checkout. When I pass from cart to checkout, my plugins are ignored. I debugged and detected that the original methods are executed:
Magento\Catalog\Pricing\Price\FinalPrice::getValue()
Magento\Catalog\Model\Product::getPrice()
Magento\Catalog\Model\Product::getFinalPrice()
But the plugins not. Why is it? How can I run my plugins on checkout?
Thanks.