选择付款方式时,OpenCart在购物车中获取总价


opencart get total price in cart when payment method selected

这是我为opencart自定义的付款方式代码:

<?php
class ControllerPaymentportmanat extends Controller {
    protected function index() {
        $this->data['button_confirm'] = $this->language->get('button_confirm_portmanat');
        $this->data['continue'] = $this->url->link('checkout/success');
        $this->data['order_id'] = $this->session->data['order_id'];
        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/portmanat.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/payment/portmanat.tpl';
        } else {
            $this->template = 'default/template/payment/portmanat.tpl';
        }   
        $this->render();
    }
    public function confirm() {
        $this->load->model('checkout/order');
        $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('portmanat_order_status_id'));
    }
}
?>

如何获取代码的当前大小?我想在我的代码上定义价。

您可以使用 getOrder 并使用存储在会话中的order_id来获取订单信息:

$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

现在您可以使用 $order_info['total'] 获取订单总额