Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么客户';s的配送选项与Zen Cart 1.5中的数据库或模块设置不匹配?_Php_Shopping Cart_Zen Cart - Fatal编程技术网

Php 为什么客户';s的配送选项与Zen Cart 1.5中的数据库或模块设置不匹配?

Php 为什么客户';s的配送选项与Zen Cart 1.5中的数据库或模块设置不匹配?,php,shopping-cart,zen-cart,Php,Shopping Cart,Zen Cart,客户机在Zen Cart 1.5中有一个自定义装运模块。昨天,我修改了模块,使其具有区域意识(他们希望原始模块适用于美国,并对非美国订单的副本进行调整) 现在,我在该模块中只有一个装运选项,而不是配置的四个。区域意识似乎正在发挥作用(我的测试订单显示了显示的选项的美国费用,而不是国际费用),但只有第一个选项显示出来 以下是模块的代码: /*include functions/functions_categories.pnp for zen_product_in_category method *

客户机在Zen Cart 1.5中有一个自定义装运模块。昨天,我修改了模块,使其具有区域意识(他们希望原始模块适用于美国,并对非美国订单的副本进行调整)

现在,我在该模块中只有一个装运选项,而不是配置的四个。区域意识似乎正在发挥作用(我的测试订单显示了显示的选项的美国费用,而不是国际费用),但只有第一个选项显示出来

以下是模块的代码:

/*include functions/functions_categories.pnp for zen_product_in_category method
*/
class tfn
{
    var $code, $title, $description, $icon, $enabled, $types;

    // class constructor
    function tfn() {
        global $order, $db, $types, $fees;

        $this->code = 'tfn';
        $this->title = MODULE_SHIPPING_TFN_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_TFN_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_TFN_SORT_ORDER;
        $this->icon = '';
        $this->tax_class = MODULE_SHIPPING_TFN_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_TFN_TAX_BASIS;

        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_TFN_STATUS == 'True') ? true : false);
        }

        if (($this->enabled == true) && ((int)MODULE_SHIPPING_TFN_ZONE > 0)) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TFN_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
            while (!$check->EOF) {
                if ($check->fields['zone_id'] < 1) {
                    $check_flag = true;
                    break;
                } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
                    $check_flag = true;
                    break;
                }
                $check->MoveNext();
            }

            if ($check_flag == false) {
                $this->enabled = false;
            }
        }

        $types = array(
            'STD'  => 'Standard',
            'FXH'  => 'USPS Priority Mail',
            'FXES' => 'USPS Express Mail',
            'FXSO' => 'FedEx Overnight'
        );
        // 'FAM' => 'Foreign Airmail',
        // 'FXG' => 'USPS Priority Mail with Delivery Confirmation',
        // 'FX2D' => 'FedEx 2nd Day',

        $fees = array(
            'STD'  => '0.00',
            'FXH'  => '4.50',
            'FXES' => '17.50',
            'FXSO' => '28.00'
        );
        // 'FAM' => '15.00',
        // 'FXG' => '5.50',
        // 'FX2D' => '10.00',
    }

    // class methods
    function quote($method = '') {
        global $order, $types, $fees;

        $methods = array();

        $this->quotes = array(
            'id'     => $this->code,
            'module' => $this->title
        );

        if (($method == '') || (!isset($method))) {
            foreach ($fees as $type => $cost) {
                $methods[] = array(
                    'id'    => $type,
                    'title' => $types[$type],
                    'cost'  => $this->_calculateBaseCost() + $cost
                );
            }
        } else {
            $cost = $fees[$method];
            $methods[] = array(
                'id'    => $method,
                'title' => $types[$method],
                'cost'  => $this->_calculateBaseCost() + $cost
            );
        }

        $this->quotes['methods'] = $methods;
        if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }

        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);

        return $this->quotes;
    }

    function _calculateBaseCost() {
        global $db, $shipping_cost;

        $total_count = $_SESSION['cart']->count_contents();
        $total_count = $total_count - $_SESSION['cart']->free_shipping_items();
        $foreign_charge = $this->_additionalForeignCharge();
        $shipping_cost = ($total_count * (MODULE_SHIPPING_TFN_BASE_COST + $foreign_charge));

        return $shipping_cost;
    }

    function _additionalForeignCharge() {
        global $db, $order;

        $foreign_charge = 0;

        $dest_country = $order->delivery['country']['iso_code_2'];

        if ($dest_country != 'US') {
            $foreign_charge = MODULE_SHIPPING_TFN_FOREIGN_COST;
        }

        return $foreign_charge;
    }

    function check() {
        global $db;
        if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TFN_STATUS'");
            $this->_check = $check_query->RecordCount();
        }

        return $this->_check;
    }

    function install() {
        global $db;
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Item Shipping', 'MODULE_SHIPPING_TFN_STATUS', 'True', 'Do you want to offer per item rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_TFN_BASE_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', '6', '0', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Additional Foreign Shipping Cost', 'MODULE_SHIPPING_TFN_FOREIGN_COST', '4.00', 'The additional foreign shipping cost will be multiplied by the number of items and added to the base cost.', '6', '0', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TFN_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TFN_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TFN_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TFN_SHIPPING_TYPES', '0', 'Code and Name for each kind of shipping offered.', '6', '0', now())");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Shipping Methods: <br />Standard, Foreign Airmail, FedEx Home Delivery, FedEx Ground, FedEx Express Saver, FedEx 2nd Day, FedEx Standard Overnight', 'MODULE_SHIPPING_TFN_TYPES', 'STD, FAM, FXHD, FXG, FXES, FX2D, FXSO', 'Select the TFN services to be offered.', '6', '13', 'zen_cfg_select_multioption(array(\'STD\',\'FAM\',\'FXHD\', \'FXG\', \'FXES\', \'FX2D\', \'FXSO\'), ', now() )");
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TFN_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    }

    function remove() {
        global $db;
        $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
        return array(
            'MODULE_SHIPPING_TFN_STATUS', 'MODULE_SHIPPING_TFN_BASE_COST',
            'MODULE_SHIPPING_TFN_FOREIGN_COST', 'MODULE_SHIPPING_TFN_TAX_CLASS',
            'MODULE_SHIPPING_TFN_TAX_BASIS', 'MODULE_SHIPPING_TFN_SORT_ORDER',
            'MODULE_SHIPPING_TFN_TYPES', 'MODULE_SHIPPING_TFN_ZONE'
        );
    }
}
?>
直接在数据库中更新_SHIPPING_TYPES设置(例如,将其设置为1而不是0)似乎不会改变任何东西。我找不到任何调用此设置的代码


Zen Cart在哪里确定运输选项?我怎样才能让它显示我想要的呢?

当装运模块不显示时,通常是因为装运选项的文件命名和文件结构错误。你知道你必须制作50个不同的文件才能在zen cart中添加一个页面吗

请仔细按照此处的说明进行操作,并确保您的命名约定以及文件位置都是正确的


好吧,这有点可笑。如果这个问题无法回答,请至少有人评论一下,让我知道遗漏了哪些信息,这将使它可以回答?是不是变得如此之大以至于赏金无人认领?我将在本周尝试关注这个问题!到本周末,将提供复兴徽章。:)你能把函数install()粘贴到代码中,这样我就可以在本地安装上进行测试了吗?顺便说一句,看起来定制模块实际上只是对一些应该而且可能很简单的事情大惊小怪。例如,您可以将固定费率模块克隆7次,总共有8个固定费率模块,并将每个模块用于您的组合(4个用于美国,4个用于国际)…我已还原install()函数。谢谢你看。有可能自定义模块有些过分,但在我接管时它已经存在了;我只是想让它工作区意识到。谢谢你的回答!我不再做这个项目了,所以我无法检查它是否有效,但希望其他人能找到他们需要参考的问题。搜索通常为我做。
mysql> select configuration_value, configuration_key from configuration where configuration_key LIKE 'MODULE_SHIPPING_%_TYPES';
+-----------------------+----------------------------------------+
| configuration_value   | configuration_key                      |
+-----------------------+----------------------------------------+
| 0                     | MODULE_SHIPPING_TFN_INT_SHIPPING_TYPES | 
| STD                   | MODULE_SHIPPING_TFN_INT_TYPES          | 
| 0                     | MODULE_SHIPPING_TFN_SHIPPING_TYPES     | 
| STD, FXHD, FXES, FXSO | MODULE_SHIPPING_TFN_TYPES              | 
+-----------------------+----------------------------------------+
4 rows in set (0.00 sec)