/** * 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); }
public function deleteCarriers() { foreach ($this->getValue('carrierList') as $ck => $cn) { $carrier = new \Carrier((int) \Configuration::get($ck)); $carrier->delete(); \Configuration::deleteByName($ck); } return true; }
function displayOrderStep($params) { global $smarty, $cart, $cookie, $defaultCountry; if ($isVirtualCart = $cart->isVirtualCart()) { $cart->id_carrier = 0; $cart->update(); } $smarty->assign('virtual_cart', $isVirtualCart); $address = new Address(intval($cart->id_address_delivery)); $id_zone = Address::getZoneById($address->id); $result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone)); $resultsArray = array(); foreach ($result as $k => $row) { $carrier = new Carrier(intval($row['id_carrier'])); if (Configuration::get('PS_SHIPPING_METHOD') and !$carrier->getMaxDeliveryPriceByWeight($id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !$carrier->getMaxDeliveryPriceByPrice($id_zone)) { unset($result[$k]); continue; } if ($row['range_behavior']) { // Get id zone if (isset($cart->id_address_delivery) and $cart->id_address_delivery) { $id_zone = Address::getZoneById(intval($cart->id_address_delivery)); } else { $id_zone = intval($defaultCountry->id_zone); } if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotalLC(true, 4), $id_zone)) { unset($result[$k]); continue; } } $row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME'); $row['price'] = $cart->getOrderShippingCostLC(intval($row['id_carrier'])); $row['price_tax_exc'] = $cart->getOrderShippingCostLC(intval($row['id_carrier']), false); $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . intval($row['id_carrier']) . '.jpg') ? _THEME_SHIP_DIR_ . intval($row['id_carrier']) . '.jpg' : ''; $row['extra'] = Module::hookExec('extraCarrierDetails', array("row" => $row, "carrier" => $carrier)); $resultsArray[] = $row; } // Wrapping fees $wrapping_fees = floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')); $wrapping_fees_tax = new Tax(intval(Configuration::get('PS_GIFT_WRAPPING_TAX'))); $wrapping_fees_tax_exc = $wrapping_fees / (1 + floatval($wrapping_fees_tax->rate) / 100); if (Validate::isUnsignedInt($cart->id_carrier)) { $carrier = new Carrier(intval($cart->id_carrier)); if ($carrier->active and !$carrier->deleted) { $checked = intval($cart->id_carrier); } } if (!isset($checked)) { $checked = intval(Configuration::get('PS_CARRIER_DEFAULT')); } $smarty->assign(array('checkedTOS' => intval($cookie->checkedTOS), 'recyclablePackAllowed' => intval(Configuration::get('PS_RECYCLABLE_PACK')), 'giftAllowed' => intval(Configuration::get('PS_GIFT_WRAPPING')), 'conditions' => intval(Configuration::get('PS_CONDITIONS')), 'recyclable' => intval($cart->recyclable), 'gift_wrapping_price' => floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')), 'carriers' => $resultsArray, 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'checked' => intval($checked), 'back' => strval(Tools::getValue('back')), 'total_wrapping' => number_format($wrapping_fees, 2, '.', ''), 'total_wrapping_tax_exc' => number_format($wrapping_fees_tax_exc, 2, '.', ''))); Tools::safePostVars(); $css_files = array(__PS_BASE_URI__ . 'css/thickbox.css' => 'all'); $js_files = array(__PS_BASE_URI__ . 'js/jquery/thickbox-modified.js'); include_once dirname(__FILE__) . '/../../header.php'; echo $this->display(__FILE__, 'ordercarrier.tpl'); }
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; }
public function xdUninstall() { foreach ($this->Options->getValue('carrierList') as $carrier_key => $carrier_name) { $carrierId = \Configuration::get($carrier_key); if ($carrierId > 0) { $carrier = new \Carrier($carrierId); $carrier->delete(); } } return true; }
/** * Override add to create delivery value for all zones * @see classes/ObjectModelCore::add() * * @param bool $null_values * @param bool $autodate * @return bool Insertion result */ public function add($autodate = true, $null_values = false) { if (!parent::add($autodate, $null_values) || !Validate::isLoadedObject($this)) { return false; } $carrier = new Carrier((int) $this->id_carrier); $price_list = array(); foreach ($carrier->getZones() as $zone) { $price_list[] = array('id_range_price' => (int) $this->id, 'id_range_weight' => 0, 'id_carrier' => (int) $this->id_carrier, 'id_zone' => (int) $zone['id_zone'], 'price' => 0); } $carrier->addDeliveryPrice($price_list); return true; }
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; }
function getContent() { $configKeys = array('EBAY_SECURITY_TOKEN', 'PS_LANG_DEFAULT'); // Load prestashop ebay's configuration $configs = Configuration::getMultiple($configKeys); $profile_configs = $this->ebay_profile->getMultiple(array('EBAY_DELIVERY_TIME', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL')); // Check if the module is configured if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) { $template_vars = array('error_form_shipping' => 'true'); return $this->display('error_paypal_email.tpl', $template_vars); } $nb_shipping_zones_excluded = DB::getInstance()->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id); if (!$nb_shipping_zones_excluded) { EbayShippingZoneExcluded::loadEbayExcludedLocations($this->ebay_profile->id); } $module_filters = version_compare(_PS_VERSION_, '1.4.5', '>=') ? Carrier::CARRIERS_MODULE : 2; //INITIALIZE CACHE $psCarrierModule = $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT'], false, false, false, null, $module_filters); $url_vars = array('id_tab' => '3', 'section' => 'shipping'); if (version_compare(_PS_VERSION_, '1.5', '>')) { $url_vars['controller'] = Tools::getValue('controller'); } else { $url_vars['tab'] = Tools::getValue('tab'); } $zones = Zone::getZones(true); foreach ($zones as &$zone) { $zone['carriers'] = Carrier::getCarriers($this->context->language->id, false, false, $zone['id_zone']); } $template_vars = array('eBayCarrier' => EbayShippingService::getCarriers($this->ebay_profile->ebay_site_id), 'psCarrier' => $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT']), 'psCarrierModule' => $psCarrierModule, 'existingNationalCarrier' => EbayShipping::getNationalShippings($this->ebay_profile->id), 'existingInternationalCarrier' => EbayShippingInternationalZone::getExistingInternationalCarrier($this->ebay_profile->id), 'deliveryTime' => $profile_configs['EBAY_DELIVERY_TIME'], 'prestashopZone' => Zone::getZones(), 'excludeShippingLocation' => EbayShippingZoneExcluded::cacheEbayExcludedLocation($this->ebay_profile->id), 'internationalShippingLocations' => EbayShippingLocation::getInternationalShippingLocations(), 'deliveryTimeOptions' => EbayDeliveryTimeOptions::getDeliveryTimeOptions(), 'formUrl' => $this->_getUrl($url_vars), 'ebayZoneNational' => isset($profile_configs['EBAY_ZONE_NATIONAL']) ? $profile_configs['EBAY_ZONE_NATIONAL'] : false, 'ebayZoneInternational' => isset($profile_configs['EBAY_ZONE_INTERNATIONAL']) ? $profile_configs['EBAY_ZONE_INTERNATIONAL'] : false, 'ebay_token' => $configs['EBAY_SECURITY_TOKEN'], 'id_ebay_profile' => $this->ebay_profile->id, 'newPrestashopZone' => $zones); return $this->display('shipping.tpl', $template_vars); }
protected function getOptionFields() { $forms = array(); $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $carriers = Carrier::getCarriers($this->context->language->id, true); $modules = Module::getModulesOnDisk(true); $forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other')); foreach ($forms as &$form) { $form['icon'] = 'tab-preferences'; $form['fields'] = array(); $form['submit'] = array('title' => $this->l('Save')); } foreach ($modules as $module) { if (isset($module->tab) && $module->tab == 'payments_gateways' && $module->id) { $moduleClass = Module::getInstanceByName($module->name); if (!$moduleClass->isEnabledForShopContext()) { continue; } $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); if (Currency::isMultiCurrencyActivated()) { $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); } } } foreach ($carriers as $carrier) { $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the domestic delivery costs in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the overseas delivery costs in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); } $forms['carriers']['description'] = $this->l('Method: Indicate the percentage of your carrier margin. For example, if you charge $10 of shipping fees to your customer for each shipment, but you really pay $4 to this carrier, then you should indicate "40" in the percentage field.'); $forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin'), 'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (cost of goods sold)) / (total sales revenue) * 100. This value is only used to calculate the Dashboard approximate gross margin, if you do not specify the wholesale price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); $forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fees per order'), 'desc' => $this->l('You should calculate this value by making the sum of all of your additional costs per order.'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); return $forms; }
public function run() { $this->init(); $this->preProcess(); if (Tools::getValue('ajax') == 'true') { if (Tools::getIsset('summary')) { if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { if (self::$cookie->id_customer) { $customer = new Customer((int) self::$cookie->id_customer); $groups = $customer->getGroups(); } else { $groups = array(1); } if ((int) self::$cart->id_address_delivery) { $deliveryAddress = new Address((int) self::$cart->id_address_delivery); } $result = array('carriers' => Carrier::getCarriersForOrder((int) Country::getIdZone((isset($deliveryAddress) and (int) $deliveryAddress->id) ? (int) $deliveryAddress->id_country : (int) Configuration::get('PS_COUNTRY_DEFAULT')), $groups)); } $result['summary'] = self::$cart->getSummaryDetails(); $result['customizedDatas'] = Product::getAllCustomizedDatas((int) self::$cart->id); $result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']); die(Tools::jsonEncode($result)); } else { $this->includeCartModule(); } } else { $this->setMedia(); $this->displayHeader(); $this->process(); $this->displayContent(); $this->displayFooter(); } }
protected function getOptionFields() { $forms = array(); $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $carriers = Carrier::getCarriers($this->context->language->id, true); $modules = Module::getModulesOnDisk(true); $forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'), 'expenses' => array('title' => $this->l('Other expenses (monthly)'), 'id' => 'expenses')); foreach ($forms as &$form) { $form['icon'] = 'tab-preferences'; $form['fields'] = array(); $form['submit'] = array('title' => $this->l('Save')); } foreach ($modules as $module) { if ($module->tab == 'payments_gateways' && $module->id) { $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); if (Currency::isMultiCurrencyActivated()) { $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); } } } foreach ($carriers as $carrier) { $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for domestic delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for overseas delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); } $forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin (Selling price / Buying price)'), 'desc' => $this->l('Only used if you do not specify your buying price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%'); $forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fee per order'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); $expense_types = array('hosting' => $this->l('Hosting'), 'tools' => $this->l('Tools (E-mailing, etc.)'), 'acounting' => $this->l('Accounting'), 'development' => $this->l('Development'), 'marketing' => $this->l('Marketing (Adwords, etc.)'), 'others' => $this->l('Others')); foreach ($expense_types as $expense_type => $expense_label) { $forms['expenses']['fields']['CONF_MONTHLY_' . strtoupper($expense_type)] = array('title' => $expense_label, 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code); } return $forms; }
private function _displayForm() { $this->_html .= ' <form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '"> <fieldset> <legend><img src="' . $this->_path . 'logo.png" width="16" height="16"/>' . $this->l('Settings') . '</legend> <label>' . $this->l('Carrier') . '</label> <div class="margin-form"> <select name="STORE_DELIVERY_CARRIER">'; foreach (Carrier::getCarriers($this->context->language->id) as $carrier) { $this->_html .= '<option value="' . $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == Configuration::get('STORE_DELIVERY_CARRIER') ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option>'; } $this->_html .= '</select> <p class="clear">' . $this->l('Choose here a carrier used for the delivery in store') . '</p> </div> <div class="clear"></div> <label>' . $this->l('Send email to store to prevent new order') . '</label> <div class="margin-form"> <input type="radio" name="STORE_DELIVERY_SEND_MAIL" id="sendmail_on" value="1" ' . (Configuration::get('STORE_DELIVERY_SEND_MAIL') == '1' ? 'checked="checked" ' : '') . '/> <label class="t" for="sendmail_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label> <input type="radio" name="STORE_DELIVERY_SEND_MAIL" id="sendmail_off" value="0" ' . (Configuration::get('STORE_DELIVERY_SEND_MAIL') == '0' ? 'checked="checked" ' : '') . '/> <label class="t" for="sendmail_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label> <p class="clear">' . $this->l('You must enter email address in each store admin') . '</p> </div> <div class="clear"></div> <label>' . $this->l('Display Google Map') . '</label> <div class="margin-form"> <input type="radio" name="STORE_DELIVERY_DISPLAY_MAP" id="map_on" value="1" ' . (Configuration::get('STORE_DELIVERY_DISPLAY_MAP') == '1' ? 'checked="checked" ' : '') . '/> <label class="t" for="map_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label> <input type="radio" name="STORE_DELIVERY_DISPLAY_MAP" id="map_off" value="0" ' . (Configuration::get('STORE_DELIVERY_DISPLAY_MAP') == '0' ? 'checked="checked" ' : '') . '/> <label class="t" for="map_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label> <p class="clear">' . $this->l("You can display a map of stores. Don't forgot to change default latitude/longitude in Store Contact page (under Preference/Store Contact admin page)") . '</p> </div> <div class="clear"></div> <label>' . $this->l('Height of Google map') . '</label> <div class="margin-form"> <input type="text" name="STORE_DELIVERY_HEIGHT_MAP" value="' . Configuration::get('STORE_DELIVERY_HEIGHT_MAP') . '"/> <p class="clear">' . $this->l('Height of map in px (for exemple enter "300px")') . '</p> </div> <div class="clear"></div> <label>' . $this->l('Width of Google map') . '</label> <div class="margin-form"> <input type="text" name="STORE_DELIVERY_WIDTH_MAP" value="' . Configuration::get('STORE_DELIVERY_WIDTH_MAP') . '"/> <p class="clear">' . $this->l('Width of map in px or % (for exemple enter "725px" or "100%"...)') . '</p> </div> <div class="clear"></div> <div class="margin-form clear pspace"> <input type="submit" name="submitUpdate" value="' . $this->l('Update') . '" class="button" /> </div> </fieldset> </form>'; return $this->_html; }
/** * @param ShopGate $module * * @return bool */ function upgrade_module_2_9_52($module) { $shopgateCarrierId = Configuration::get('SG_CARRIER_ID'); /** * set current shopgate carrier as deleted */ if ($shopgateCarrierId) { /** @var CarrierCore $carrier */ $carrier = new Carrier($shopgateCarrierId); $carrier->deleted = true; $carrier->save(); } $shopgateShippingModel = new ShopgateShipping($module); $shopgateShippingModel->createShopgateCarrier(); $module->updateTables(); return true; }
/** * Initializes the class. * * @param string $code The provider code. * * @return void */ public function __construct($code) { $providers = array_merge(self::$providers, Carrier::getCarriers()); if (!array_key_exists($code, $providers)) { return false; } $this->code = $code; $this->name = $providers[$code]; }
public static function getCarrierByName($name) { global $cookie; $carriers = Carrier::getCarriers($cookie->id_lang, true, false, false, NULL, ALL_CARRIERS); foreach ($carriers as $carrier) { if (!$carrier['deleted'] and $carrier['external_module_name'] == $name) { return new Carrier($carrier['id_carrier']); } } }
public function getCarriersList() { $carriers = Carrier::getCarriers($this->mCookie->id_lang); $binded = unserialize(Configuration::get(self::KONFIG_PREFIX . self::KONFIG_POWIAZANIA_KURIEROW)); $list = array(); foreach ($carriers as $key => $c) { $list[] = new BindedCarrier($c['id_carrier'], $c['name'], is_array($binded) && isset($binded[$c['id_carrier']]) ? $binded[$c['id_carrier']] : "false"); } return $list; }
/** * * @param type $config * @return boolean */ public function installExternalCarrier($config) { $check = Db::getInstance()->executeS("SELECT id_carrier FROM " . _DB_PREFIX_ . "carrier WHERE name = '" . $config['name'] . "' "); if (is_array($check) && !empty($check)) { return Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier', array('deleted' => 0), 'UPDATE', ' name = "' . $config['name'] . '" '); } $carrier = new Carrier(); $carrier->name = $config['name']; $carrier->url = $config['url']; $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) { $carrier->delay[(int) $language['id_lang']] = $config['delay']['br']; } 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 = '0'; $rangePrice->add(); $rangeWeight = new RangeWeight(); $rangeWeight->id_carrier = $carrier->id; $rangeWeight->delimiter1 = '0'; $rangeWeight->delimiter2 = '30'; $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'); } Configuration::updateValue("PS_CORREIOS_CARRIER_{$carrier->id}", $config['cod_servico']); // Copy Logo if (!copy(dirname(__FILE__) . '/logos/' . $config['cod_servico'] . '.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg')) { return false; } // Return ID Carrier return (int) $carrier->id; } return false; }
public function renderForm() { $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); foreach ($carriers as $key => $carrier) { if ($carrier['is_free']) { unset($carriers[$key]); } } $this->fields_form = array('legend' => array('title' => $this->l('Weight ranges'), 'icon' => 'icon-suitcase'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier'), 'name' => 'id_carrier', 'required' => false, 'hint' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<p class="alert alert-block">' . $this->l('There is no carrier available for this weight range.') . '</p>'), array('type' => 'text', 'label' => $this->l('From'), 'name' => 'delimiter1', 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'hint' => $this->l('Start range (included).')), array('type' => 'text', 'label' => $this->l('To'), 'name' => 'delimiter2', 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'hint' => $this->l('End range (excluded).'))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'btn btn-default')); return parent::renderForm(); }
public function renderForm() { $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); foreach ($carriers as $key => $carrier) { if ($carrier['is_free']) { unset($carriers[$key]); } } $this->fields_form = array('legend' => array('title' => $this->l('Weight ranges'), 'image' => '../img/t/AdminRangeWeight.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier:'), 'name' => 'id_carrier', 'required' => false, 'desc' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<div style="margin:5px 0 10px 0">' . $this->l('There is no carrier available for this weight range.') . '</div>'), array('type' => 'text', 'label' => $this->l('From:'), 'name' => 'delimiter1', 'size' => 5, 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'desc' => $this->l('Range start (included)')), array('type' => 'text', 'label' => $this->l('To:'), 'name' => 'delimiter2', 'size' => 5, 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'desc' => $this->l('Range end (excluded)'))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button')); return parent::renderForm(); }
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) { parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); if ($this->_list && is_array($this->_list)) { foreach ($this->_list as $key => $list) { if ($list['carrier_name'] == '0') { $this->_list[$key]['carrier_name'] = Carrier::getCarrierNameFromShopName(); } } } }
public function renderForm() { $currency = $this->context->currency; $carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); foreach ($carriers as $key => $carrier) { if ($carrier['is_free']) { unset($carriers[$key]); } } $this->fields_form = array('legend' => array('title' => $this->l('Price ranges'), 'image' => '../img/t/AdminRangePrice.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier:'), 'name' => 'id_carrier', 'required' => false, 'desc' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<div style="margin:5px 0 10px 0">' . $this->l('There is no carrier available for this price range.') . '</div>'), array('type' => 'text', 'label' => $this->l('From:'), 'name' => 'delimiter1', 'size' => 5, 'required' => true, 'suffix' => $currency->getSign('right') . ' ' . $this->l('(Tax Incl.)'), 'desc' => $this->l('Start range (included)'), 'string_format' => '%.2f'), array('type' => 'text', 'label' => $this->l('To:'), 'name' => 'delimiter2', 'size' => 5, 'required' => true, 'suffix' => $currency->getSign('right') . ' ' . $this->l('(Tax Incl.)'), 'desc' => $this->l('End range (excluded)'), 'string_format' => '%.2f')), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button')); return parent::renderForm(); }
public function __construct() { $this->table = 'powatag_configuration'; $this->lang = false; $this->_select = null; //If needed you can add informations to select issued from other databases $this->_join = null; //Join the databases here parent::__construct(); $this->bootstrap = true; $this->fields_options = array('api_settings' => array('title' => $this->l('API Settings'), 'image' => '../img/admin/prefs.gif', 'fields' => array('POWATAG_API_KEY' => array('title' => $this->l('API Key'), 'validation' => 'isString', 'type' => 'text', 'size' => '80', 'visibility' => Shop::CONTEXT_SHOP, 'required' => true), 'POWATAG_HMAC_KEY' => array('title' => $this->l('HMAC Key'), 'validation' => 'isString', 'type' => 'text', 'visibility' => Shop::CONTEXT_SHOP, 'size' => 80, 'required' => true), 'POWATAG_GENERATOR_URL' => array('title' => $this->l('Powatag Endpoint URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_JS_URL' => array('title' => $this->l('Head JavaScript URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_CSS_URL' => array('title' => $this->l('Head CSS URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_LEGACY_ERRORS' => array('title' => $this->l('Legacy error codes enabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save'))), 'other_settings' => array('title' => $this->l('Other Settings'), 'image' => '../img/admin/tab-tools.gif', 'fields' => array('POWATAG_SHIPPING' => array('title' => $this->l('Shipping Method'), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'id_carrier', 'desc' => $this->l('This will be used to calculate shipping costs'), 'list' => Carrier::getCarriers($this->context->language->id, false, false, false, null, Carrier::ALL_CARRIERS), 'visibility' => Shop::CONTEXT_SHOP, 'required' => true), 'POWATAG_SUCCESS_MSG' => array('title' => $this->l('Sucess message'), 'validation' => 'isString', 'type' => 'textLang', 'size' => '80', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_IMG_TYPE' => array('title' => $this->l('Image type to send'), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'id_image_type', 'list' => ImageType::getImagesTypes(), 'visibility' => Shop::CONTEXT_SHOP, 'required' => true)), 'submit' => array('title' => $this->l('Save'))), 'product_settings' => array('title' => $this->l('Product Settings'), 'image' => $this->module->getPathUri() . 'img/qr_code.png', 'fields' => array('POWATAG_QR' => array('title' => $this->l('QR Code enabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_QR_POS' => array('title' => $this->l('QR code Position'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => 'displayRightColumnProduct', 'name' => $this->l('displayRightColumnProduct')), array('key' => 'displayLeftColumnProduct', 'name' => $this->l('displayLeftColumnProduct')), array('key' => 'displayFooterProduct', 'name' => $this->l('displayFooterProduct')), array('key' => 'displayProductButtons', 'name' => $this->l('displayProductButtons'))), 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_SKU' => array('title' => $this->l('Which SKU field to use '), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => Powatag::EAN, 'name' => $this->l('EAN13 or JAN')), array('key' => Powatag::UPC, 'name' => $this->l('UPC')), array('key' => Powatag::PRODUCT_ID, 'name' => $this->l('Product ID')), array('key' => Powatag::REFERENCE, 'name' => $this->l('REFERENCE')))), 'POWATAG_REDIRECT' => array('title' => $this->l('URL Redirect'), 'validation' => 'isString', 'type' => 'text', 'size' => 250), 'POWATAG_OFFER' => array('title' => $this->l('Promotional area'), 'validation' => 'isString', 'type' => 'text', 'size' => 250), 'POWATAG_LANG' => array('title' => $this->l('Language'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'site', 'name' => $this->l('Use site language')), array('key' => 'en_GB', 'name' => $this->l('en_GB')), array('key' => 'es_ES', 'name' => $this->l('es_ES')), array('key' => 'fr_FR', 'name' => $this->l('fr_FR')), array('key' => 'it_IT', 'name' => $this->l('it_IT')))), 'POWATAG_TYPE' => array('title' => $this->l('Type'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'bag', 'name' => $this->l('Bag')), array('key' => 'mobile-button', 'name' => $this->l('Mobile button')), array('key' => 'tablet-bag', 'name' => $this->l('Tablet bag')))), 'POWATAG_STYLE' => array('title' => $this->l('Style'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'act-left', 'name' => $this->l('act-left')), array('key' => 'act-right', 'name' => $this->l('act-right')), array('key' => 'buy-left', 'name' => $this->l('buy-left')), array('key' => 'buy-right', 'name' => $this->l('buy-right')), array('key' => 'give-left', 'name' => $this->l('give-left')), array('key' => 'give-right', 'name' => $this->l('give-right')), array('key' => 'bg-act-left', 'name' => $this->l('bg-act-left')), array('key' => 'bg-act-right', 'name' => $this->l('bg-act-right')), array('key' => 'bg-buy-left', 'name' => $this->l('bg-buy-left')), array('key' => 'bg-buy-right', 'name' => $this->l('bg-buy-right')), array('key' => 'bg-give-left', 'name' => $this->l('bg-give-left')), array('key' => 'bg-give-right', 'name' => $this->l('bg-give-right')))), 'POWATAG_COLORSCHEME' => array('title' => $this->l('Color scheme'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'light', 'name' => $this->l('Light')), array('key' => 'dark', 'name' => $this->l('Dark')))), 'POWATAG_DISPLAY' => array('title' => $this->l('Desktop / mobile'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'both', 'name' => $this->l('Both')), array('key' => 'desktop-only', 'name' => $this->l('Desktop only')), array('key' => 'mobile-only', 'name' => $this->l('Mobile only')))), 'POWATAG_VIDEO' => array('title' => $this->l('Video'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'POWATAG_DEBUG' => array('title' => $this->l('Developer mode'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool')), 'submit' => array('title' => $this->l('Save'))), 'logs' => array('title' => $this->l('Logs'), 'image' => '../img/t/AdminLogs.gif', 'fields' => array('POWATAG_API_LOG' => array('title' => $this->l('Enable applicative logging'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_REQUEST_LOG' => array('title' => $this->l('Enable request logging'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save')))); }
public function isCarrierInRange($id_carrier, $id_zone) { if (version_compare(_PS_VERSION_, "1.4.2.5", "==") || version_compare(_PS_VERSION_, "1.4.3.0", "==")) { // fix a bug in Prestashop $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); $shippingMethod = $carrier->getShippingMethod(); ###### that is the bug BOF ###### if (!$carrier->range_behavior) { return true; } ###### that is the bug EOF ###### if ($shippingMethod == Carrier::SHIPPING_METHOD_FREE) { return true; } if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT && Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone)) { return true; } if ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE && Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency)) { return true; } } elseif (version_compare(_PS_VERSION_, "1.4.1.0", "==")) { // fix a bug in prestashop $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); $is_in_zone = false; $order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING); ###### that is the bug BOF ###### if (!$carrier->range_behavior) { return true; } ###### that is the bug EOF ###### if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT and Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone) or $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE and Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $order_total, $id_zone, (int) $this->id_currency)) { $is_in_zone = true; } unset($carrier); return $is_in_zone; } else { return parent::isCarrierInRange($id_carrier, $id_zone); } return false; }
private function LoginedAction() { global $cookie, $smarty; if (!isset($cookie->id_cart)) { die('Shpping cart is empty!'); } $cart = new Cart((int) $cookie->id_cart); $user = new User((int) $cart->id_user); $addresses = $user->getAddresses(); $carriers = Carrier::loadData(); $payments = PaymentModule::getHookPayment(); $smarty->assign(array('cart' => $cart, 'addresses' => $addresses, 'carriers' => $carriers, 'payments' => $payments, 'products' => $cart->getProducts(), 'discount' => $cart->discount, 'total' => $cart->getProductTotal())); }
public function displayForm($isMainTab = true) { global $currentIndex; parent::displayForm(); if (!($obj = $this->loadObject(true))) { return; } $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $carrierArray = array(); $carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $id_carrier = Tools::getValue('id_carrier', $obj->id_carrier); foreach ($carriers as $carrier) { if (!$carrier['is_free']) { $carrierArray[] = '<option value="' . (int) $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option><sup>*</sup>'; } } echo ' <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post"> ' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . ' <fieldset><legend><img src="../img/t/AdminRangePrice.gif" />' . $this->l('Price ranges') . '</legend> <label>' . $this->l('Carrier') . '</label> <div class="margin-form">'; if (count($carrierArray)) { echo '<select name="id_carrier">'; foreach ($carrierArray as $carrierOption) { echo $carrierOption; } echo '</select> <p class="clear">' . $this->l('Carrier to which this range will be applied') . '</p>'; } else { echo '<div style="margin:5px 0 10px 0">' . $this->l('There isn\'t any carrier available for a price range.') . '</div>'; } echo ' </div> <label>' . $this->l('From:') . ' </label> <div class="margin-form"> ' . $currency->getSign('left') . '<input type="text" size="4" name="delimiter1" value="' . htmlentities($this->getFieldValue($obj, 'delimiter1'), ENT_COMPAT, 'UTF-8') . '" />' . $currency->getSign('right') . '<sup>*</sup> <p class="clear">' . $this->l('Range start (included)') . '</p> </div> <label>' . $this->l('To:') . ' </label> <div class="margin-form"> ' . $currency->getSign('left') . '<input type="text" size="4" name="delimiter2" value="' . htmlentities($this->getFieldValue($obj, 'delimiter2'), ENT_COMPAT, 'UTF-8') . '" />' . $currency->getSign('right') . '<sup>*</sup> <p class="clear">' . $this->l('Range end (excluded)') . '</p> </div> <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset> </form>'; }
public function getFormYaPokupki() { $yamodule = new Yamodule(); $dir = _PS_ADMIN_DIR_; $dir = explode('/', $dir); $dir = base64_encode($yamodule->cryptor->encrypt(end($dir) . '_' . Context::getContext()->cookie->id_employee . '_pokupki')); $carriers = Carrier::getCarriers(Context::getContext()->language->id, true, false, false, null, 5); $type = array(array('name' => 'POST', 'id' => 'POST'), array('name' => 'PICKUP', 'id' => 'PICKUP'), array('name' => 'DELIVERY', 'id' => 'DELIVERY')); $out = array('form' => array('legend' => array('title' => $this->l('Module configuration Orders on the market'), 'icon' => 'icon-cogs'), 'input' => array(array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('A token for access to API Yandex.Market'), 'name' => 'YA_POKUPKI_TOKEN', 'label' => $this->l('An authorization token Yandex.Market')), array('col' => 4, 'class' => 't', 'disabled' => 1, 'type' => 'text', 'name' => 'YA_POKUPKI_FD', 'label' => $this->l('Формат данных')), array('col' => 4, 'class' => 't', 'disabled' => 1, 'type' => 'text', 'name' => 'YA_POKUPKI_TA', 'label' => $this->l('Тип авторизации')), array('type' => 'checkbox', 'label' => $this->l('Prepayment'), 'name' => 'YA_POKUPKI_PREDOPLATA', 'values' => array('query' => array(array('id' => 'YANDEX', 'name' => $this->l('Payment at registration (only in Russia)'), 'val' => 1), array('id' => 'SHOP_PREPAID', 'name' => $this->l('Directly to the shop (only for Ukraine)'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Post-paid'), 'name' => 'YA_POKUPKI_POSTOPLATA', 'values' => array('query' => array(array('id' => 'CASH_ON_DELIVERY', 'name' => $this->l('Cash upon receipt of goods'), 'val' => 1), array('id' => 'CARD_ON_DELIVERY', 'name' => $this->l('Payment via credit card upon receipt of order'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Settings'), 'name' => 'YA_POKUPKI_SET', 'values' => array('query' => array(array('id' => 'CHANGEC', 'name' => $this->l('To enable the change of delivery'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Ссылка на https://api.partner.market.yandex.ru/v2/'), 'name' => 'YA_POKUPKI_APIURL', 'label' => $this->l('URL affiliate API Yandex.Market')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('The Campaign Number'), 'name' => 'YA_POKUPKI_NC', 'label' => $this->l('The Campaign Number')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('The user login in the system Yandex.Market'), 'name' => 'YA_POKUPKI_LOGIN', 'label' => $this->l('The user login in the system Yandex.Market')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Application ID'), 'name' => 'YA_POKUPKI_ID', 'label' => $this->l('Application ID')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Password prilozheniye'), 'name' => 'YA_POKUPKI_PW', 'label' => $this->l('An application-specific password')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => '<a href="https://oauth.yandex.ru/authorize?response_type=code&display=popup&state=' . $dir . '&client_id=' . Configuration::get('YA_POKUPKI_ID') . "&device_id=" . md5(Configuration::get('YA_POKUPKI_ID')) . '">' . $this->l('To obtain a token for access to Yandex.Buy') . '</a>', 'name' => 'YA_POKUPKI_YATOKEN', 'label' => $this->l('An authorization token'), 'disabled' => true), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Item number ex'), 'name' => 'YA_POKUPKI_PUNKT', 'label' => $this->l('The ID of the item ex')), array('col' => 6, 'class' => 't', 'type' => 'text', 'name' => 'YA_MARKET_REDIRECT', 'desc' => $this->l('Callback Url for OAuth applications'), 'label' => $this->l('The link for the application')), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('URL API to fill in the store settings on Yandex.Market'), 'name' => 'YA_POKUPKI_APISHOP', 'label' => $this->l('The link to access Your store'))), 'submit' => array('title' => $this->l('Save')))); foreach ($carriers as $a) { $out['form']['input'][] = array('type' => 'select', 'label' => $this->l('The delivery type') . ' ' . $a['name'], 'name' => 'YA_POKUPKI_DELIVERY_' . $a['id_carrier'], 'desc' => $this->l('POST - Mail DELIVERY - Express delivery, PICKUP Pickup'), 'options' => array('query' => $type, 'name' => 'name', 'id' => 'id'), 'class' => 't'); } return $out; }
public function getContent() { if (Tools::isSubmit('btnSubmit')) { $this->postProcess(); } $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT')); $id_lang = Configuration::get('PS_LANG_DEFAULT'); $carriers = Carrier::getCarriers($id_lang, false, false, false, null, 0); $config = Configuration::getMultiple(array('COD_ENABLED', 'COD_SHOW_ZERO', 'COD_TITLE', 'COD_ORDER_STATUS', 'COD_SPECIFIC_COUNTRY', 'COD_COUNTRY', 'COD_MINIMUM_ORDER', 'COD_MAXIMUM_ORDER', 'COD_COST_CALCULATION', 'COD_COST_INLAND', 'COD_COST_FOREIGN', 'COD_FREE_FROM', 'COD_CUSTOM_TEXT', 'COD_DISALLOW_METHODS', 'COD_DISALLOWED_METHODS', 'COD_ORDER_TIME')); $this->context->smarty->assign(array('module_name' => $this->name, 'displayName' => $this->displayName, 'order_time' => $config['COD_ORDER_TIME'], 'request_uri' => $_SERVER['REQUEST_URI'], 'enabled' => $config['COD_ENABLED'], 'show_zero' => $config['COD_SHOW_ZERO'], 'title' => $config['COD_TITLE'], 'orders_status' => OrderStateCore::getOrderStates((int) $this->context->language->id), 'order_status' => $config['COD_ORDER_STATUS'], 'specific_country' => $config['COD_SPECIFIC_COUNTRY'], 'country' => ($a = unserialize($config['COD_COUNTRY'])) ? $a : array(), 'all_countrys' => Country::getCountries((int) $this->context->language->id, true), 'minimum_order' => $config['COD_MINIMUM_ORDER'], 'maximum_order' => $config['COD_MAXIMUM_ORDER'], 'cost_calculation' => $config['COD_COST_CALCULATION'], 'cost_inland' => $config['COD_COST_INLAND'], 'cost_foreign' => $config['COD_COST_FOREIGN'], 'free_from' => $config['COD_FREE_FROM'], 'custom_text' => $config['COD_CUSTOM_TEXT'], 'disallow_methods' => $config['COD_DISALLOW_METHODS'], 'carriers' => $carriers, 'disallowed_methods' => ($a = unserialize($config['COD_DISALLOWED_METHODS'])) ? $a : array(), 'currency_sign' => $currency->sign)); $this->context->controller->addJS($this->local_path . '/views/js/script.js', 'all'); $output = $this->context->smarty->fetch($this->local_path . '/views/templates/admin/configure.tpl'); return $output; }
public function postProcess() { /* Shipping fees */ if (Tools::isSubmit('submitFees' . $this->table)) { if ($this->tabAccess['edit'] === '1') { if (($id_carrier = (int) Tools::getValue('id_carrier')) && $id_carrier == ($id_carrier2 = (int) Tools::getValue('id_carrier2'))) { $carrier = new Carrier($id_carrier); if (Validate::isLoadedObject($carrier)) { /* Get configuration values */ $shipping_method = $carrier->getShippingMethod(); $rangeTable = $carrier->getRangeTable(); $carrier->deleteDeliveryPrice($rangeTable); $currentList = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier); /* Build prices list */ $priceList = array(); foreach ($_POST as $key => $value) { if (strstr($key, 'fees_')) { $tmpArray = explode('_', $key); $price = number_format(abs(str_replace(',', '.', $value)), 6, '.', ''); $current = 0; foreach ($currentList as $item) { if ($item['id_zone'] == $tmpArray[1] && $item['id_' . $rangeTable] == $tmpArray[2]) { $current = $item; } } if ($current && $price == $current['price']) { continue; } $priceList[] = array('id_range_price' => $shipping_method == Carrier::SHIPPING_METHOD_PRICE ? (int) $tmpArray[2] : null, 'id_range_weight' => $shipping_method == Carrier::SHIPPING_METHOD_WEIGHT ? (int) $tmpArray[2] : null, 'id_carrier' => (int) $carrier->id, 'id_zone' => (int) $tmpArray[1], 'price' => $price); } } /* Update delivery prices */ $carrier->addDeliveryPrice($priceList); Tools::redirectAdmin(self::$currentIndex . '&conf=6&id_carrier=' . $carrier->id . '&token=' . $this->token); } else { $this->errors[] = Tools::displayError('An error occurred while attempting to update fees (cannot load carrier object).'); } } elseif (isset($id_carrier2)) { $_POST['id_carrier'] = $id_carrier2; } else { $this->errors[] = Tools::displayError('An error occurred while attempting to update fees (cannot load carrier object).'); } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } else { return parent::postProcess(); } }
public function __construct() { global $cookie; $this->table = 'carrier'; $this->className = 'Carrier'; $this->lang = true; $this->edit = true; $this->delete = true; $this->deleted = true; $this->fieldImageSettings = array('name' => 'logo', 'dir' => 's'); $this->fieldsDisplay = array('id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 100), 'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false), 'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false), 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), 'is_free' => array('title' => $this->l('Is Free'), 'align' => 'center', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false)); $this->optionTitle = $this->l('Carrier options'); $this->_fieldsOptions = array('PS_CARRIER_DEFAULT' => array('title' => $this->l('Default carrier:'), 'desc' => $this->l('The default carrier used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_carrier', 'list' => Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, Carrier::ALL_CARRIERS))); parent::__construct(); }
public function getFormYaPokupki() { $state = OrderState::getOrderStates(Context::getContext()->language->id); $dir = _PS_ADMIN_DIR_; $dir = explode('/', $dir); $dir = base64_encode(end($dir) . '_' . Context::getContext()->cookie->id_employee . '_pokupki'); $extend = array(); $carriers = Carrier::getCarriers(Context::getContext()->language->id, true, false, false, null, 5); $type = array(array('name' => 'POST', 'id' => 'POST'), array('name' => 'PICKUP', 'id' => 'PICKUP'), array('name' => 'DELIVERY', 'id' => 'DELIVERY')); $out = array('form' => array('legend' => array('title' => $this->l('Настройки модуля Заказы на маркете'), 'icon' => 'icon-cogs'), 'input' => array(array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Токен для доступа к API Яндекс.Маркет'), 'name' => 'YA_POKUPKI_TOKEN', 'label' => $this->l('Авторизационный токен Яндекс.Маркет')), array('type' => 'checkbox', 'label' => $this->l('Предоплата'), 'name' => 'YA_POKUPKI_PREDOPLATA', 'values' => array('query' => array(array('id' => 'YANDEX', 'name' => $this->l('Оплата при оформлении (только в России)'), 'val' => 1), array('id' => 'SHOP_PREPAID', 'name' => $this->l('Напрямую магазину (только для Украины)'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Постоплата'), 'name' => 'YA_POKUPKI_POSTOPLATA', 'values' => array('query' => array(array('id' => 'CASH_ON_DELIVERY', 'name' => $this->l('Наличный расчёт при получении товара'), 'val' => 1), array('id' => 'CARD_ON_DELIVERY', 'name' => $this->l('Оплата банковской картой при получении заказа'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Настройки'), 'name' => 'YA_POKUPKI_SET', 'values' => array('query' => array(array('id' => 'CHANGEC', 'name' => $this->l('Включить смену доставок'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Ссылка на https://api.partner.market.yandex.ru/v2/'), 'name' => 'YA_POKUPKI_APIURL', 'label' => $this->l('URL партнёрского API Яндекс.Маркет')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Номер Кампании'), 'name' => 'YA_POKUPKI_NC', 'label' => $this->l('Номер Кампании')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Логин пользователя в системе Яндекс.Маркет'), 'name' => 'YA_POKUPKI_LOGIN', 'label' => $this->l('Логин пользователя в системе Яндекс.Маркет')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('ID приложения'), 'name' => 'YA_POKUPKI_ID', 'label' => $this->l('ID приложения')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Пароль приложениюж'), 'name' => 'YA_POKUPKI_PW', 'label' => $this->l('Пароль приложения')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => '<a href="https://oauth.yandex.ru/authorize?response_type=code&display=popup&state=' . $dir . '&client_id=' . Configuration::get('YA_POKUPKI_ID') . "&device_id=" . md5(Configuration::get('YA_POKUPKI_ID')) . '">' . $this->l('Получить токен для доступа к Yandex.Покупки') . '</a>', 'name' => 'YA_POKUPKI_YATOKEN', 'label' => $this->l('Авторизационный токен'), 'disabled' => true), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Номер пункта самовывоза'), 'name' => 'YA_POKUPKI_PUNKT', 'label' => $this->l('Идентификатор пункта самовывоза')), array('col' => 6, 'class' => 't', 'type' => 'text', 'name' => 'YA_MARKET_REDIRECT', 'desc' => $this->l('Callback Url для OAuth-приложения'), 'label' => $this->l('Ссылка для приложения')), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('URL API для заполнения в настройках магазина на Яндекс.Маркет'), 'name' => 'YA_POKUPKI_APISHOP', 'label' => $this->l('Ссылка для обращения к Вашему магазину'))), 'submit' => array('title' => $this->l('Сохранить')))); foreach ($carriers as $a) { $out['form']['input'][] = array('type' => 'select', 'label' => $this->l('Тип доставки') . ' ' . $a['name'], 'name' => 'YA_POKUPKI_DELIVERY_' . $a['id_carrier'], 'desc' => $this->l('POST - Почта, DELIVERY - Курьерская доставка, PICKUP - Самовывоз'), 'options' => array('query' => $type, 'name' => 'name', 'id' => 'id'), 'class' => 't'); } return $out; }