I have a problem, I am creating a custom module of rma, the module must allow to calculate the price of the shipment. Additionally I have a custom shipping module that works correctly in the purchase process but I have to calculate shipping prices in the rma module(for return product), I am trying to do this by calling a function of the shipping module but it does not execute.
The Shipping module:
app/code/xxxx/xxxx/model/carrier/shipping.php
class Shipping extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements \Magento\Shipping\Model\Carrier\CarrierInterface
{
#...rest of class methods
#function to calculate rates
public function getShippingPrice($origenRegion,$origenCiudad, $destinoRegion, $destinoCiudad, $peso)
{
# ...rest of function
$shippingPrice = $this->getFinalPriceWithHandlingFee($tasa);
return $shippingPrice;
}
public function collectRates(RateRequest $request)
{
#...
}
}
The shipping rates works fine, but when I try to use the getShippingPrice function in another section (an observer) it does not get executed.
class RmaSuccess implements ObserverInterface
{
protected $_ShippingModel;
public function __construct(\xxxx\xxxx\Model\Carrier\Shipping $ShippingModel){
$this->_ShippingModel = $ShippingModel;
}
public function execute(\Magento\Framework\Event\Observer $observer ) {
#....
CostOfRefound = $this->_ShippingModel->getShippingPrice($shippingAdressOrigin->getRegion(),
$shippingAdressOrigin->getCity(), $SellerRegion, $SellerCiudad,($PesoTotalSeller[$key])/1000);
#....the function does not run
}
}
thanks for any help.