简体   繁体   English

需要Opencart运送方式

[英]Opencart Shipping Method Required

I have created a new shipping module based on the post below 我根据下面的帖子创建了一个新的运输模块

http://forum.opencart.com/viewtopic.php?f=142&t=30226 http://forum.opencart.com/viewtopic.php?f=142&t=30226

The shipping method checks what members group the user is in, and if they then qualify for free delivery based on the cart price. 送货方式检查用户所在的成员组,然后根据购物车价格确定他们是否有资格享受免费送货服务。 All works great, except when you go to the checkout and select the free shipping method it comes back with the error "Warning: Shipping method required!" 一切都很好,除非您去结帐并选择免费送货方式,它会返回错误“警告:需要送货方式!”。

The model for the shipping is below, can anyone shed any light on this? 运输的型号如下,有人可以对此进行说明吗?

<?php
class ModelShippingFreeusergroup extends Model {
    function getQuote($address) {
        $this->language->load('shipping/freeusergroup');

        $customer_group_id = $this->customer->getCustomerGroupId();
        if ($customer_group_id < 1)$customer_group_id = 1;

        $cart_total = $this->cart->getTotal();

        $strQuery = "SELECT * FROM " . DB_PREFIX . "members_delivery " . 
            " WHERE price <= '" . $cart_total . "' AND customer_group_id = '" . $customer_group_id . "' " . 
            " LIMIT 1";
        $query = $this->db->query($strQuery);

        //$ShipArray = array();
        $method_data = array();
        if ($query->num_rows > 0)
        {
            foreach ($query->rows as $result) {
                $quote_data['freeusergroup'] = array(
                    'code'          => 'freeusergroup',
                    'title'         =>  'Free Delivery',
                    'cost'          =>  0.00,
                    'tax_class_id'  => $this->config->get('weight_tax_class_id'),//0,
                    'text'          => $this->currency->format(0.00)
                );

                $method_data = array(
                    'code'          => 'freeusergroup',
                    'title'         => 'Free Delivery',
                    'quote'         => $quote_data,
                    'sort_order'    => $this->config->get('freeusergroup_sort_order'),
                    'error'         => false
                );
            }
        }
        return $method_data;

    }
}
?>

I've managed to fix it, I didn't realize the method data quote data required a . 我设法解决了这个问题,但我没有意识到方法数据引用数据需要使用。 in the code, checking the validate function on the controller pointed me to the fact that the 'code' in the quote data should be 'freeusergroup.freeusergroup' 在代码中,检查控制器上的validate函数使我注意到报价数据中的“代码”应为“ freeusergroup.freeusergroup”

The first part of the code is taken from the method_data, 代码的第一部分取自method_data,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM