openCart 3 - 如何在结帐页面获得总价?
openCart 3 - How to get total price at checkout page?
我需要了解如何在结帐页面 (confirm.php) 上获得总价加上我自己的价格。
我需要查看总数,如果超过 5K 则送货服务是免费的,否则送货服务是固定价格。
$this->$cart->getTotal(); // it returns totals not including coupons
$this->$cart->getSubTotal(); // it returns products totals not including coupons
有谁知道如何计算总计 coupons/vouchers...?
$this->load->model('setting/extension');
$sort_order = array();
$results = $this->model_setting_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get('total_' . $result['code'] . '_status')) {
$this->load->model('extension/total/' . $result['code']);
// We have to put the totals in an array so that they pass by reference.
$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
}
}
$sort_order = array();
foreach ($totals as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $totals);
在 $totals 中,您将拥有所有总计数据,您可以使用它通过计算数组值来根据需要获得总计
这个你会在confirm.php
只需打印 $totals 并检查,然后您就得到了数据,并通过添加两个数据来计算凭证的总数
我需要了解如何在结帐页面 (confirm.php) 上获得总价加上我自己的价格。 我需要查看总数,如果超过 5K 则送货服务是免费的,否则送货服务是固定价格。
$this->$cart->getTotal(); // it returns totals not including coupons
$this->$cart->getSubTotal(); // it returns products totals not including coupons
有谁知道如何计算总计 coupons/vouchers...?
$this->load->model('setting/extension');
$sort_order = array();
$results = $this->model_setting_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get('total_' . $result['code'] . '_status')) {
$this->load->model('extension/total/' . $result['code']);
// We have to put the totals in an array so that they pass by reference.
$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
}
}
$sort_order = array();
foreach ($totals as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $totals);
在 $totals 中,您将拥有所有总计数据,您可以使用它通过计算数组值来根据需要获得总计
这个你会在confirm.php
只需打印 $totals 并检查,然后您就得到了数据,并通过添加两个数据来计算凭证的总数