/** * Returns the template's HTML content * * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_DELIVERY')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $path = _PS_PROD_IMG_DIR_ . $order_detail['image']->getExistingImgPath() . '.jpg'; $order_detail['image_tag'] = preg_replace('/\\.*' . preg_quote(__PS_BASE_URI__, '/') . '/', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, ImageManager::thumbnail($path, $name, 45, 'jpg', false), 1); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier, 'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY'))); $tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab'))); $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $country = new Country((int) $invoice_address->id_country); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_INVOICE')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $data = array('order' => $this->order, 'order_details' => $order_details, 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer); if (Tools::getValue('debug')) { die(json_encode($data)); } $this->smarty->assign($data); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); }
/** * Assign template vars for simplified stores */ protected function assignStoresSimplified() { $stores = Db::getInstance()->executeS(' SELECT s.*, cl.name country, st.iso_code state FROM ' . _DB_PREFIX_ . 'store s ' . Shop::addSqlAssociation('store', 's') . ' LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN ' . _DB_PREFIX_ . 'state st ON (st.id_state = s.id_state) WHERE s.active = 1 AND cl.id_lang = ' . (int) $this->context->language->id); $addresses_formated = array(); foreach ($stores as &$store) { $address = new Address(); $address->country = Country::getNameById($this->context->language->id, $store['id_country']); $address->address1 = $store['address1']; $address->address2 = $store['address2']; $address->postcode = $store['postcode']; $address->city = $store['city']; $addresses_formated[$store['id_store']] = AddressFormat::getFormattedLayoutData($address); $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_ . (int) $store['id_store'] . '.jpg'); if ($working_hours = $this->renderStoreWorkingHours($store)) { $store['working_hours'] = $working_hours; } } $this->context->smarty->assign(array('simplifiedStoresDiplay' => true, 'stores' => $stores, 'addresses_formated' => $addresses_formated)); }
public function renderForm() { $this->fields_form = array('legend' => array('title' => $this->l('Addresses'), 'icon' => 'icon-envelope-alt'), 'input' => array(array('type' => 'text_customer', 'label' => $this->l('Customer'), 'name' => 'id_customer', 'required' => false), array('type' => 'text', 'label' => $this->l('Identification Number'), 'name' => 'dni', 'required' => false, 'col' => '4', 'hint' => $this->l('DNI / NIF / NIE')), array('type' => 'text', 'label' => $this->l('Floor'), 'name' => 'floor', 'required' => true, 'col' => '4', 'hint' => $this->l('Floor')), array('type' => 'text', 'label' => $this->l('Lift'), 'name' => 'lift', 'required' => true, 'col' => '4', 'hint' => $this->l('Lift')), array('type' => 'text', 'label' => $this->l('Code_intercom'), 'name' => 'code_intercom', 'required' => false, 'col' => '4', 'hint' => $this->l('Code_intercom')), array('type' => 'text', 'label' => $this->l('Address alias'), 'name' => 'alias', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'textarea', 'label' => $this->l('Other'), 'name' => 'other', 'required' => false, 'cols' => 15, 'rows' => 3, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}')), 'submit' => array('title' => $this->l('Save'))); $id_customer = (int) Tools::getValue('id_customer'); if (!$id_customer && Validate::isLoadedObject($this->object)) { $id_customer = $this->object->id_customer; } if ($id_customer) { $customer = new Customer((int) $id_customer); $token_customer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id); } $this->tpl_form_vars = array('customer' => isset($customer) ? $customer : null, 'tokenCustomer' => isset($token_customer) ? $token_customer : null); // Order address fields depending on country format $addresses_fields = $this->processAddressFormat(); // we use delivery address $addresses_fields = $addresses_fields['dlv_all_fields']; // get required field $required_fields = AddressFormat::getFieldsRequired(); // Merge with field required $addresses_fields = array_unique(array_merge($addresses_fields, $required_fields)); $temp_fields = array(); foreach ($addresses_fields as $addr_field_item) { if ($addr_field_item == 'company') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'required' => in_array('company', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'); $temp_fields[] = array('type' => 'text', 'label' => $this->l('VAT number'), 'col' => '2', 'name' => 'vat_number', 'required' => in_array('vat_number', $required_fields)); } elseif ($addr_field_item == 'lastname') { if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) { $default_value = $customer->lastname; } else { $default_value = ''; } $temp_fields[] = array('type' => 'text', 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => in_array('lastname', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"�{}_$%:', 'default_value' => $default_value); } elseif ($addr_field_item == 'firstname') { if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) { $default_value = $customer->firstname; } else { $default_value = ''; } $temp_fields[] = array('type' => 'text', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => in_array('firstname', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"�{}_$%:', 'default_value' => $default_value); } elseif ($addr_field_item == 'address1') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'col' => '6', 'required' => in_array('address1', $required_fields)); } elseif ($addr_field_item == 'address2') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'col' => '6', 'required' => in_array('address2', $required_fields)); } elseif ($addr_field_item == 'postcode') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('Zip/Postal Code'), 'name' => 'postcode', 'col' => '2', 'required' => in_array('postcode', $required_fields)); } elseif ($addr_field_item == 'city') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'col' => '4', 'required' => in_array('city', $required_fields)); } elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') { $temp_fields[] = array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => in_array('Country:name', $required_fields) || in_array('country', $required_fields), 'col' => '4', 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')); $temp_fields[] = array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => false, 'col' => '4', 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name')); } elseif ($addr_field_item == 'phone') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('Home phone'), 'name' => 'phone', 'required' => in_array('phone', $required_fields) || Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'col' => '4', 'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : ''); } elseif ($addr_field_item == 'phone_mobile') { $temp_fields[] = array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields) || Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'col' => '4', 'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : ''); } } // merge address format with the rest of the form array_splice($this->fields_form['input'], 3, 0, $temp_fields); return AdminController::renderForm(); }
public function process() { parent::process(); $multipleAddressesFormated = array(); $ordered_fields = array(); $customer = new Customer((int) self::$cookie->id_customer); if (!Validate::isLoadedObject($customer)) { die(Tools::displayError('Customer not found')); } // Retro Compatibility Theme < 1.4.1 self::$smarty->assign('addresses', $customer->getAddresses((int) self::$cookie->id_lang)); $customerAddressesDetailed = $customer->getAddresses((int) self::$cookie->id_lang); $total = 0; foreach ($customerAddressesDetailed as $addressDetailed) { $address = new Address($addressDetailed['id_address']); $multipleAddressesFormated[$total] = AddressFormat::getFormattedLayoutData($address); unset($address); ++$total; // Retro theme < 1.4.2 $ordered_fields = AddressFormat::getOrderedAddressFields($addressDetailed['id_country'], false, true); } // Retro theme 1.4.2 if ($key = array_search('Country:name', $ordered_fields)) { $ordered_fields[$key] = 'country'; } self::$smarty->assign('addresses_style', array('company' => 'address_company', 'vat_number' => 'address_company', 'firstname' => 'address_name', 'lastname' => 'address_name', 'address1' => 'address_address1', 'address2' => 'address_address2', 'city' => 'address_city', 'country' => 'address_country', 'phone' => 'address_phone', 'phone_mobile' => 'address_phone_mobile', 'alias' => 'address_title')); self::$smarty->assign(array('multipleAddresses' => $multipleAddressesFormated, 'ordered_fields' => $ordered_fields)); unset($customer); }
/** * Returns the template's HTML content * * @return string HTML content */ public function getContent() { $delivery_address = $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $this->order->total_paid_tax_excl = $this->order->total_paid_tax_incl = $this->order->total_products = $this->order->total_products_wt = 0; if ($this->order_slip->amount > 0) { foreach ($this->order->products as &$product) { $product['total_price_tax_excl'] = $product['unit_price_tax_excl'] * $product['product_quantity']; $product['total_price_tax_incl'] = $product['unit_price_tax_incl'] * $product['product_quantity']; if ($this->order_slip->partial == 1) { $order_slip_detail = Db::getInstance()->getRow(' SELECT * FROM `' . _DB_PREFIX_ . 'order_slip_detail` WHERE `id_order_slip` = ' . (int) $this->order_slip->id . ' AND `id_order_detail` = ' . (int) $product['id_order_detail']); $product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl']; $product['total_price_tax_incl'] = $order_slip_detail['amount_tax_incl']; } $this->order->total_products += $product['total_price_tax_excl']; $this->order->total_products_wt += $product['total_price_tax_incl']; $this->order->total_paid_tax_excl = $this->order->total_products; $this->order->total_paid_tax_incl = $this->order->total_products_wt; } } else { $this->order->products = null; } unset($product); // remove reference if ($this->order_slip->shipping_cost == 0) { $this->order->total_shipping_tax_incl = $this->order->total_shipping_tax_excl = 0; } $tax = new Tax(); $tax->rate = $this->order->carrier_tax_rate; $tax_calculator = new TaxCalculator(array($tax)); $tax_excluded_display = Group::getPriceDisplayMethod((int) $customer->id_default_group); $this->order->total_shipping_tax_incl = $this->order_slip->total_shipping_tax_incl; $this->order->total_shipping_tax_excl = $this->order_slip->total_shipping_tax_excl; $this->order_slip->shipping_cost_amount = $tax_excluded_display ? $this->order_slip->total_shipping_tax_excl : $this->order_slip->total_shipping_tax_incl; $this->order->total_paid_tax_incl += $this->order->total_shipping_tax_incl; $this->order->total_paid_tax_excl += $this->order->total_shipping_tax_excl; $total_cart_rule = 0; if ($this->order_slip->order_slip_type == 1 && is_array($cart_rules = $this->order->getCartRules($this->order_invoice->id))) { foreach ($cart_rules as $cart_rule) { if ($tax_excluded_display) { $total_cart_rule += $cart_rule['value_tax_excl']; } else { $total_cart_rule += $cart_rule['value']; } } } $this->smarty->assign(array('order' => $this->order, 'order_slip' => $this->order_slip, 'order_details' => $this->order->products, 'cart_rules' => $this->order_slip->order_slip_type == 1 ? $this->order->getCartRules($this->order_invoice->id) : false, 'amount_choosen' => $this->order_slip->order_slip_type == 2 ? true : false, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address), 'tax_excluded_display' => $tax_excluded_display, 'total_cart_rule' => $total_cart_rule)); $tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('order-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('order-slip.product-tab')), 'total_tab' => $this->smarty->fetch($this->getTemplate('order-slip.total-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('order-slip.payment-tab')), 'tax_tab' => $this->getTaxTabContent()); $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplate('order-slip')); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_DELIVERY')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
/** * Returns the shop address * * @return string */ protected function getShopAddress() { $shop_address = ''; $shop_address_obj = $this->shop->getAddress(); if (isset($shop_address_obj) && $shop_address_obj instanceof Address) { $shop_address = AddressFormat::generateAddress($shop_address_obj, array(), ' - ', ' '); } return $shop_address; }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $this->smarty->assign(array('order' => $this->order, 'order_details' => $this->order_invoice->getProducts(), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $this->smarty->assign(array('order_return' => $this->order_return, 'return_nb_days' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'), 'products' => OrderReturn::getOrdersReturnProducts((int) $this->order_return->id, $this->order), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'shop_address' => AddressFormat::generateAddress($this->shop->getAddress(), array(), '<br />', ' '))); return $this->smarty->fetch($this->getTemplate('order-return')); }
public function getFormat() { $fields = AddressFormat::getOrderedAddressFields($this->country->id, true, true); $required = array_flip(AddressFormat::getFieldsRequired()); $format = ['id_address' => (new FormField())->setName('id_address')->setType('hidden'), 'id_customer' => (new FormField())->setName('id_customer')->setType('hidden'), 'back' => (new FormField())->setName('back')->setType('hidden'), 'token' => (new FormField())->setName('token')->setType('hidden'), 'alias' => (new FormField())->setName('alias')->setLabel($this->getFieldLabel('alias'))]; foreach ($fields as $field) { $formField = new FormField(); $formField->setName($field); $fieldParts = explode(':', $field, 2); if (count($fieldParts) === 1) { if ($field === 'postcode') { if ($this->country->need_zip_code) { $formField->setRequired(true); } } } elseif (count($fieldParts) === 2) { list($entity, $entityField) = $fieldParts; // Fields specified using the Entity:field // notation are actually references to other // entities, so they should be displayed as a select $formField->setType('select'); // Also, what we really want is the id of the linked entity $formField->setName('id_' . strtolower($entity)); if ($entity === 'Country') { $formField->setType('countrySelect'); $formField->setValue($this->country->id); foreach ($this->availableCountries as $country) { $formField->addAvailableValue($country['id_country'], $country[$entityField]); } } elseif ($entity === 'State') { if ($this->country->contains_states) { $states = State::getStatesByIdCountry($this->country->id); foreach ($states as $state) { $formField->addAvailableValue($state['id_state'], $state[$entityField]); } $formField->setRequired(true); } } } $formField->setLabel($this->getFieldLabel($field)); if (!$formField->isRequired()) { // Only trust the $required array for fields // that are not marked as required. // $required doesn't have all the info, and fields // may be required for other reasons than what // AddressFormat::getFieldsRequired() says. $formField->setRequired(array_key_exists($field, $required)); } $format[$formField->getName()] = $formField; } return $this->addConstraints($this->addMaxLength($format)); }
/** * Returns the shop address * @return string */ protected function getShopAddress() { $shop_address = ''; if (Validate::isLoadedObject($this->shop)) { Shop::setContext(Shop::CONTEXT_SHOP, $this->shop->id); $shop_address_obj = $this->shop->getAddress(); if (isset($shop_address_obj) && $shop_address_obj instanceof Address) { $shop_address = AddressFormat::generateAddress($shop_address_obj, array(), ' - ', ' '); } return $shop_address; } return $shop_address; }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $country = new Country((int) $this->order->id_address_invoice); $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $this->smarty->assign(array('order' => $this->order, 'order_details' => $this->order_invoice->getProducts(), 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer)); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $this->smarty->assign(array('order' => $this->order, 'order_details' => $this->order_invoice->getProducts(), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
public function process() { parent::process(); $customer = new Customer((int) self::$cookie->id_customer); if (!Validate::isLoadedObject($customer)) { die(Tools::displayError('Customer not found')); } self::$smarty->assign('addresses', $customer->getAddresses((int) self::$cookie->id_lang)); $values = array(); $customer_address = $customer->getAddresses((int) self::$cookie->id_lang); foreach ($customer_address as $addr_item) { $ordered_fields = AddressFormat::getOrderedAddressFields($addr_item['id_country']); } self::$smarty->assign('addresses_style', array('company' => 'address_company', 'vat_number' => 'address_company', 'firstname' => 'address_name', 'lastname' => 'address_name', 'address1' => 'address_address1', 'address2' => 'address_address2', 'city' => 'address_city', 'country' => 'address_country', 'phone' => 'address_phone', 'phone_mobile' => 'address_phone_mobile', 'alias' => 'address_title')); self::$smarty->assign('ordered_fields', $ordered_fields); }
public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $carrier = new Carrier((int) $this->order->id_carrier); $data = array('order' => $this->order, 'order_details' => $this->order->getProducts(), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'customer' => $customer, 'carrier' => $carrier); $this->smarty->assign($data); $order_pdf_tpl = _PS_MODULE_DIR_ . '/mobassistantconnector/views/templates/front/order_pdf.tpl'; return $this->smarty->fetch($order_pdf_tpl); }
public function initContent() { parent::initContent(); $customer = $this->context->customer; /* * Get delivery address and data. */ if ((int) $this->context->cart->id_address_delivery) { $shipto_delivery_address = new Address((int) $this->context->cart->id_address_delivery); $country_name = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'country_lang WHERE id_country = ' . (int) Configuration::get('SHIPTOMYID_DEFAULT_ADDR_COUNTRY') . ' '); $state_name = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'state WHERE id_state = ' . (int) Configuration::get('SHIPTOMYID_DEFAULT_ADDR_STATE') . ' '); $default_delivery_address = array('address1' => Configuration::get('SHIPTOMYID_DEFAULT_ADDR_ADDRESS'), 'address2' => Configuration::get('SHIPTOMYID_DEFAULT_ADDR_ADDRESS2'), 'city' => Configuration::get('SHIPTOMYID_DEFAULT_ADDR_CITY'), 'zip' => Configuration::get('SHIPTOMYID_DEFAULT_ADDR_POSTCODE'), 'phone' => Configuration::get('SHIPTOMYID_DEFAULT_ADDR_PHONE'), 'alise' => Configuration::get('SHIPTOMYID_DEFAULT_ADDR_ALIAS'), 'country' => $country_name, 'state' => $state_name); $this->context->smarty->assign(array('shipto_delivery_address' => $shipto_delivery_address, 'shipto_default_delivery_address' => $default_delivery_address)); } /* * Get addresses. */ $customer_addresses = $customer->getAddresses($this->context->language->id, false); // On supprime de la liste les addresse shipto foreach ($customer_addresses as $key => $address) { if (strpos(Tools::strtolower($address['alias']), 'ship2myid') !== false) { $customer_addresses[$key]['shipto_addr'] = 1; } } // Getting a list of formated address fields with associated values $formated_address_fields_values_list = array(); foreach ($customer_addresses as $i => $address) { if (!Address::isCountryActiveById((int) $address['id_address'])) { unset($customer_addresses[$i]); } $tmp_address = new Address($address['id_address']); $formated_address_fields_values_list[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']); $formated_address_fields_values_list[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmp_address, $formated_address_fields_values_list[$address['id_address']]['ordered_fields']); unset($tmp_address); } if (key($customer_addresses) != 0) { $customer_addresses = array_values($customer_addresses); } $this->context->smarty->assign(array('addresses' => $customer_addresses, 'formatedAddressFieldsValuesList' => $formated_address_fields_values_list)); if (class_exists('Tools') && method_exists('Tools', 'version_compare') && Tools::version_compare(_PS_VERSION_, '1.6', '>=') === true) { $this->setTemplate('front-16.tpl'); } else { $this->setTemplate('front.tpl'); } }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $this->order->total_products = $this->order->total_products_wt = 0; foreach ($this->order->products as &$product) { $product['total_price_tax_excl'] = $product['unit_price_tax_excl'] * $product['product_quantity']; $product['total_price_tax_incl'] = $product['unit_price_tax_incl'] * $product['product_quantity']; if ($this->order_slip->partial == 1) { $order_slip_detail = Db::getInstance()->getRow(' SELECT * FROM `' . _DB_PREFIX_ . 'order_slip_detail` WHERE `id_order_slip` = ' . (int) $this->order_slip->id . ' AND `id_order_detail` = ' . (int) $product['id_order_detail']); $product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl']; $product['total_price_tax_incl'] = $order_slip_detail['amount_tax_incl']; } $this->order->total_products += $product['total_price_tax_excl']; $this->order->total_products_wt += $product['total_price_tax_incl']; $this->order->total_paid_tax_excl = $this->order->total_products; $this->order->total_paid_tax_incl = $this->order->total_products_wt; } unset($product); // remove reference if ($this->order_slip->shipping_cost == 0) { $this->order->total_shipping_tax_incl = $this->order->total_shipping_tax_excl = 0; } if ($this->order_slip->partial == 1 && $this->order_slip->shipping_cost_amount > 0) { $this->order->total_shipping_tax_incl = $this->order_slip->shipping_cost_amount; } $tax = new Tax(); $tax->rate = $this->order->carrier_tax_rate; $tax_calculator = new TaxCalculator(array($tax)); $this->order->total_shipping_tax_excl = Tools::ps_round($tax_calculator->removeTaxes($this->order_slip->shipping_cost_amount), 2); $this->order->total_paid_tax_incl += $this->order->total_shipping_tax_incl; $this->order->total_paid_tax_excl += $this->order->total_shipping_tax_excl; $this->smarty->assign(array('order' => $this->order, 'order_slip' => $this->order_slip, 'order_details' => $this->order->products, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod((int) $customer->id_default_group), 'tax_tab' => $this->getTaxTabContent())); return $this->smarty->fetch($this->getTemplate('order-slip')); }
private function _buildOrderedFieldsShop($formFields) { $associatedOrderKey = array('PS_SHOP_NAME' => 'company', 'PS_SHOP_ADDR1' => 'address1', 'PS_SHOP_ADDR2' => 'address2', 'PS_SHOP_CITY' => 'city', 'PS_SHOP_STATE_ID' => 'State:name', 'PS_SHOP_CODE' => 'postcode', 'PS_SHOP_COUNTRY_ID' => 'Country:name', 'PS_SHOP_PHONE' => 'phone'); $this->_fieldsShop = array(); $orderedFields = AddressFormat::getOrderedAddressFields(Configuration::get('PS_SHOP_COUNTRY_ID'), false, true); foreach ($orderedFields as $lineFields) { if ($patterns = explode(' ', $lineFields)) { foreach ($patterns as $pattern) { if ($key = array_search($pattern, $associatedOrderKey)) { $this->_fieldsShop[$key] = $formFields[$key]; } } } } foreach ($formFields as $key => $value) { if (!isset($this->_fieldsShop[$key])) { $this->_fieldsShop[$key] = $formFields[$key]; } } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $total = 0; $multiple_addresses_formated = array(); $ordered_fields = array(); $addresses = $this->context->customer->getAddresses($this->context->language->id); // @todo getAddresses() should send back objects foreach ($addresses as $detail) { $address = new Address($detail['id_address']); $multiple_addresses_formated[$total] = AddressFormat::getFormattedLayoutData($address); unset($address); ++$total; // Retro theme < 1.4.2 $ordered_fields = AddressFormat::getOrderedAddressFields($detail['id_country'], false, true); } // Retro theme 1.4.2 if ($key = array_search('Country:name', $ordered_fields)) { $ordered_fields[$key] = 'country'; } $addresses_style = array('company' => 'address_company', 'vat_number' => 'address_company', 'firstname' => 'address_name', 'lastname' => 'address_name', 'address1' => 'address_address1', 'address2' => 'address_address2', 'city' => 'address_city', 'country' => 'address_country', 'phone' => 'address_phone', 'phone_mobile' => 'address_phone_mobile', 'alias' => 'address_title'); $this->context->smarty->assign(array('addresses_style' => $addresses_style, 'multipleAddresses' => $multiple_addresses_formated, 'ordered_fields' => $ordered_fields, 'addresses' => $addresses)); $this->setTemplate(_PS_THEME_DIR_ . 'addresses.tpl'); }
/** * get formatted string address */ protected function processStoreAddress($store) { $ignore_field = array('firstname', 'lastname'); $out_datas = array(); $address_datas = AddressFormat::getOrderedAddressFields($store['id_country'], false, true); $state = isset($store['id_state']) ? new State($store['id_state']) : null; foreach ($address_datas as $data_line) { $data_fields = explode(' ', $data_line); $addr_out = array(); $data_fields_mod = false; foreach ($data_fields as $field_item) { $field_item = trim($field_item); if (!in_array($field_item, $ignore_field) && !empty($store[$field_item])) { $addr_out[] = $field_item == 'city' && $state && isset($state->iso_code) && strlen($state->iso_code) ? $store[$field_item] . ', ' . $state->iso_code : $store[$field_item]; $data_fields_mod = true; } } if ($data_fields_mod) { $out_datas[] = implode(' ', $addr_out); } } $out = implode('<br />', $out_datas); return $out; }
public function getContent() { if (isset($this->order) and Validate::isLoadedObject($this->order) and Module::isInstalled('agilemultipleseller')) { $carrier = new Carrier($this->order->id_carrier); $this->smarty->assign(array('order_number_text' => sprintf('%06d', $this->order->id), 'carrier_name' => $carrier->name)); } $content = parent::getContent(); if (isset($this->order) and Validate::isLoadedObject($this->order) and Module::isInstalled('agilepickupcenter')) { $country = new Country((int) $this->order->id_address_invoice); $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = $formatted_invoice_address; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } require_once _PS_ROOT_DIR_ . "/modules/agilepickupcenter/agilepickupcenter.php"; $pickupcenter = new AgilePickupCenter(); $delivery_address = $formatted_delivery_address . "<BR>" . $pickupcenter->displayInfoByCart($this->order->id_cart); $this->smarty->assign(array('delivery_address' => $delivery_address)); $content = $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); } return $content; }
protected function processAddressFormat() { $addressDelivery = new Address((int) $this->context->cart->id_address_delivery); $addressInvoice = new Address((int) $this->context->cart->id_address_invoice); $invoiceAddressFields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country, false, true); $deliveryAddressFields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country, false, true); $this->context->smarty->assign(array('inv_adr_fields' => $invoiceAddressFields, 'dlv_adr_fields' => $deliveryAddressFields)); }
/** * Get Address formats used by the country where the address id retrieved from POST/GET is. * * @return array address formats */ protected function processAddressFormat() { $tmp_addr = new Address((int) Tools::getValue('id_address')); $selected_country = $tmp_addr && $tmp_addr->id_country ? $tmp_addr->id_country : (int) Configuration::get('PS_COUNTRY_DEFAULT'); $inv_adr_fields = AddressFormat::getOrderedAddressFields($selected_country, false, true); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($selected_country, false, true); $inv_all_fields = array(); $dlv_all_fields = array(); $out = array(); foreach (array('inv', 'dlv') as $adr_type) { foreach (${$adr_type . '_adr_fields'} as $fields_line) { foreach (explode(' ', $fields_line) as $field_item) { ${$adr_type . '_all_fields'}[] = trim($field_item); } } $out[$adr_type . '_adr_fields'] = ${$adr_type . '_adr_fields'}; $out[$adr_type . '_all_fields'] = ${$adr_type . '_all_fields'}; } return $out; }
protected function processAddressFormat(Address $delivery, Address $invoice) { $inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country, false, true); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($delivery->id_country, false, true); $this->context->smarty->assign('inv_adr_fields', $inv_adr_fields); $this->context->smarty->assign('dlv_adr_fields', $dlv_adr_fields); }
public static function getCurrentFormattedShopAddress($id_shop = null) { $address = new Address(); $address->company = Configuration::get('PS_SHOP_NAME', null, null, $id_shop); $address->address1 = Configuration::get('PS_SHOP_ADDR1', null, null, $id_shop); $address->address2 = Configuration::get('PS_SHOP_ADDR2', null, null, $id_shop); $address->postcode = Configuration::get('PS_SHOP_CODE', null, null, $id_shop); $address->city = Configuration::get('PS_SHOP_CITY', null, null, $id_shop); $address->phone = Configuration::get('PS_SHOP_PHONE', null, null, $id_shop); $address->id_country = Configuration::get('PS_SHOP_COUNTRY_ID', null, null, $id_shop); return AddressFormat::generateAddress($address, array(), '<br />', ' '); }
protected function displayValidFields() { /* The following translations are needed later - don't remove the comments! $this->l('Customer'); $this->l('Warehouse'); $this->l('Country'); $this->l('State'); $this->l('Address'); */ $html_tabnav = '<ul class="nav nav-tabs" id="custom-address-fields">'; $html_tabcontent = '<div class="tab-content" >'; $object_list = AddressFormat::getLiableClass('Address'); $object_list['Address'] = null; // Get the available properties for each class $i = 0; $class_tab_active = 'active'; foreach ($object_list as $class_name => &$object) { if ($i != 0) { $class_tab_active = ''; } $fields = array(); $html_tabnav .= '<li class="' . $class_tab_active . '""> <a href="#availableListFieldsFor_' . $class_name . '"><i class="icon-caret-down"></i> ' . Translate::getAdminTranslation($class_name, 'AdminCountries') . '</a></li>'; foreach (AddressFormat::getValidateFields($class_name) as $name) { $fields[] = '<a href="javascript:void(0);" class="addPattern btn btn-default btn-xs" id="' . ($class_name == 'Address' ? $name : $class_name . ':' . $name) . '"> <i class="icon-plus-sign"></i> ' . ObjectModel::displayFieldName($name, $class_name) . '</a>'; } $html_tabcontent .= ' <div class="tab-pane availableFieldsList panel ' . $class_tab_active . '" id="availableListFieldsFor_' . $class_name . '"> ' . implode(' ', $fields) . '</div>'; unset($object); $i++; } $html_tabnav .= '</ul>'; $html_tabcontent .= '</div>'; return $html = $html_tabnav . $html_tabcontent; }
/** * Return useful informations for cart * * @return array Cart details */ public function getSummaryDetails($id_lang = null, $refresh = false) { $context = Context::getContext(); if (!$id_lang) { $id_lang = $context->language->id; } $delivery = new Address((int) $this->id_address_delivery); $invoice = new Address((int) $this->id_address_invoice); // New layout system with personalization fields $formatted_addresses = array('delivery' => AddressFormat::getFormattedLayoutData($delivery), 'invoice' => AddressFormat::getFormattedLayoutData($invoice)); $base_total_tax_inc = $this->getOrderTotal(true); $base_total_tax_exc = $this->getOrderTotal(false); $total_tax = $base_total_tax_inc - $base_total_tax_exc; if ($total_tax < 0) { $total_tax = 0; } $currency = new Currency($this->id_currency); $products = $this->getProducts($refresh); $gift_products = array(); $cart_rules = $this->getCartRules(); $total_shipping = $this->getTotalShippingCost(); $total_shipping_tax_exc = $this->getTotalShippingCost(null, false); $total_products_wt = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS); $total_products = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS); $total_discounts = $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS); $total_discounts_tax_exc = $this->getOrderTotal(false, Cart::ONLY_DISCOUNTS); // The cart content is altered for display foreach ($cart_rules as &$cart_rule) { // If the cart rule is automatic (wihtout any code) and include free shipping, it should not be displayed as a cart rule but only set the shipping cost to 0 if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^' . CartRule::BO_ORDER_CODE_PREFIX . '[0-9]+/', $cart_rule['code']))) { $cart_rule['value_real'] -= $total_shipping; $cart_rule['value_tax_exc'] -= $total_shipping_tax_exc; $cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); $cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); if ($total_discounts > $cart_rule['value_real']) { $total_discounts -= $total_shipping; } if ($total_discounts_tax_exc > $cart_rule['value_tax_exc']) { $total_discounts_tax_exc -= $total_shipping_tax_exc; } // Update total shipping $total_shipping = 0; $total_shipping_tax_exc = 0; } if ($cart_rule['gift_product']) { foreach ($products as $key => &$product) { if (empty($product['gift']) && $product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) { // Update total products $total_products_wt = Tools::ps_round($total_products_wt - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); $total_products = Tools::ps_round($total_products - $product['price'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); // Update total discounts $total_discounts = Tools::ps_round($total_discounts - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); $total_discounts_tax_exc = Tools::ps_round($total_discounts_tax_exc - $product['price'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); // Update cart rule value $cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); $cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'] - $product['price'], (int) $context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); // Update product quantity $product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); $product['total'] = Tools::ps_round($product['total'] - $product['price'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_); $product['cart_quantity']--; if (!$product['cart_quantity']) { unset($products[$key]); } // Add a new product line $gift_product = $product; $gift_product['cart_quantity'] = 1; $gift_product['price'] = 0; $gift_product['price_wt'] = 0; $gift_product['total_wt'] = 0; $gift_product['total'] = 0; $gift_product['gift'] = true; $gift_products[] = $gift_product; break; // One gift product per cart rule } } } } foreach ($cart_rules as $key => &$cart_rule) { if ($cart_rule['value_real'] == 0) { unset($cart_rules[$key]); } } return array('delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'formattedAddresses' => $formatted_addresses, 'products' => array_values($products), 'gift_products' => $gift_products, 'discounts' => $cart_rules, 'is_virtual_cart' => (int) $this->isVirtualCart(), 'total_discounts' => $total_discounts, 'total_discounts_tax_exc' => $total_discounts_tax_exc, 'total_wrapping' => $this->getOrderTotal(true, Cart::ONLY_WRAPPING), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_WRAPPING), 'total_shipping' => $total_shipping, 'total_shipping_tax_exc' => $total_shipping_tax_exc, 'total_products_wt' => $total_products_wt, 'total_products' => $total_products, 'total_price' => $base_total_tax_inc, 'total_tax' => $total_tax, 'total_price_without_tax' => $base_total_tax_exc, 'is_multi_address_delivery' => $this->isMultiAddressDelivery() || (int) Tools::getValue('multi-shipping') == 1, 'free_ship' => $total_shipping ? 0 : 1, 'carrier' => new Carrier($this->id_carrier, $id_lang)); }
public function ajaxReturnVars() { $id_cart = (int) $this->context->cart->id; $message_content = ''; if ($message = Message::getMessageByCartId((int) $this->context->cart->id)) { $message_content = $message['message']; } $cart_rules = $this->context->cart->getCartRules(CartRule::FILTER_ACTION_SHIPPING); $free_shipping = false; if (count($cart_rules)) { foreach ($cart_rules as $cart_rule) { if ($cart_rule['id_cart_rule'] == CartRule::getIdByCode(CartRule::BO_ORDER_CODE_PREFIX . (int) $this->context->cart->id)) { $free_shipping = true; break; } } } $addresses = $this->context->customer->getAddresses((int) $this->context->cart->id_lang); foreach ($addresses as &$data) { $address = new Address((int) $data['id_address']); $data['formated_address'] = AddressFormat::generateAddress($address, array(), "<br />"); } return array('summary' => $this->getCartSummary(), 'delivery_option_list' => $this->getDeliveryOptionList(), 'cart' => $this->context->cart, 'currency' => new Currency($this->context->cart->id_currency), 'addresses' => $addresses, 'id_cart' => $id_cart, 'order_message' => $message_content, 'link_order' => $this->context->link->getPageLink('order', false, (int) $this->context->cart->id_lang, 'step=3&recover_cart=' . $id_cart . '&token_cart=' . md5(_COOKIE_KEY_ . 'recover_cart_' . $id_cart)), 'free_shipping' => (int) $free_shipping); }
protected function processAddressFormat() { $addressItems = array(); $addressFormat = AddressFormat::getOrderedAddressFields(Configuration::get('PS_COUNTRY_DEFAULT'), false, true); $requireFormFieldsList = AddressFormat::$requireFormFieldsList; foreach ($addressFormat as $addressline) { foreach (explode(' ', $addressline) as $addressItem) { $addressItems[] = trim($addressItem); } } // Add missing require fields for a new user susbscription form foreach ($requireFormFieldsList as $fieldName) { if (!in_array($fieldName, $addressItems)) { $addressItems[] = trim($fieldName); } } foreach (array('inv', 'dlv') as $addressType) { self::$smarty->assign(array($addressType . '_adr_fields' => $addressFormat, $addressType . '_all_fields' => $addressItems)); } }