public function install() { if (!extension_loaded('soap') || !class_exists('SoapClient')) { $this->_errors[] = $this->l('SOAP extension should be enabled on your server to use this module.'); return false; } /* Check SoapClient extension before cotinues */ if ($this->active == 1) { return false; } if (!parent::install() || !$this->registerHook('adminOrder') || !$this->registerHook('orderDetail') || !$this->registerHook('extraCarrier') || !$this->registerHook('updateCarrier') || !$this->registerHook('displayOrderConfirmation') || !$this->registerHook('header') || !$this->registerHook('backOfficeHeader')) { return false; } if (version_compare(_PS_VERSION_, '1.5', '<')) { if (!$this->registerHook('orderDetailDisplayed')) { return false; } } else { if (!$this->registerHook('displayOrderDetail')) { return false; } } if (!$this->createDatabases() || !$this->createCarriers() || !$this->createAdminTab() || !$this->installSeurCashOnDelivery()) { $this->uninstall(); return false; } return true; }
public function install() { $hooks = array('paymentTop', 'adminOrder', 'backOfficeHeader'); $database_table_install_error = false; $price_rules_data_intall_error = false; if (!extension_loaded('soap')) { $this->_errors[] = $this->l('Soap Client library is not installed'); return false; } if (!parent::install()) { return false; } if ($this->ps_14) { $hooks[] = 'updateCarrier'; } if (!$this->registerHooks($hooks)) { parent::uninstall(); return false; } require_once _DPDGROUP_SQL_DIR_ . 'install.php'; if ($database_table_install_error) { $this->_errors[] = $this->l('Could not install database tables'); return false; } if ($price_rules_data_intall_error) { $this->dropTables(); $this->_errors[] = $this->l('Could not add default price rules data'); parent::uninstall(); return false; } return true; }
public function install() { if (!parent::install()) { return false; } $carrier = new Carrier(null, $this->context->language->id); $carrier->name = 'My carrier'; $carrier->active = 1; $carrier->isFree = false; $carrier->url = ''; $carrier->shipping_handling = false; $carrier->shipping_method = 0; $carrier->max_width = 0; $carrier->max_height = 0; $carrier->max_depth = 0; $carrier->max_weight = 0; $carrier->grade = 0; $carrier->external_module_name = 'mycarrier'; $carrier->is_module = true; $carrier->deleted = false; $carrier->delay = 'string'; if (!$carrier->add()) { return false; } if (!Configuration::updateValue('MY_CARRIER_ID', $carrier->id)) { return false; } return true; }
function install() { if (parent::install() == false or $this->registerHook('updateCarrier') == false or $this->registerHook('extraCarrier') == false or $this->registerHook('beforeCarrier') == false) { return false; } $this->installCarriers(); return true; }
/** * Don't forget to create update methods if needed: * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update */ public function install() { if (extension_loaded('curl') == false) { $this->_errors[] = $this->l('You have to enable the cURL extension on your server to install this module'); return false; } $carrier = $this->addCarrier(); $this->addZones($carrier); $this->addGroups($carrier); $this->addRanges($carrier); Configuration::updateValue('EGDELIVERY_LIVE_MODE', false); return parent::install() && $this->registerHook('header') && $this->registerHook('backOfficeHeader') && $this->registerHook('updateCarrier') && $this->registerHook('actionCarrierProcess'); }
public function install() { if (!parent::install()) { return false; } if (!$this->registerHook('actionCarrierUpdate') || !$this->registerHook('displayCarrierList') || !$this->registerHook('displayAdminOrder')) { return false; } $sql_file = dirname(__FILE__) . '/install/install.sql'; if (!$this->loadSQLFile($sql_file)) { return false; } if (!$this->installCarriers()) { return false; } return true; }
public function install() { // Install SQL include dirname(__FILE__) . '/sql-install.php'; foreach ($sql as $s) { if (!Db::getInstance()->Execute($s)) { return false; } } // Install Module if (!parent::install() or !$this->registerHook('updateCarrier') or !$this->registerHook('orderDetailDisplayed') or !$this->registerHook('adminOrder') or !$this->registerHook('extraCarrier') or !$this->registerHook('newOrder')) { return false; } if (file_exists('../modules/' . $this->_moduleName . '/serviceBase.xml')) { $serviceList = simplexml_load_file('../modules/' . $this->_moduleName . '/serviceBase.xml'); if ($serviceList == false) { return false; } } foreach ($serviceList as $k => $v) { $carrierConfig = array('name' => $v->name, 'id_tax_rules_group' => 0, 'deleted' => $v->option == 'JS' ? 1 : 0, 'shipping_handling' => false, 'range_behavior' => 0, 'delay' => array('fr' => $v->descriptionfr, 'en' => $v->description), 'id_zone' => 1, 'is_module' => true, 'shipping_external' => true, 'external_module_name' => $this->_moduleName, 'need_range' => true, 'active' => true); $id_carrier = $this->installExternalCarrier($carrierConfig); Configuration::updateValue('TNT_CARRIER_' . $v->option . '_ID', (int) $id_carrier); Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'tnt_carrier_option` (`option`, `id_carrier`) VALUES ("' . pSQL($v->option) . '", "' . (int) $id_carrier . '")'); if (substr($v->option, 1, 1) == 'Z') { copy(dirname(__FILE__) . '/logo_24h_chezmoi_RVB.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $id_carrier . '.jpg'); } else { if (substr($v->option, 1, 1) == 'D') { copy(dirname(__FILE__) . '/logo_24h_RELAISCOLIS_RVB.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $id_carrier . '.jpg'); } else { if (strlen($v->option) == 1 || substr($v->option, 1, 1) == 'S') { copy(dirname(__FILE__) . '/logo_24h_ENTREPRISE.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $id_carrier . '.jpg'); } else { copy(dirname(__FILE__) . '/carrier.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg'); } } } } Configuration::updateValue('TNT_CARRIER_TOKEN', md5(rand())); return true; }
public function install() { if (!parent::install()) { return false; } if (!$this->registerHook('actionCarrierUpdate')) { return false; } if (!$this->createDatabaseTable()) { return false; } Configuration::updateValue('FRAKTGUIDE_EDI', true); Configuration::updateValue('FRAKTGUIDE_FORSIKRING', true); Configuration::updateValue('FRAKTGUIDE_FRA_POSTNUMMER', ''); Configuration::updateValue('FRAKTGUIDE_CARRIER_IDS', ''); Configuration::updateValue('FRAKTGUIDE_CREATED_CARRIER_IDS', ''); Configuration::updateValue('FRAKTGUIDE_PRODUCTS', 'SERVICEPAKKE'); Configuration::updateValue('FRAKTGUIDE_A_POST_MAX_PRIS', ''); Configuration::updateValue('FRAKTGUIDE_DEBUG_MODE', false); Configuration::updateValue('FRAKTGUIDE_ID_TAX_RULES_GROUP', 1); return true; }
public function install() { global $cookie; if (!parent::install() or !Configuration::updateValue('SOCOLISSIMO_ID', NULL) or !Configuration::updateValue('SOCOLISSIMO_KEY', NULL) or !Configuration::updateValue('SOCOLISSIMO_URL', 'https://ws.colissimo.fr/pudo-fo/storeCall.do') or !Configuration::updateValue('SOCOLISSIMO_PREPARATION_TIME', 1) or !Configuration::updateValue('SOCOLISSIMO_OVERCOST', 3.6) or !$this->registerHook('extraCarrier') or !$this->registerHook('AdminOrder') or !$this->registerHook('updateCarrier') or !$this->registerHook('newOrder') or !Configuration::updateValue('SOCOLISSIMO_SUP_URL', 'http://ws.colissimo.fr/supervision-pudo/supervision.jsp') or !Configuration::updateValue('SOCOLISSIMO_SUP', true)) { return false; } //creat config table in database $sql = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'socolissimo_delivery_info` ( `id_cart` int(10) NOT NULL, `id_customer` int(10) NOT NULL, `delivery_mode` varchar(3) NOT NULL, `prid` text(10) NOT NULL, `prname` varchar(64) NOT NULL, `prfirstname` varchar(64) NOT NULL, `prcompladress` text NOT NULL, `pradress1` text NOT NULL, `pradress2` text NOT NULL, `pradress3` text NOT NULL, `pradress4` text NOT NULL, `przipcode` text(10) NOT NULL, `prtown` varchar(64) NOT NULL, `cephonenumber` varchar(10) NOT NULL, `ceemail` varchar(64) NOT NULL, `cecompanyname` varchar(64) NOT NULL, `cedeliveryinformation` text NOT NULL, `cedoorcode1` varchar(10) NOT NULL, `cedoorcode2` varchar(10) NOT NULL, PRIMARY KEY (`id_cart`,`id_customer`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'; if (!Db::getInstance()->Execute($sql)) { return false; } //add carrier in back office if (!$this->createSoColissimoCarrier($this->_config)) { return false; } return true; }
public function preInstall() { if (!self::checkPSVersion()) { $this->context->controller->errors[] = 'This module is incompatible with your Prestashop installation. You can visit the <a href = "http://www.chronopost.fr/transport-express/livraison-colis/accueil/produits-tarifs/expertise-sectorielle/e-commerce/plateformes">Chronopost.fr </a>website to download a comptible version.'; return false; } // Check for SOAP if (!extension_loaded('soap')) { $this->context->controller->errors[] = $this->l('The SOAP extension is not available or configured on the server ; The module will not work without this extension ! Please contact your host to activate it in your PHP installation.'); return false; } if (!parent::install()) { return false; } // Admin tab if (!$this->_adminInstall()) { return false; } // register hooks if (!$this->registerHook('extraCarrier') || !$this->registerHook('updateCarrier') || !$this->registerHook('newOrder') || !$this->registerHook('header') || !$this->registerHook('backOfficeHeader') || !$this->registerHook('adminOrder')) { return false; } return true; }
public function install() { $carrier_config = array(0 => array('name' => 'Courier service', 'type' => 'carrier', 'id_tax_rules_group' => 0, 'active' => true, 'deleted' => false, 'shipping_handling' => false, 'range_behavior' => false, 'shipping_external' => true, 'need_range' => true, 'delay' => array('lv' => 'Saņemiet sūtījumu tieši rokās.', 'lt' => 'Gaukite savo siuntą tiesiai į rankas.', Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')) => 'Receive your shipment right in your hands.'), 'id_zone' => 1, 'is_module' => true, 'external_module_name' => self::$module_name, 'is_free' => false, 'grade' => false, 'ranges' => array(array('delimiter1' => 0.0, 'delimiter2' => BalticodeDpdCarrierCourier::$maxWeight, 'price' => 7.99)), 'max_weight' => BalticodeDpdCarrierCourier::$maxWeight, 'max_width' => BalticodeDpdCarrierCourier::$maxLength, 'max_height' => BalticodeDpdCarrierCourier::$maxLength, 'max_depth' => BalticodeDpdCarrierCourier::$maxLength), 1 => array('name' => 'Pickup and delivery points', 'type' => 'pickup', 'id_tax_rules_group' => 0, 'active' => true, 'deleted' => false, 'shipping_handling' => false, 'range_behavior' => false, 'shipping_external' => true, 'need_range' => true, 'delay' => array('lv' => 'Jūs varat izbaudīt sūtījuma saņemšanas tepat aiz stūra ērtību.', 'lt' => 'Jūs galite naudotis patogiu pirkinių atsiėmimu Jums patogioje vietoje.', Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')) => 'You can enjoy the convenience of picking up a parcel just around the corner.'), 'id_zone' => 1, 'is_module' => true, 'external_module_name' => self::$module_name, 'is_free' => false, 'grade' => false, 'ranges' => array(array('delimiter1' => 0.0, 'delimiter2' => BalticodeDpdCarrierPickUp::$maxWeight, 'price' => 2.8)), 'max_weight' => BalticodeDpdCarrierPickUp::$maxWeight, 'max_width' => BalticodeDpdCarrierPickUp::$maxLength, 'max_height' => BalticodeDpdCarrierPickUp::$maxLength, 'max_depth' => BalticodeDpdCarrierPickUp::$maxLength)); if (!DpdCarrierOptions::installDb()) { return false; } $id_carrier1 = $this->installExternalCarrier($carrier_config[0]); $id_carrier2 = $this->installExternalCarrier($carrier_config[1]); Configuration::updateValue('COURIERSERVICE_CARRIER_ID', (int) $id_carrier1); Configuration::updateValue('DELIVERYPOINTS_CARRIER_ID', (int) $id_carrier2); if (!parent::install() || !Configuration::updateValue('COURIERSERVICE_OVERCOST', '') || !Configuration::updateValue('DELIVERYPOINTS_OVERCOST', '') || !$this->registerHook('updateCarrier') || !$this->registerHook('displayCarrierList') || !$this->registerHook('displayBackOfficeHeader') || !$this->registerHook('displayOrderConfirmation') || !DpdDeliveryPoints::installDb() || !DpdOrderOptions::installDb() || !DpdDeliveryPrice::installDb()) { // || !$this->addBulkActionButtons() //Bulk Action buttons // //Using this only if Overwrite using already other model! return false; } $tab = new Tab(); $tab->class_name = 'AdminCallcarrier'; $tab->module = self::$module_name; $tab->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $this->l('AdminCallcarrier'); $tab->id_parent = -1; $tab->position = 1; $tab->save(); return true; }
/** * Don't forget to create update methods if needed: * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update */ public function install() { if (extension_loaded('curl') == false) { $this->_errors[] = $this->l('You have to enable the cURL extension on your server to install this module'); return false; } include dirname(__FILE__) . '/sql/install.php'; $carriers = Carrier::getCarriers($this->context->language->id); foreach ($carriers as $carrier) { $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'hf_free_shipping_pro_carriers` SET `id_carrier` = ' . $carrier['id_carrier'] . ', `show_not_free` = 1, `show_free` = 1'; if (!Db::getInstance()->execute($sql)) { return false; } $carrier_to_update = new Carrier($carrier['id_carrier']); $carrier_to_update->need_range = 1; $carrier_to_update->shipping_external = true; $carrier_to_update->external_module_name = $this->name; $carrier_to_update->save(); } return parent::install() && $this->registerHook('header') && $this->registerHook('backOfficeHeader') && $this->registerHook('updateCarrier') && $this->registerHook('displayAdminProductsExtra') && $this->registerHook('actionProductSave') && $this->registerHook('displayBackOfficeCategory') && $this->registerHook('displayBackOfficeFooter') && $this->registerHook('shoppingCart') && $this->registerHook('displayShoppingCartFooter'); }
public function install() { // Install SQL include dirname(__FILE__) . '/sql-install.php'; foreach ($sql as $s) { if (!Db::getInstance()->execute($s)) { return false; } } // Install Carriers $this->installCarriers(); // Install Module if (!parent::install() or !$this->registerHook('updateCarrier')) { return false; } return true; }
public function install() { if (parent::install() == false) { return false; } require_once _PS_MODULE_DIR_ . $this->name . '/PrestahostModuleInstall.php'; $install = new PrestahostModuleInstall($this); if (!$install->addState('OS_ULOZENKA_DORUCENO', array('en' => 'Ulozenka delivered', 'cs' => 'Ulozenka doručeno'), '#FFD5D5', 0, 1)) { return false; } $carrierConfig = array(0 => array('name' => 'Uloženka', 'id_tax_rules_group' => 0, 'active' => true, 'deleted' => 0, 'shipping_handling' => false, 'shipping_method' => 2, 'range_behavior' => 0, 'delay' => array('cs' => 'Dva dny'), 'grade' => 5, 'is_module' => true, 'shipping_external' => true, 'external_module_name' => 'ulozenka', 'need_range' => true)); if ($id_carrier = $install->installExternalCarrier($carrierConfig[0])) { Configuration::updateValue($this->uppername . '_CARRIER_ID', $id_carrier); } else { return false; } if (!$install->installModuleTab('AdminOrderUlozenka', 'Uloženka', 'AdminOrders')) { return false; } if (!$install->installSql()) { return false; } if (!$install->addMailTemplate()) { return false; } Configuration::updateValue($this->uppername . '_CARRIER_ID', (int) $id_carrier); Configuration::updateValue($this->uppername . '_LOGO_TYPE', 1); $this->registerHook('actionCarrierUpdate'); $this->registerHook('displayBeforeCarrier'); $this->registerHook('displayCarrierList'); $this->registerHook('actionCarrierProcess'); $this->registerHook('displayHeader'); $this->registerHook('displayOrderConfirmation'); $path = _PS_MODULE_DIR_ . $this->name . '/tpl/'; if (is_writable($path)) { $version = self::getVersion(); if ($version == 150) { $source_file = 'form_154.tpl'; } elseif ($version == 155) { $source_file = 'form_156.tpl'; } else { // 160 $source_file = 'form_16.tpl'; } if (file_exists($path . $source_file)) { $targetfile = $path . 'form.tpl'; if (file_exists($targetfile)) { unlink($targetfile); } copy($path . $source_file, $targetfile); } } return true; }
/** * install dejala module */ public function install() { if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) { return false; } elseif (!($sql = file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))) { return false; } $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); $sql = preg_split("/;\\s*[\r\n]+/", $sql); foreach ($sql as $query) { if (!empty($query)) { if (!Db::getInstance()->Execute(trim($query))) { return false; } } } if (parent::install() == false or $this->registerHook('updateOrderStatus') == false or $this->registerHook('extraCarrier') == false or $this->registerHook('processCarrier') == false or $this->registerHook('orderDetailDisplayed') == false or $this->registerHook('PDFInvoice') == false) { return false; } $this->dejalaConfig = new DejalaConfig(); if (!$this->dejalaConfig->saveConfig()) { return false; } // Cleanup pre-existing Dejala Carriers (in case the module had previously been tested and not removed cleanly) while (!is_null($carrier = DejalaCarrierUtils::getCarrierByName($this->name, true))) { $carrier->deleted = 1; if (!$carrier->update()) { return false; } } DejalaCarrierUtils::createDejalaCarrier($this->dejalaConfig); return true; }
public function install() { if (!parent::install() || !Configuration::updateValue('SOCOLISSIMO_ID', null) || !Configuration::updateValue('SOCOLISSIMO_KEY', null) || !Configuration::updateValue('SOCOLISSIMO_URL', 'ws.colissimo.fr/pudo-fo-frame/storeCall.do') || !Configuration::updateValue('SOCOLISSIMO_URL_MOBILE', 'ws-mobile.colissimo.fr/') || !Configuration::updateValue('SOCOLISSIMO_PREPARATION_TIME', 1) || !Configuration::updateValue('SOCOLISSIMO_EXP_BEL', true) || !Configuration::updateValue('SOCOLISSIMO_COST_SELLER', false) || !Configuration::updateValue('SOCOLISSIMO_OVERCOST', 3.6) || !Configuration::updateValue('SOCOLISSIMO_SUP_URL', 'ws.colissimo.fr/supervision-pudo-frame/supervision.jsp') || !Configuration::updateValue('SOCOLISSIMO_SUP_BELG', true) || !Configuration::updateValue('SOCOLISSIMO_SUP', true) || !Configuration::updateValue('SOCOLISSIMO_USE_FANCYBOX', false) || !Configuration::updateValue('SOCOLISSIMO_USE_IFRAME', true) || !$this->registerHook('extraCarrier') || !$this->registerHook('AdminOrder') || !$this->registerHook('updateCarrier') || !$this->registerHook('newOrder') || !$this->registerHook('paymentTop') || !$this->registerHook('backOfficeHeader')) { return false; } //creat config table in database $sql = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'socolissimo_delivery_info` ( `id_cart` int(10) NOT NULL, `id_customer` int(10) NOT NULL, `delivery_mode` varchar(3) NOT NULL, `prid` text(10) NOT NULL, `prname` varchar(64) NOT NULL, `prfirstname` varchar(64) NOT NULL, `prcompladress` text NOT NULL, `pradress1` text NOT NULL, `pradress2` text NOT NULL, `pradress3` text NOT NULL, `pradress4` text NOT NULL, `przipcode` text(10) NOT NULL, `prtown` varchar(64) NOT NULL, `cecountry` varchar(10) NOT NULL, `cephonenumber` varchar(32) NOT NULL, `ceemail` varchar(64) NOT NULL, `cecompanyname` varchar(64) NOT NULL, `cedeliveryinformation` text NOT NULL, `cedoorcode1` varchar(10) NOT NULL, `cedoorcode2` varchar(10) NOT NULL, `codereseau` varchar(3) NOT NULL, `cename` varchar(64) NOT NULL, `cefirstname` varchar(64) NOT NULL, `lotacheminement` varchar(64) NOT NULL, `distributionsort` varchar(64) NOT NULL, `versionplantri` text(10) NOT NULL, PRIMARY KEY (`id_cart`,`id_customer`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'; if (!Db::getInstance()->execute($sql)) { return false; } if (!version_compare(_PS_VERSION_, '1.5', '<')) { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } } if (!Configuration::updateValue('SOCOLISSIMO_VERSION', $this->version)) { return false; } // Add carrier in back office if (!$this->createSoColissimoCarrier($this->config)) { return false; } // add carrier for cost seller if (!$this->createSoColissimoCarrierSeller($this->config)) { return false; } return true; }
public function install() { if (!extension_loaded('soap')) { $this->_errors[] = $this->l('Soap Client lib is not installed'); return false; } $sql = ' CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . _DPDPOLAND_PRICE_RULE_DB_ . '` ( `id_csv` int(11) NOT NULL AUTO_INCREMENT, `id_shop` int(11) NOT NULL, `date_add` datetime DEFAULT NULL, `date_upd` datetime DEFAULT NULL, `iso_country` varchar(255) NOT NULL, `weight_from` varchar(255) NOT NULL, `weight_to` varchar(255) NOT NULL, `parcel_price` float NOT NULL, `cod_price` varchar(255) NOT NULL, `id_carrier` varchar(11) NOT NULL, PRIMARY KEY (`id_csv`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . _DPDPOLAND_PAYER_NUMBERS_DB_ . '` ( `id_dpdpoland_payer_number` int(11) NOT NULL AUTO_INCREMENT, `id_shop` int(11) NOT NULL, `payer_number` varchar(255) NOT NULL, `name` varchar(255) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_dpdpoland_payer_number`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . _DPDPOLAND_COUNTRY_DB_ . '` ( `id_dpdpoland_country` int(11) NOT NULL AUTO_INCREMENT, `id_shop` int(11) NOT NULL, `id_country` int(11) NOT NULL, `enabled` tinyint(1) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_dpdpoland_country`,`id_shop`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE `' . _DB_PREFIX_ . _DPDPOLAND_MANIFEST_DB_ . '` ( `id_manifest` int(11) NOT NULL AUTO_INCREMENT, `id_manifest_ws` int(11) NOT NULL, `id_package_ws` int(11) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_manifest`), UNIQUE KEY `id_manifest_ws` (`id_manifest_ws`,`id_package_ws`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '` ( `id_package` int(11) NOT NULL AUTO_INCREMENT, `id_package_ws` int(11) NOT NULL, `id_order` int(10) NOT NULL, `sessionId` int(11) NOT NULL, `sessionType` varchar(50) NOT NULL, `payerNumber` varchar(255) NOT NULL, `id_address_sender` int(10) NOT NULL, `id_address_delivery` int(10) NOT NULL, `cod_amount` decimal(17,2) DEFAULT NULL, `declaredValue_amount` decimal(17,2) DEFAULT NULL, `ref1` varchar(255) DEFAULT NULL, `ref2` varchar(255) DEFAULT NULL, `additional_info` text, `labels_printed` tinyint(1) NOT NULL DEFAULT "0", `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_package`), UNIQUE KEY `id_package_ws` (`id_package_ws`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . _DPDPOLAND_PARCEL_DB_ . '` ( `id_parcel` int(11) NOT NULL, `id_package_ws` int(11) NOT NULL, `waybill` varchar(50) NOT NULL, `content` text NOT NULL, `weight` decimal(20,6) NOT NULL, `height` decimal(20,6) NOT NULL, `length` decimal(20,6) NOT NULL, `width` decimal(20,6) NOT NULL, `number` int(5) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_parcel`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . _DPDPOLAND_CARRIER_DB_ . '` ( `id_dpdpoland_carrier` int(10) NOT NULL AUTO_INCREMENT, `id_carrier` int(10) NOT NULL, `id_reference` int(10) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_dpdpoland_carrier`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $sql = ' CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . _DPDPOLAND_PARCEL_PRODUCT_DB_ . '` ( `id_parcel_product` int(10) NOT NULL AUTO_INCREMENT, `id_parcel` int(11) NOT NULL, `id_product` int(10) NOT NULL, `id_product_attribute` int(10) NOT NULL, `name` varchar(255) NOT NULL, `weight` decimal(20,6) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_parcel_product`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8'; if (!Db::getInstance()->execute($sql)) { return false; } $current_date = date('Y-m-d H:i:s'); $shops = Shop::getShops(); foreach (array_keys($shops) as $id_shop) { if (!$this->saveCSVRule((int) $id_shop, 'PL', '0', '0.5', '0', '', _DPDPOLAND_STANDARD_ID_, $current_date, $current_date) || !$this->saveCSVRule((int) $id_shop, 'PL', '0', '0.5', '0', '0', _DPDPOLAND_STANDARD_COD_ID_, $current_date, $current_date) || !$this->saveCSVRule((int) $id_shop, 'GB', '0', '0.5', '0', '', _DPDPOLAND_CLASSIC_ID_, $current_date, $current_date) || !$this->saveCSVRule((int) $id_shop, '*', '0', '0.5', '0', '', _DPDPOLAND_CLASSIC_ID_, $current_date, $current_date)) { return false; } } if (!parent::install() || !$this->registerHook('adminOrder') || !$this->registerHook('paymentTop')) { return false; } /** * this hook is needed only in PS 1.4 * used to track DpdPoland carriers references * higher versions than 1.4 alredy have this functionality */ if (version_compare(_PS_VERSION_, '1.5', '<') && !$this->registerHook('updateCarrier')) { return false; } require_once _DPDPOLAND_CONTROLLERS_DIR_ . 'countryList.controller.php'; if (!DpdPolandCountryListController::disableDefaultCountries()) { return false; } return true; }
public function install() { if (parent::install()) { foreach ($this->hooks as $hook) { if (!$this->registerHook($hook)) { return false; } } $sql_file = dirname(__FILE__) . '/install/install.sql'; if (!$this->loadSQLFile($sql_file)) { return false; } // Function for creating new currier. if (!$this->createCarriers('(viser leveringstid i dag)')) { return false; } return true; } return false; }
/** * install dejala module */ public function install() { if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) { return false; } elseif (!($sql = file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))) { return false; } $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); $sql = preg_split("/;\\s*[\r\n]+/", $sql); foreach ($sql as $query) { if (!empty($query)) { if (!Db::getInstance()->Execute(trim($query))) { return false; } } } if (parent::install() == false or $this->registerHook('updateOrderStatus') == false or $this->registerHook('extraCarrier') == false or $this->registerHook('processCarrier') == false) { return false; } $this->dejalaConfig = new DejalaConfig(); if (!$this->dejalaConfig->saveConfig()) { return false; } DejalaCarrierUtils::createDejalaCarrier($this->dejalaConfig); return true; }
public function install() { // ID нашей несчастной почты в системе $idCarrier = $this->installCarrier(); $res = false; // Не удалось создать, то и все остальное не уперлось // Хорошо бы Exceptions употреблять. Потом, с ними // еще разбираться надо if (!$idCarrier) { return false; } //Создание перевозчика с наложенным платежом $idCarrierCOD = $this->installCarrier(1); if (!$idCarrierCOD) { return false; } if (!$this->RussianPost->createTable()) { $this->uninstallCarrier($idCarrier); $this->uninstallCarrier($idCarrierCOD); } // Здесь мы создаем пункт вехнего подменю. // Сначала проверим, есть-ли оно уже $idTab = Tab::getIdFromClassName('AdminRussianPost'); // Если нет, создадим // TODO: поработать с этим куском if (!$idTab) { $tab = new Tab(); $tab->class_name = 'AdminRussianPost'; $tab->module = 'russianpostcarrier'; $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentShipping'); $languages = Language::getLanguages(false); foreach ($languages as $lang) { $tab->name[(int) $lang['id_lang']] = 'Russian Post'; } if (!$tab->save()) { // Если что-то пошло не так, удалим перевозчика и закруглимся $this->uninstallCarrier($idCarrier); $this->uninstallCarrier($idCarrierCOD); return $this->_abortInstall($this->l('Unable to create the "Russian Post" tab')); } } else { $tab = new Tab((int) $idTab); } //Обновляем в БД tab id вкладки "Russian Post" или завершаем с ошибкой if (Validate::isLoadedObject($tab)) { Configuration::updateValue('SR_RUSSIAN_POST_TAB_ID', $tab->id); } else { return $this->_abortInstall($this->l('Unable to load the "Russian Post" tab')); } // Если родительский метод не срабатывает, то все удаляем, // и самоустраняемся if (!parent::install() or !$this->registerHook('ActionCarrierUpdate')) { parent::uninstall(); $this->uninstallTab($tab->id); $this->uninstallCarrier($idCarrier); $this->uninstallCarrier($idCarrierCOD); $this->RussianPost->dropTable(); return $this->_abortInstall($this->l('Unable to invoke parent method install or registerHook "ActionCarrierUpdate" failed')); } // Нам будут полезны ID пункта меню и перевозчика // TODO: Некисло и результат этой операции проверять, конечно Configuration::updateValue('SR_RUSSIAN_POST_CARRIER_ID', $idCarrier); Configuration::updateValue('SR_RUSSIAN_POST_CARRIER_COD_ID', $idCarrierCOD); return true; }
/** * @return bool * * @author Panagiotis Vagenas <*****@*****.**> * @since ${VERSION} */ public function install() { if (!parent::install()) { return false; } if (!$this->registerHook('updateCarrier') or !$this->registerHook('displayCarrierList') or !$this->registerHook('displayAdminOrder')) { return false; } return $this->installCarriers(); }