openCart 3 - 如何在结账页面获取总价?

问题描述 投票:0回答:1

我需要了解如何在结帐页面(confirm.php)获取总价加上我自己的价格。 我需要检查总数,如果超过 5K 那么送货服务是免费的,否则送货服务是固定价格的。

$this->$cart->getTotal(); // it returns totals not including coupons
$this->$cart->getSubTotal(); // it returns products totals not including coupons

有谁知道如何获得包括优惠券/代金券在内的总计...?

php sorting opencart-3
1个回答
1
投票
$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 并检查您是否获得了数据,并通过添加这两个数据来计算凭证的总计

© www.soinside.com 2019 - 2024. All rights reserved.