英文:
Prestashop- How to add Amount Due in AdminOrdersController.php
问题
我的Prestashop版本是1.7.5
我想要在AdminOrdersController中添加应付金额的值。应付金额可以使用('total_paid_tax_incl' - 'total_paid_real')来计算。
所以我将它修改为这样
'total_paid_tax_incl' - 'total_paid_real' => array(
'title' => $this->trans('Amount Due', array(), 'Admin.Global'),
'align' => 'text-right',
'type' => 'price',
'currency' => true,
'badge_success' => true,
),
但是它会抛出一个错误,警告:遇到非数字值。
尽管'value' 'total_paid_tax_incl'和'total_paid_real'都是decimal(20,6)类型的。
英文:
My Prestashop version is 1.7.5
I wanted to add the amount due value in the AdminOrdersController. Amount due value can be calculated using ('total_paid_tax_incl'-'total_paid_real')
'total_paid_real' => array(
'title' => $this->trans('Real Paid', array(), 'Admin.Global'),
'align' => 'text-right',
'type' => 'price',
'currency' => true,
'badge_success' => true,
),
So I modified it like this
'total_paid_tax_incl'-'total_paid_real' => array(
'title' => $this->trans('Amount Due', array(), 'Admin.Global'),
'align' => 'text-right',
'type' => 'price',
'currency' => true,
'badge_success' => true,
),
But It is throwing an error, Warning: A non-numeric value encountered.
Though both value 'total_paid_tax_incl' & 'total_paid_real' are in decimal(20,6)
Can you guys help me to solve the issue?
答案1
得分: 1
在生成订单列表的SQL查询中,您需要添加一个自定义字段,然后使用该字段。
在AdminOrdersController构造函数中添加以下代码:
$this->_select .= ' a.total_paid_tax_incl-a.total_paid_real as `due_value'`;
就在$this->_select = '<default query>'
之后添加。
这将允许您在定义列表中显示的列时使用due_value
变量:
'due_value' => array(
'title' => $this->trans('Amount Due', array(), 'Admin.Global'),
'align' => 'text-right',
'type' => 'price',
'currency' => true,
'badge_success' => true,
'havingFilter' => true
),
请注意,我添加了havingFilter
参数,因为它不是数据库中的标准字段,而是在运行时创建的。
英文:
You need to add a custom field to the SQL query that generates the order list and then use that field.
In the AdminOrdersController constructor, add
$this->_select .= ' a.total_paid_tax_incl-a.total_paid_real as `due_value`';
Right after $this->_select = '<default query>';
This will allow you to use the due_value
variable when defining the columns displayed in the list
'due_value' => array(
'title' => $this->trans('Amount Due', array(), 'Admin.Global'),
'align' => 'text-right',
'type' => 'price',
'currency' => true,
'badge_success' => true,
'havingFilter' => true
),
Note that I added the havingFilter parameter, because it is not a standard field in the database, but created "on the fly".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论