显示我的运营商错误

时间:2016-06-13 08:16:43

标签: php mysql prestashop prestashop-1.6

我创建了一个模块,用于添加通过外部Web服务获得的运营商。数据库的ADDICTION正确完成,并在phpmyadmin中显示载体创建。 但是,屏幕载体未显示安装的载体并打印出以下行错误:

  

警告:strip_tags()期望参数1为字符串,数组在第815行的C:\ xampp \ htdocs \ prestashop \ classes \ db \ Db.php中给出

完整的方法代码是:

public function installCarriers()
    {        
        $id_lang_default = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'));
        $envios = Configuration::get('ENVIOS');
        foreach ($envios as $env) 
        {                
                $carrier = new Carrier();
                $carrier->name = $env->nombreModo;
                $carrier->id_tax_rules_group = 0;
                $carrier->active = TRUE;
                $carrier->deleted = 0;
                foreach (Language::getLanguages(true) as $language)
                   $carrier->delay[(int)$language['id_lang']] = $env->periodo_dia;
                $carrier->shipping_handling = false;
                $carrier->range_behavior = 0;
                $carrier->is_module = true;
                $carrier->is_free = false;
                $carrier->shipping_external = false;
                $carrier->external_module_name = (string)$this->name;
                $carrier->need_range = true;

                if ($carrier->add())
                {
                    // Associate carrier to all groups
                    $groups = Group::getGroups(true);
                    foreach ($groups as $group)
                        Db::getInstance()->insert('carrier_group', array('id_carrier' => (int)$carrier->id, 'id_group' => (int)$group['id_group']));

                    // Create price range
                    $aux1 = intval($env->precioBase);
                    $aux2 = $aux1+1;
                    $rangePrice = new RangePrice();
                    $rangePrice->id_carrier = $carrier->id;
                    $rangePrice->delimiter1 = $aux1;
                    $rangePrice->delimiter2 = $aux2;   
                    $rangePrice->add();

                    // Crear el rango de pesos para el carrier
                    $rangeWeight = new RangeWeight();
                    $rangeWeight->id_carrier = $carrier->id;
                    $rangeWeight->delimiter1 = '0';
                    $rangeWeight->delimiter2 = '10000';
                    $rangeWeight->add();

                    //Calculo del precio incluyendo el IVA (21%)
                    $priceIVA = str_replace(',', '.', $env->precioBase);
                    $priceIVA = (float)$priceIVA + (float)$priceIVA*(float)0.21;

                    // Asociar el carrier a la zona 1 = Europa
                    $zone = Zone::getIdByName('Europe');
                    Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int)$carrier->id, 'id_zone' => (int)$zone));
                    Db::getInstance()->insert('delivery', array('id_carrier' => (int)$carrier->id, 'id_range_price' => (int)$rangePrice->id, 'id_range_weight' => (int)$rangeWeight->id, 'id_zone' => (int)$zone, 'price' => $priceIVA));



                    // Copy the carrier logo
                    copy(dirname(__FILE__).'/views/img/'.$env->urlEmpresa, _PS_SHIP_IMG_DIR_.'/'.(int)$carrier->id.'.jpg');

                }
        }
    }

1 个答案:

答案 0 :(得分:0)

检查对象变量(定义数组中的字段),避免多选值并给出数组而不是字符串值(array => string)。