Php Opencart:如何获取装运方法的代码

Php Opencart:如何获取装运方法的代码,php,opencart,Php,Opencart,我正在开发Opencart的装运模块 我已经回顾了shipping模块模板的源代码,如下所示 但是,我不确定是否要添加新的装运方法,我应该在哪里设置/获取$quote['code']。装运代码在相应装运方法的模型文件中设置,可在中找到 /catalog/model/shipping/your_shipping_name.php OpenCart附带了许多方法,它们将向您展示如何做到这一点。您需要特别查看$quote\u数据变量。值得注意的是,如果你想为你的运输类型提供多种方式,如24小时、

我正在开发Opencart的装运模块

我已经回顾了shipping模块模板的源代码,如下所示



但是,我不确定是否要添加新的装运方法,我应该在哪里设置/获取$quote['code']。装运代码在相应装运方法的模型文件中设置,可在中找到

/catalog/model/shipping/your_shipping_name.php
OpenCart附带了许多方法,它们将向您展示如何做到这一点。您需要特别查看
$quote\u数据
变量。值得注意的是,如果你想为你的运输类型提供多种方式,如24小时、标准配送等,那么它会变得更加复杂。这里有一个例子

                $quote_data['surface'] = array(
                    'code'         => 'royal_mail.surface',
                    'title'        => $title,
                    'cost'         => $cost,
                    'tax_class_id' => $this->config->get('royal_mail_tax_class_id'),
                    'text'         => $this->currency->format($this->tax->calculate($cost, $this->config->get('royal_mail_tax_class_id'), $this->config->get('config_tax')))
                );
这是
royal_mail.php
文件的发送方法(其中之一)。请特别注意代码键如何在
royal_mail
后接
以将其与此特定方法
表面分离。您还会注意到,
surface
$quote\u data
中引号本身的数组键。这是区分不同方法的必要条件。例如,如果您希望将名为
foo
的新配送方法添加到皇家邮政配送方法中,您可以这样做

                $quote_data['foo'] = array(
                    'code'         => 'royal_mail.foo',
                    'title'        => $title,
                    'cost'         => $cost,
                    'tax_class_id' => $this->config->get('royal_mail_tax_class_id'),
                    'text'         => $this->currency->format($this->tax->calculate($cost, $this->config->get('royal_mail_tax_class_id'), $this->config->get('config_tax')))
                );

谢谢。你是我的英雄!