public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); $db = Db::getInstance(); $context = Context::getContext(); $controller = Tools::getValue('controller'); if ($controller == "orderdetail") { list($order) = $db->executeS('SELECT id_carrier, id_cart FROM `' . _DB_PREFIX_ . 'orders` WHERE id_order=' . (int) Tools::getValue('id_order')); $id_carrier = $order['id_carrier']; $id_cart = $order['id_cart']; } elseif (!in_array($controller, ["orderopc", "order"]) && $context && $context->cart) { $id_carrier = $context->cart->id_carrier; $id_cart = $context->cart->id; } else { $id_carrier = null; $id_cart = null; } $is_packetery_carrier = $db->getValue('SELECT 1 FROM `' . _DB_PREFIX_ . 'packetery_carrier` WHERE id_carrier=' . (int) $id_carrier) == 1; if ($is_packetery_carrier) { $selected_branch = $db->getValue('SELECT name_branch FROM `' . _DB_PREFIX_ . 'packetery_order` WHERE id_cart=' . (int) $id_cart); if ($selected_branch) { $this->name .= " ({$selected_branch})"; } } }
public function getTaxesRate(Address $address) { /* * EU-Legal * alternative method for tax calculation instead of static taxrate (LEGAL_SHIPTAXMETH) * Only if Cart exists and at least one product in cart, otherwise the alternative method could not be applied */ if (Configuration::get('LEGAL_SHIPTAXMETH') && ($cart = Context::getContext()->cart) && ($products = $cart->getProducts()) && !empty($products)) { return Cart::getTaxesAverageUsed($cart->id); } return parent::getTaxesRate($address); }
public function add($autodate = true, $nullValues = false) { if (_PS_VERSION_ >= '1.5') { return parent::add($autodate, $nullValues); } if (!parent::add($autodate, $nullValues)) { return false; } include_once dirname(__FILE__) . "/../../modules/agilemultipleseller/agilemultipleseller.php"; $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'carrier_owner` (id_owner,id_carrier,is_default) values(' . intval(Tools::getValue('id_seller')) . ',' . $this->id . ',' . intval(Tools::getValue('is_default')) . ')'; Db::getInstance()->Execute($sql); return true; }
/** * @since 1.5.0 * @see ObjectModel::delete() */ public function delete() { if (!parent::delete()) return false; Carrier::cleanPositions(); return (Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'cart_rule_carrier WHERE id_carrier = '.(int)$this->id) && $this->deleteTaxRulesGroup(Shop::getShops(true, null, true))); }
/** * @return mixed */ private function renderForm() { $options = array(); foreach (CarrierCore::getCarriers((int) Context::getContext()->language->id, true, false) as $carrier) { $options[] = array("id" => $carrier['id_carrier'], "name" => $carrier['name']); } // ddd(CarrierCore::getCarriers((int)Context::getContext()->language->id,true,true)); $fields_form = array('form' => array('legend' => array('title' => $this->l('Upload PinCode'), 'icon' => 'icon-cogs'), 'enctype' => 'multipart/form-data', 'input' => array(array('type' => 'select', 'label' => $this->l('Shipping method:'), 'desc' => $this->l('Choose a shipping method'), 'name' => 'SHIPPING_METHOD', 'required' => true, 'options' => array('query' => $options, 'id' => 'id', 'name' => 'name')), array('type' => 'file', 'label' => $this->l('Upload CSV'), 'name' => 'PINCODE_UPLOAD', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-default pull-right', 'name' => 'submitShipping'))); $fields_form_1 = array('form' => array('legend' => array('title' => $this->l('Cash On Delivery'), 'icon' => 'icon-cogs'), 'description' => $this->l('Define Your COD Setting Here!') . '<br />', 'input' => array(array('type' => 'text', 'label' => $this->l('COD Minimum Amount'), 'name' => 'COD_MINIMUM_AMOUNT'), array('type' => 'text', 'label' => $this->l('COD Fee'), 'name' => 'COD_FEE')), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-default pull-right', 'name' => 'submitCOD'))); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->override_folder = '/'; $helper->submit_action = 'submitModule'; $helper->module = $this; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array('currencies' => Currency::getCurrencies(), 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); $helper->override_folder = '/'; return $helper->generateForm(array($fields_form, $fields_form_1)); }
/** * Get all carriers in a given language * * @param int $id_lang Language id * @param bool $active Returns only active carriers when true * @param bool $delete * @param bool|int $id_zone * @param null|string $ids_group * @param $modules_filters, possible values: * PS_CARRIERS_ONLY * CARRIERS_MODULE * CARRIERS_MODULE_NEED_RANGE * PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE * ALL_CARRIERS * * @return array Carriers */ public function getCarriers($id_lang, $active = false, $delete = false, $id_zone = false, $ids_group = null, $modules_filters = self::PS_CARRIERS_ONLY) { return \CarrierCore::getCarriers($id_lang, $active, $delete, $id_zone, $ids_group, $modules_filters); }