本文整理汇总了PHP中Carrier::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::add方法的具体用法?PHP Carrier::add怎么用?PHP Carrier::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDejalaCarrier
/**
* creates of a dejala carrier corresponding to $dejalaProduct
*/
public static function createDejalaCarrier($dejalaConfig, $dejalaProduct)
{
// MFR091130 - get id zone from the country used in the module (if the store zones were customized) - default is 1 (Europe)
$id_zone = 1;
$moduleCountryIsoCode = strtoupper($dejalaConfig->country);
$countryID = Country::getByIso($moduleCountryIsoCode);
if (intval($countryID)) {
$id_zone = Country::getIdZone($countryID);
}
$vatRate = floatval($dejalaProduct['vat']);
// MFR091130 - get or create the tax & attach it to our zone if needed
$id_tax = Tax::getTaxIdByRate($vatRate);
if (!$id_tax) {
$tax = new Tax();
$tax->rate = $vatRate;
$defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
$tax->name[$defaultLanguage] = $tax->rate . '%';
$tax->add();
$id_tax = Tax::getTaxIdByRate($vatRate);
}
if (!Tax::zoneHasTax($id_tax, $id_zone)) {
// MFR : direct call because $tax->addZone($id_zone) causes errors when called
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'tax_zone` (`id_tax` , `id_zone`) VALUES (' . intval($id_tax) . ', ' . intval($id_zone) . ')');
}
$carrier = new Carrier();
$carrier->name = 'dejala';
$carrier->id_tax = $id_tax;
$carrier->url = 'http://tracking.dejala.' . $dejalaConfig->country . '/tracker/@';
$carrier->active = true;
$carrier->deleted = 0;
$carrier->shipping_handling = false;
$carrier->range_behavior = 0;
$carrier->is_module = 1;
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$carrier->delay[$language['id_lang']] = utf8_encode('Quand vous voulez... Par coursier, ' . $dejalaProduct['timelimit'] . 'H');
}
if ($language['iso_code'] == 'en') {
$carrier->delay[$language['id_lang']] = utf8_encode('When you want... Dispatch rider, ' . $dejalaProduct['timelimit'] . 'H range');
}
if ($language['iso_code'] == 'es') {
$carrier->delay[$language['id_lang']] = utf8_encode('Cuando quiera... Por mensajero, ' . $dejalaProduct['timelimit'] . 'H');
}
}
$carrier->add();
$sql = 'INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone` (`id_carrier` , `id_zone`) VALUES (' . intval($carrier->id) . ', ' . intval($id_zone) . ')';
Db::getInstance()->Execute($sql);
$rangeW = new RangeWeight();
$rangeW->id_carrier = $carrier->id;
$rangeW->delimiter1 = 0;
$rangeW->delimiter2 = $dejalaProduct['max_weight'];
$rangeW->add();
$vat_factor = 1 + $dejalaProduct['vat'] / 100;
$priceTTC = round($dejalaProduct['price'] * $vat_factor + $dejalaProduct['margin'], 2);
$priceHT = round($priceTTC / $vat_factor, 2);
$priceList = '(NULL' . ',' . $rangeW->id . ',' . $carrier->id . ',' . $id_zone . ',' . $priceHT . ')';
$carrier->addDeliveryPrice($priceList);
return new Carrier($carrier->id);
}
示例2: xdInstall
public function xdInstall()
{
foreach ($this->Options->getValue('carrierList') as $carrier_key => $carrier_name) {
$carrierId = \Configuration::get($carrier_key);
$deleted = false;
if ($carrierId > 0) {
$carrier = new \Carrier($carrierId);
$deleted = $carrier->deleted;
}
if ($carrierId < 1 || $deleted) {
// Create carrier
$carrier = new \Carrier();
$carrier->name = $carrier_name;
$carrier->id_tax_rules_group = 0;
$carrier->active = 1;
$carrier->deleted = 0;
foreach (\Language::getLanguages(true) as $language) {
// TODO Carrier delay
$carrier->delay[(int) $language['id_lang']] = ' ';
}
$carrier->shipping_handling = 0;
$carrier->range_behavior = 1;
$carrier->is_module = 1;
$carrier->shipping_external = 1;
$carrier->external_module_name = $this->moduleInstance->name;
$carrier->need_range = 1;
if (!$carrier->add()) {
return false;
}
// 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
$rangePrice = new \RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
// Create weight range
$rangeWeight = new \RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
// Associate carrier to all zones
$zones = \Zone::getZones(true);
foreach ($zones as $zone) {
\Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
\Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
\Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
}
copy(self::$instanceBaseDir . '/img/logo.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
\Configuration::updateValue($carrier_key, $carrier->id);
}
}
return true;
}
示例3: installCarriers
public function installCarriers()
{
$id_lang_default = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'));
$carriers_list = array('MYMOD_CA_CLDE' => 'Classic delivery', 'MYMOD_CA_REPO' => 'Relay Point');
foreach ($carriers_list as $carrier_key => $carrier_name) {
if (Configuration::get($carrier_key) < 1) {
// Create new carrier
$carrier = new Carrier();
$carrier->name = $carrier_name;
$carrier->id_tax_rules_group = 0;
$carrier->active = 1;
$carrier->deleted = 0;
foreach (Language::getLanguages(true) as $language) {
$carrier->delay[(int) $language['id_lang']] = 'Delay ' . $carrier_name;
}
$carrier->shipping_handling = false;
$carrier->range_behavior = 0;
$carrier->is_module = true;
$carrier->shipping_external = true;
$carrier->external_module_name = $this->name;
$carrier->need_range = true;
if (!$carrier->add()) {
return false;
}
// 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
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
// Create weight range
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
// Associate carrier to all zones
$zones = Zone::getZones(true);
foreach ($zones as $zone) {
Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
}
// Copy the carrier logo
copy(dirname(__FILE__) . '/views/img/' . $carrier_key . '.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
// Save the carrier ID in the Configuration table
Configuration::updateValue($carrier_key, $carrier->id);
}
}
return true;
}
示例4: installExternalCarrier
public function installExternalCarrier($config)
{
$carrier = new Carrier();
$carrier->name = $config['name'];
$carrier->id_tax_rules_group = $config['id_tax_rules_group'];
$carrier->active = $config['active'];
$carrier->deleted = $config['deleted'];
$carrier->delay = $config['delay'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behavior = $config['range_behavior'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$languages = Context::getContext()->language->getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'cs') {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
} else {
$carrier->delay[(int) $language['id_lang']] = '2 days';
}
}
if ($carrier->add()) {
$groups = Group::getGroups(true);
foreach ($groups as $group) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
}
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '1000000';
$rangePrice->add();
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
$sql = 'SELECT DISTINCT id_zone FROM ' . _DB_PREFIX_ . 'country WHERE iso_code="CZ" OR iso_code="SK"';
$zones = Db::getInstance()->executeS($sql);
if (is_array($zones)) {
foreach ($zones as $zone) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
}
}
$this->module->copyLogo($carrier->id);
if (Configuration::get('PS_TAX')) {
$carrier->setTaxRulesGroup(1, true);
}
return (int) $carrier->id;
}
$this->messages[] = 'Failed to create external carrier ' . $config['name'];
return false;
}
示例5: uninstall
public function uninstall()
{
if (!parent::uninstall()) {
return false;
}
$carrier = new Carrier(Configuration::get('MY_CARRIR_ID'));
$carrier->deleted = 1;
if (!$carrier->add()) {
return false;
}
if (!Configuration::deleteByName('MY_CARRIER_ID')) {
return false;
}
return true;
}
示例6: installExternalCarrier
public static function installExternalCarrier($config)
{
$carrier = new Carrier();
$carrier->name = $config['name'];
$carrier->id_tax_rules_group = $config['id_tax_rules_group'];
$carrier->id_zone = $config['id_zone'];
$carrier->active = $config['active'];
$carrier->deleted = $config['deleted'];
$carrier->delay = $config['delay'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behavior = $config['range_behavior'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($language['iso_code'] == 'en') {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'))) {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
}
}
if ($carrier->add()) {
$groups = Group::getGroups(true);
foreach ($groups as $group) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
}
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
$zones = Zone::getZones(true);
foreach ($zones as $zone) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
}
// Copy Logo
if (!copy(dirname(__FILE__) . '/carrier.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg')) {
return false;
}
// Return ID Carrier
return (int) $carrier->id;
}
return false;
}
示例7: addCarrier
protected function addCarrier()
{
$carrier = new Carrier();
$carrier->name = $this->l('My super carrier');
$carrier->is_module = true;
$carrier->active = 1;
$carrier->range_behavior = 1;
$carrier->need_range = 1;
$carrier->shipping_external = true;
$carrier->range_behavior = 0;
$carrier->external_module_name = $this->name;
$carrier->shipping_method = 2;
foreach (Language::getLanguages() as $lang) {
$carrier->delay[$lang['id_lang']] = $this->l('Super fast delivery');
}
if ($carrier->add() == true) {
@copy(dirname(__FILE__) . '/views/img/carrier_image.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
Configuration::updateValue('MYSHIPPINGMODULE_CARRIER_ID', (int) $carrier->id);
return $carrier;
}
return false;
}
示例8: installExternalCarrier
public static function installExternalCarrier($config)
{
$carrier = new Carrier();
$carrier->hydrate($config);
$carrier->name = $config['name'];
$carrier->id_zone = $config['id_zone'];
$carrier->active = $config['active'];
$carrier->deleted = $config['deleted'];
$carrier->delay = $config['delay'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behavior = $config['range_behavior'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$carrier->setTaxRulesGroup($config['id_tax_rules_group'], true);
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'lv') {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($language['iso_code'] == 'lt') {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'))) {
$carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
}
}
if ($carrier->add()) {
$groups = Group::getGroups(true);
foreach ($groups as $group) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
}
// $range_price = new RangePrice();
// $range_price->id_carrier = $carrier->id;
// $range_price->delimiter1 = '0';
// $range_price->delimiter2 = '10000';
// $range_price->add();
// $range_weight = new RangeWeight();
// $range_weight->id_carrier = $carrier->id;
// $range_weight->delimiter1 = '0';
// $range_weight->delimiter2 = '10000';
// $range_weight->add();
// Add weight ranges to carrier
$rangePrices = array();
foreach ($config['ranges'] as $range) {
$rangeWeight = new RangeWeight();
$rangeWeight->hydrate(array('id_carrier' => $carrier->id, 'delimiter1' => (double) $range['delimiter1'], 'delimiter2' => (double) $range['delimiter2']));
$rangeWeight->add();
// Save range ID and price and set it after the Zones have been added
$rangePrices[] = array('id_range_weight' => $rangeWeight->id, 'price' => $range['price']);
}
// Update prices in delivery table for each range (need IDs)
foreach ($rangePrices as $rangePrice) {
$data = array('price' => $rangePrice['price']);
$where = 'id_range_weight = ' . $rangePrice['id_range_weight'];
Db::getInstance()->update('delivery', $data, $where);
}
// Add Europe for EVERY carrier range
// Automatically creates rows in delivery table, price is 0
$id_zone_europe = Zone::getIdByName('Europe');
$carrier->addZone($id_zone_europe ? $id_zone_europe : 1);
// Copy Logo
if (!Tools::copy(dirname(__FILE__) . '/logo.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.png')) {
return false;
}
DpdCarrierOptions::setCarrierOptions((int) $carrier->id, (int) $carrier->id, $config['type']);
// Return ID Carrier
return (int) $carrier->id;
}
return false;
}
开发者ID:uab-balticode,项目名称:dpd-shipping-module-prestashop-2,代码行数:72,代码来源:dynamicparceldistribution.php
示例9: createShopgateCarrier
/**
* create shopgate carrier
*/
public function createShopgateCarrier()
{
/** @var CarrierCore $carrier */
$carrier = new Carrier();
$carrier->name = self::MODULE_CARRIER_NAME;
$carrier->active = true;
$carrier->deleted = true;
$carrier->shipping_handling = false;
$carrier->range_behavior = true;
$carrier->delay[Configuration::get('PS_LANG_DEFAULT')] = self::MODULE_CARRIER_NAME;
$carrier->shipping_external = true;
$carrier->is_module = true;
$carrier->external_module_name = self::DEFAULT_EXTERNAL_MODULE_CARRIER_NAME;
$carrier->need_range = true;
foreach (Language::getLanguages() as $language) {
$carrier->delay[$language['id_lang']] = 'Depends on Shopgate selected carrier';
}
if ($carrier->add()) {
$groups = Group::getGroups(true);
foreach ($groups as $group) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
}
/** @var RangePriceCore $rangePrice */
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '1000000';
$rangePrice->add();
/** @var RangeWeightCore $rangeWeight */
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '1000000';
$rangeWeight->add();
$zones = Zone::getZones(true);
foreach ($zones as $zone) {
/** @var $zone ZoneCore */
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
}
}
Configuration::updateValue('SG_CARRIER_ID', $carrier->id);
}
示例10: addCarrier
/**
* Add new carrier
*
* @param $name
* @param $delay
* @return bool|int
*/
private function addCarrier($name, $delay)
{
$ret = false;
if ($carrier = new Carrier()) {
$carrier->name = $name;
$carrier->active = 1;
$carrier->range_behavior = 1;
$carrier->need_range = 1;
$carrier->external_module_name = 'mondialrelay';
$carrier->shipping_method = 1;
$carrier->delay = array($this->context->language->id => $delay);
$carrier->is_module = _PS_VERSION_ > '1.3' ? 1 : 0;
$ret = $carrier->add();
}
return $ret ? $carrier->id : false;
}
示例11: createCarrier
private function createCarrier($config, $product_id, $name, $debug_mode = false, &$debug_info = array())
{
$carrier = new Carrier();
if ($debug_mode) {
array_push($debug_info, "Trying to create carrier " . $product_id . " with name " . $name);
}
$carrier->name = $name;
$carrier->id_zone = $config['id_zone'];
$carrier->url = $config['url'];
$carrier->active = $config['active'];
$carrier->deleted = $config['deleted'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behaviour = $config['range_behaviour'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'en') {
$carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($language['iso_code'] == 'no') {
$carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
}
}
if ($debug_mode) {
array_push($debug_info, "Adding carrier");
}
if ($carrier->add()) {
if ($debug_mode) {
array_push($debug_info, "Carrier added, setting up associations");
}
$carriers_str = Configuration::get('FRAKTGUIDE_CREATED_CARRIER_IDS');
$carriers = $carriers_str ? explode(';', Configuration::get('FRAKTGUIDE_CREATED_CARRIER_IDS')) : array();
$carriers[] = $carrier->id;
Configuration::updateValue('FRAKTGUIDE_CREATED_CARRIER_IDS', implode(';', $carriers));
$zones = Zone::getZones(true);
foreach ($zones as $zone) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_zone VALUE(\'' . (int) $carrier->id . '\', \'' . (int) $zone['id_zone'] . '\')');
}
$groups = Group::getgroups(true);
foreach ($groups as $group) {
Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_group VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $group['id_group'] . '\')');
}
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
if ($debug_mode) {
array_push($debug_info, "Trying to update product name table");
}
if (!Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'fraktguide_product_names`(`id_carrier`, `product_id`) VALUES(' . $carrier->id . ', \'' . $product_id . '\')')) {
return false;
}
if (!copy(dirname(__FILE__) . '/img/logo.png', _PS_SHIP_IMG_DIR_ . '/' . $carrier->id . '.jpg')) {
return false;
}
if ($debug_mode) {
array_push($debug_info, "Success");
}
// Link to correct tax group (ps_carrier_tax_rules_group_shop aparently...)
if (!Db::getInstance()->insert('carrier_tax_rules_group_shop', array('id_carrier' => $carrier->id, 'id_tax_rules_group' => Configuration::get('FRAKTGUIDE_ID_TAX_RULES_GROUP'), 'id_shop' => Context::getContext()->shop->id))) {
return false;
}
return true;
} else {
Tools::dieOrLog("Error creating carrier " . $product_id);
return false;
}
}
示例12: addCarrier
/**
* Add new carrier
*
* @param $name
* @param $delay
* @return bool|int
*/
private function addCarrier($name, $delay)
{
$ret = false;
if ($carrier = new Carrier()) {
$delay_lang = array();
foreach (Language::getLanguages(false) as $lang) {
$delay_lang[$lang['id_lang']] = $delay;
}
$carrier->name = $name;
$carrier->active = 1;
$carrier->range_behavior = 1;
$carrier->need_range = 1;
$carrier->external_module_name = 'mondialrelay';
$carrier->shipping_method = 1;
$carrier->delay = $delay_lang;
$carrier->is_module = _PS_VERSION_ < '1.4' ? 0 : 1;
$ret = $carrier->add();
}
return $ret ? $carrier->id : false;
}
示例13: createCarriers
protected function createCarriers($eta)
{
// Sameday(ETA: 18:00)
foreach ($this->carriers as $key => $value) {
//Create new carrier
$carrier = new Carrier();
$carrier->name = $key;
$carrier->active = true;
$carrier->deleted = 0;
$carrier->shipping_handling = false;
$carrier->range_behavior = 0;
$carrier->delay[Configuration::get('PS_LANG_DEFAULT')] = $eta;
$carrier->shipping_external = true;
$carrier->is_module = true;
$carrier->external_module_name = $this->name;
$carrier->need_range = true;
$carrier->url = 'https://send24.com/track?@';
if ($carrier->add()) {
$groups = Group::getGroups(true);
foreach ($groups as $group) {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
}
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '5';
$rangePrice->add();
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '5';
$rangeWeight->add();
$zones = Zone::getZones(true);
foreach ($zones as $z) {
if ($z['name'] == 'Europe') {
Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $z['id_zone']), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
}
}
copy(dirname(__FILE__) . '/views/img/send24.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
Configuration::updateValue(self::PREFIX . $value, $carrier->id);
Configuration::updateValue(self::PREFIX . $value . '_reference', $carrier->id);
}
}
return true;
}
示例14: Carrier
<?php
if (Tools::P('saveCarrier') == 'add') {
$carrier = new Carrier();
$carrier->copyFromPost();
if ($carrier->add() && $carrier->updateLogo()) {
UIAdminAlerts::conf('配送商已添加');
$_GET['id'] = $carrier->id;
}
if (is_array($carrier->_errors) and count($carrier->_errors) > 0) {
$errors = $carrier->_errors;
}
}
if (isset($_GET['id'])) {
$id = (int) Tools::G('id');
$obj = new Carrier($id);
}
if (Tools::P('saveCarrier') == 'edit') {
if (Validate::isLoadedObject($obj)) {
$obj->copyFromPost();
if ($obj->update() && $obj->updateLogo()) {
UIAdminAlerts::conf('配送商已更新');
}
}
if (is_array($obj->_errors) and count($obj->_errors) > 0) {
$errors = $obj->_errors;
}
}
if (isset($errors)) {
UIAdminAlerts::MError($errors);
}
示例15: createSoColissimoCarrierSeller
public static function createSoColissimoCarrierSeller($config)
{
$carrier = new Carrier();
$carrier->name = $config['name'] . ' - Commerce de proximité';
$carrier->id_tax_rules_group = $config['id_tax_rules_group'];
$carrier->id_zone = $config['id_zone'];
$carrier->url = $config['url'];
$carrier->active = 0;
$carrier->deleted = $config['deleted'];
$carrier->delay = $config['delay'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behavior = $config['range_behavior'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$carrier->delay[$language['id_lang']] = $config['delay_seller'][$language['iso_code']];
}
if ($language['iso_code'] == 'en') {
$carrier->delay[$language['id_lang']] = $config['delay_seller'][$language['iso_code']];
}
}
if ($carrier->add()) {
if (!version_compare(_PS_VERSION_, '1.5', '<')) {
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
}
Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_SELLER', (int) $carrier->id);
$groups = Group::getgroups(true);
foreach ($groups as $group) {
Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_group VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $group['id_group'] . '\')');
}
$range_price = new RangePrice();
$range_price->id_carrier = $carrier->id;
$range_price->delimiter1 = '0';
$range_price->delimiter2 = '10000';
$range_price->add();
$range_weight = new RangeWeight();
$range_weight->id_carrier = $carrier->id;
$range_weight->delimiter1 = '0';
$range_weight->delimiter2 = '10000';
$range_weight->add();
//copy logo
if (!copy(dirname(__FILE__) . '/img/socolissimo.jpg', _PS_SHIP_IMG_DIR_ . '/' . $carrier->id . '.jpg')) {
return false;
}
return true;
}
return false;
}