Fatal error: Call to a member function calculate() on null in D:\xampp\htdocs\ramesh\project1\dealer\admin\controller\sale\order.php on line 795

Fatal error: Call to a member function calculate() on null in D:\xampp\htdocs\ramesh\project1\dealer\admin\controller\sale\order.php on line 795

正在为产品创建自定义总计。我正在使用此代码

$customerGroupId=$_COOKIE['customerGroupId'];

if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) 
{
    $priceOld = $newPrice;
    if($customerGroupId==25||$customerGroupId==0||$customerGroupId==26) 
    {
        $total1 = $this->getPriceListForGhee($product['name'], $priceOld, $product['types'], $product['quantity']);
    }
    else
    {
        $total1 = $this->getPriceList($product['name'], $priceOld, $product['types'], $product['quantity']);
    }
        $total=$this->currency->format($this->tax->calculate($total1, $product['tax_class_id'], $this->config->get('config_tax')));
}
else
{
    $total = false;
}

但是我遇到了一些错误,比如

Fatal error: Call to a member function calculate() on null in D:\xampp\htdocs\ramesh\project1\dealer\admin\controller\sale\order.php on line 795

我该如何解决这个错误...?

如果您希望在管理路径中获取产品的总计,您可以使用此代码来实现您的代码:

$total = $this->currency->format($product['total'], $currency_code, $currency_value);

当然要指定自己的$currency_code$currency_value