This is how I am reaching the _call method:
$model->delivery_price = $currencyConverter->convertPriceByGivenCurrencies(
$model->delivery_price,
$currency->id,
$model->order_currency
);
The function throws an error but the method exists below it. My __call looks like:
public function __call($name, $params)
{
if(method_exists(CurrencyConverter::className(), $name)){
if($params[0] == 0 || $params[0]){
call_user_func_array($name, $params);
}else{
throw new \Exception('Price must be a valid number!');
}
}
throw new NotFoundException('Function doesn\'t exist');
}
It passes the if condition but after that the error occures:
call_user_func_array() expects parameter 1 to be a valid callback, function 'convertPriceByGivenCurrencies' not found or invalid function name
And this is the convertPriceByGivenCurrencies method which is landed in the below the _call:
protected function convertPriceByGivenCurrencies($product_price, $product_price_currency_id, $select_currency_id)
{
............
}
What am I doing wrong here ? Thank you!
call_user_func_arraycall are you referring to that same class …? You are passing the function name only there, so it looks for a standalone function of that name.