/** * Get formatted string address * * @param array $store * * @return string */ protected function processStoreAddress($store) { // StarterTheme: Remove method when google maps v3 is done $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 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); }
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)); }
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 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'); } }
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'); }
public function preProcess() { parent::preProcess(); if (Tools::isSubmit('submitMessage')) { $idOrder = (int) Tools::getValue('id_order'); $msgText = htmlentities(Tools::getValue('msgText'), ENT_COMPAT, 'UTF-8'); if (!$idOrder or !Validate::isUnsignedId($idOrder)) { $this->errors[] = Tools::displayError('Order is no longer valid'); } elseif (empty($msgText)) { $this->errors[] = Tools::displayError('Message cannot be blank'); } elseif (!Validate::isMessage($msgText)) { $this->errors[] = Tools::displayError('Message is invalid (HTML is not allowed)'); } if (!sizeof($this->errors)) { $order = new Order((int) $idOrder); if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) { $message = new Message(); $message->id_customer = (int) self::$cookie->id_customer; $message->message = $msgText; $message->id_order = (int) $idOrder; $message->private = false; $message->add(); if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) { $to = strval(Configuration::get('PS_SHOP_EMAIL')); } else { $to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE')); $to = strval($to->email); } $toName = strval(Configuration::get('PS_SHOP_NAME')); $customer = new Customer((int) self::$cookie->id_customer); if (Validate::isLoadedObject($customer)) { Mail::Send((int) self::$cookie->id_lang, 'order_customer_comment', Mail::l('Message from a customer', (int) self::$cookie->id_lang), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $message->id_order, '{order_name}' => sprintf("#%06d", (int) $message->id_order), '{message}' => $message->message), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname); } if (Tools::getValue('ajax') != 'true') { Tools::redirect('order-detail.php?id_order=' . (int) $idOrder); } } else { $this->errors[] = Tools::displayError('Order not found'); } } } if (!($id_order = (int) Tools::getValue('id_order')) or !Validate::isUnsignedId($id_order)) { $this->errors[] = Tools::displayError('Order ID required'); } else { $order = new Order($id_order); if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) { $id_order_state = (int) $order->getCurrentState(); $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); $addressInvoice = new Address((int) $order->id_address_invoice); $addressDelivery = new Address((int) $order->id_address_delivery); // $stateInvoiceAddress = new State((int)$addressInvoice->id_state); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) { self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts)); } $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); $customer = new Customer($order->id_customer); self::$smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => Message::getMessagesByOrderId((int) $order->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas)); if ($carrier->url and $order->shipping_number) { self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); } self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); unset($carrier); unset($addressInvoice); unset($addressDelivery); } else { $this->errors[] = Tools::displayError('Cannot find this order'); } unset($order); } }
private function _processStoreAddress($store) { $ignore_field = array('firstname' => 1, 'lastname' => 1); $out = ''; $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); $adr_out = array(); $data_fields_mod = false; foreach ($data_fields as $field_item) { $field_item = trim($field_item); if (!isset($ignore_field[$field_item]) && !empty($store[$field_item]) && $store[$field_item] != '') { $adr_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(' ', $adr_out); } } $out = implode('<br />', $out_datas); return $out; }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) { $this->errors[] = Tools::displayError('Order ID required'); } else { $order = new Order($id_order); if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) { $id_order_state = (int) $order->getCurrentState(); $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); $addressInvoice = new Address((int) $order->id_address_invoice); $addressDelivery = new Address((int) $order->id_address_delivery); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) { $this->context->smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts)); } $products = $order->getProducts(); /* DEPRECATED: customizedDatas @since 1.5 */ $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); OrderReturn::addReturnedQuantity($products, $order->id); $customer = new Customer($order->id_customer); $this->context->smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection()), 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas)); if ($carrier->url && $order->shipping_number) { $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); } $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order))); Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order)); unset($carrier, $addressInvoice, $addressDelivery); } else { $this->errors[] = Tools::displayError('This order cannot be found.'); } unset($order); } $this->setTemplate(_PS_THEME_DIR_ . 'order-detail.tpl'); }
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); }
/** * @param Object Address $the_address that needs to be txt formated * @return String the txt formated address block */ protected function _getTxtFormatedAddress($the_address) { $adr_fields = AddressFormat::getOrderedAddressFields($the_address->id_country, false, true); $r_values = array(); foreach ($adr_fields as $fields_line) { $tmp_values = array(); foreach (explode(' ', $fields_line) as $field_item) { $field_item = trim($field_item); $tmp_values[] = $the_address->{$field_item}; } $r_values[] = implode(' ', $tmp_values); } $out = implode("\n", $r_values); return $out; }
public static function getFormattedLayoutData($address) { $layoutData = array(); if ($address && $address instanceof Address) { $layoutData['ordered'] = AddressFormat::getOrderedAddressFields((int) $address->id_country); $layoutData['formated'] = AddressFormat::getFormattedAddressFieldsValues($address, $layoutData['ordered']); $layoutData['object'] = array(); $reflect = new ReflectionObject($address); $public_properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC); foreach ($public_properties as $property) { if (isset($address->{$property->getName()})) { $layoutData['object'][$property->getName()] = $address->{$property->getName()}; } } } return $layoutData; }
/** * Assign template vars related to address format */ protected function assignAddressFormat() { $id_country = is_null($this->_address) ? (int) $this->id_country : (int) $this->_address->id_country; $requireFormFieldsList = AddressFormat::getFieldsRequired(); $ordered_adr_fields = AddressFormat::getOrderedAddressFields($id_country, true, true); $ordered_adr_fields = array_unique(array_merge($ordered_adr_fields, $requireFormFieldsList)); $this->context->smarty->assign(array('ordered_adr_fields' => $ordered_adr_fields, 'required_fields' => $requireFormFieldsList)); }
public function process() { parent::process(); self::$smarty->assign(array('is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int) $this->id_order), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int) $this->id_order, (int) $this->id_module))); if (self::$cookie->is_guest) { self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order))); /* If guest we clear the cookie for security reason */ self::$cookie->logout(); } else { self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order))); } //assign order details here $order = new Order($this->id_order); if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) { $id_order_state = (int) $order->getCurrentState(); $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); $addressInvoice = new Address((int) $order->id_address_invoice); $addressDelivery = new Address((int) $order->id_address_delivery); // $stateInvoiceAddress = new State((int)$addressInvoice->id_state); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) { self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts)); } self::$smarty->assign('order_total', Tools::ps_round($order->total_paid)); self::$smarty->assign('order_total_usd', Tools::ps_round(Tools::convertPrice($order->total_paid, self::$cookie->id_currency, false))); $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); $customer = new Customer($order->id_customer); $order->customization_fee = Cart::getCustomizationCostStatic((int) $order->id_cart); $totalQuantity = 0; foreach ($products as $productRow) { $totalQuantity += $productRow['product_quantity']; } if (strpos($order->payment, 'COD') === false) { self::$smarty->assign('paymentMethod', 'ONLINE'); } else { self::$smarty->assign('paymentMethod', 'COD'); } $shippingdate = new DateTime($order->expected_shipping_date); self::$smarty->assign(array('shipping_date' => $shippingdate->format("F j, Y"), 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => Message::getMessagesByOrderId((int) $order->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas, 'totalQuantity' => $totalQuantity)); if ($carrier->url and $order->shipping_number) { self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); } self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); //FB Share //$products = $order->getProducts(); $orderProducts = array(); $productMaxVal = 0; $productMaxId = null; foreach ($products as $product) { array_push($orderProducts, $product['product_id']); if ($product['product_price'] > $productMaxVal) { $productMaxId = $product['product_id']; $productMaxVal = $product['product_price']; } } $productObj = new Product($productMaxId, true, 1); self::$smarty->assign('fbShareProductObject', $productObj->getLink()); self::$smarty->assign('fbShareProductObjectId', $productMaxId); self::$smarty->assign('orderProducts', implode(",", $orderProducts)); self::$cookie->shareProductCode = md5(time() . $productMaxId); self::$cookie->write(); unset($carrier); unset($addressInvoice); unset($addressDelivery); } }
private function _processStoreAddress($store) { $ignore_field = array('firstname' => 1, 'lastname' => 1); $out = ''; $out_datas = array(); $address_datas = AddressFormat::getOrderedAddressFields($store['id_country']); foreach ($address_datas as $data_line) { $data_fields = explode(' ', $data_line); $adr_out = array(); $data_fields_mod = false; foreach ($data_fields as $field_item) { $field_item = trim($field_item); if (!isset($ignore_field[$field_item]) && !empty($store[$field_item]) && $store[$field_item] != '') { $adr_out[] = $store[$field_item]; $data_fields_mod = true; } } if ($data_fields_mod) { $out_datas[] = implode(' ', $adr_out); } } $out = implode('<br />', $out_datas); return $out; }
protected function assignAddressFormat() { $pvppqfqihjwv = "dlv_adr_fields"; ${"GLOBALS"}["ntesagukc"] = "id_country"; ${${"GLOBALS"}["ntesagukc"]} = is_null($this->sellerinfo) ? 0 : (int) $this->sellerinfo->id_country; $kpdwmiqiq = "dlv_adr_fields"; ${$pvppqfqihjwv} = AddressFormat::getOrderedAddressFields(${${"GLOBALS"}["ceizdslnl"]}, true, true); $this->context->smarty->assign("ordered_adr_fields", ${$kpdwmiqiq}); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) { $this->errors[] = Tools::displayError('Order ID required'); } else { $order = new Order($id_order); if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) { $id_order_state = (int) $order->getCurrentState(); $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); $addressInvoice = new Address((int) $order->id_address_invoice); $addressDelivery = new Address((int) $order->id_address_delivery); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) { $this->context->smarty->assign('total_old', (double) $order->total_paid - $order->total_discounts); } $products = $order->getProducts(); /* DEPRECATED: customizedDatas @since 1.5 */ $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); OrderReturn::addReturnedQuantity($products, $order->id); $order_status = new OrderState((int) $id_order_state, (int) $order->id_lang); $customer = new Customer($order->id_customer); //by webkul to show order details properly on order history page if (Module::isInstalled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php'; $obj_cart_bk_data = new HotelCartBookingData(); $obj_htl_bk_dtl = new HotelBookingDetail(); $obj_rm_type = new HotelRoomType(); if (!empty($products)) { foreach ($products as $type_key => $type_value) { $product = new Product($type_value['product_id'], false, $this->context->language->id); $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default'); } else { $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default'); } $unit_price = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1); if (isset($customer->id)) { $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, (new Cart($order->id_cart))->id_guest, $type_value['product_id'], $customer->id); } else { $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, $customer->id_guest, $type_value['product_id']); } $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']); $cart_htl_data[$type_key]['id_product'] = $type_value['product_id']; $cart_htl_data[$type_key]['cover_img'] = $cover_img; $cart_htl_data[$type_key]['name'] = $product->name; $cart_htl_data[$type_key]['unit_price'] = $unit_price; $cart_htl_data[$type_key]['adult'] = $rm_dtl['adult']; $cart_htl_data[$type_key]['children'] = $rm_dtl['children']; foreach ($cart_bk_data as $data_k => $data_v) { $date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']); if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1; $num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days']; $vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days; $amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1); $amount *= $vart_quant; $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount; } else { $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']); $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1; $cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; $cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; $amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1); $amount *= $num_days; $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount; } } } $this->context->smarty->assign('cart_htl_data', $cart_htl_data); } } //end $this->context->smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection()), 'logable' => (bool) $order_status->logable, 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas, 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'))); if ($carrier->url && $order->shipping_number) { $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); } $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order))); Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order)); unset($carrier, $addressInvoice, $addressDelivery); } else { $this->errors[] = Tools::displayError('This order cannot be found.'); } unset($order); } $this->setTemplate(_PS_THEME_DIR_ . 'order-detail.tpl'); }
private 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); self::$smarty->assign('inv_adr_fields', $inv_adr_fields); self::$smarty->assign('dlv_adr_fields', $dlv_adr_fields); }
/** * Assign address var to smarty */ protected function assignAddressFormat() { $addressItems = array(); $addressFormat = AddressFormat::getOrderedAddressFields((int) $this->id_country, false, true); $requireFormFieldsList = AddressFormat::getFieldsRequired(); 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) { $this->context->smarty->assign(array($addressType . '_adr_fields' => $addressFormat, $addressType . '_all_fields' => $addressItems, 'required_fields' => $requireFormFieldsList)); } }
/** * Assign template vars related to address format */ protected function assignAddressFormat() { $id_country = is_null($this->_address) ? 0 : (int) $this->_address->id_country; $dlv_adr_fields = AddressFormat::getOrderedAddressFields($id_country, true, true); $this->context->smarty->assign('ordered_adr_fields', $dlv_adr_fields); }
public static function generateHeaderAddresses(&$pdf, $order, $addressType, $patternRules, $width) { $maxY = 0; $pdf->setY($pdf->GetY() + 5); foreach (array_keys($addressType) as $type) { $currentY = $pdf->GetY(); $attributeName = 'id_address_' . $type; $addressType[$type]['displayed'] = ''; $addressType[$type]['addressObject'] = new Address((int) $order->{$attributeName}); $addressType[$type]['addressFields'] = AddressFormat::getOrderedAddressFields($addressType[$type]['addressObject']->id_country); $addressType[$type]['addressFormatedValues'] = AddressFormat::getFormattedAddressFieldsValues($addressType[$type]['addressObject'], $addressType[$type]['addressFields']); foreach ($addressType[$type]['addressFields'] as $line) { if ($patternsList = explode(' ', $line)) { $tmp = ''; foreach ($patternsList as $pattern) { if (!in_array($pattern, $patternRules['avoid'])) { if ($pattern == 'State:name' && Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')) == 'US') { $state_name =& $addressType[$type]['addressFormatedValues'][$pattern]; $state = new State((int) State::getIdByName($state_name)); if (Validate::isLoadedObject($state)) { $state_name = $state->iso_code; } else { $state_name = strtoupper(substr($state_name, 0, 2)); } } $tmp .= isset($addressType[$type]['addressFormatedValues'][$pattern]) && !empty($addressType[$type]['addressFormatedValues'][$pattern]) ? Tools::iconv('utf-8', self::encoding(), $addressType[$type]['addressFormatedValues'][$pattern]) . ' ' : ''; } } $tmp = trim($tmp); $addressType[$type]['displayed'] .= !empty($tmp) ? $tmp . "\n" : ''; } } $pdf->MultiCell($width, 6.0, $addressType[$type]['displayed'], 0, 'L', 0); if ($pdf->GetY() > $maxY) { $maxY = $pdf->GetY(); } $pdf->SetY($currentY); $pdf->SetX($width + 10); } $pdf->SetY($maxY); if ($maxY) { $pdf->Ln(5); } return $addressType; }
protected function _assignAddress() { //if guest checkout disabled and flag is_guest in cookies is actived if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 && (int) $this->context->customer->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) { $this->context->customer->logout(); Tools::redirect(''); } else { if (!Customer::getAddressesTotalById($this->context->customer->id)) { Tools::redirect('index.php?controller=address&back=' . urlencode('order.php?step=1&multi-shipping=' . (int) Tools::getValue('multi-shipping'))); } } $customer = $this->context->customer; if (Validate::isLoadedObject($customer)) { /* Getting customer addresses */ $customerAddresses = $customer->getAddresses($this->context->language->id); // Getting a list of formated address fields with associated values $formatedAddressFieldsValuesList = array(); foreach ($customerAddresses as $i => $address) { if (!Address::isCountryActiveById((int) $address['id_address'])) { unset($customerAddresses[$i]); } $tmpAddress = new Address($address['id_address']); $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']); $formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmpAddress, $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']); unset($tmpAddress); } if (key($customerAddresses) != 0) { $customerAddresses = array_values($customerAddresses); } if (!count($customerAddresses)) { $bad_delivery = false; if (($bad_delivery = (bool) (!Address::isCountryActiveById((int) $this->context->cart->id_address_delivery))) || !Address::isCountryActiveById((int) $this->context->cart->id_address_invoice)) { $back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int) Tools::getValue('multi-shipping'))); $params = array('multi-shipping' => (int) Tools::getValue('multi-shipping'), 'id_address' => $bad_delivery ? (int) $this->context->cart->id_address_delivery : (int) $this->context->cart->id_address_invoice, 'back' => $back_url); Tools::redirect($this->context->link->getPageLink('address', true, (int) $this->context->language->id, $params)); } } $this->context->smarty->assign(array('addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList)); /* Setting default addresses for cart */ if ((!isset($this->context->cart->id_address_delivery) || empty($this->context->cart->id_address_delivery)) && count($customerAddresses)) { $this->context->cart->id_address_delivery = (int) $customerAddresses[0]['id_address']; $update = 1; } if ((!isset($this->context->cart->id_address_invoice) || empty($this->context->cart->id_address_invoice)) && count($customerAddresses)) { $this->context->cart->id_address_invoice = (int) $customerAddresses[0]['id_address']; $update = 1; } /* Update cart addresses only if needed */ if (isset($update) && $update) { $this->context->cart->update(); // Address has changed, so we check if the cart rules still apply CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); } /* If delivery address is valid in cart, assign it to Smarty */ if (isset($this->context->cart->id_address_delivery)) { $deliveryAddress = new Address((int) $this->context->cart->id_address_delivery); if (Validate::isLoadedObject($deliveryAddress) && $deliveryAddress->id_customer == $customer->id) { $this->context->smarty->assign('delivery', $deliveryAddress); } } /* If invoice address is valid in cart, assign it to Smarty */ if (isset($this->context->cart->id_address_invoice)) { $invoiceAddress = new Address((int) $this->context->cart->id_address_invoice); if (Validate::isLoadedObject($invoiceAddress) && $invoiceAddress->id_customer == $customer->id) { $this->context->smarty->assign('invoice', $invoiceAddress); } } } if ($oldMessage = Message::getMessageByCartId((int) $this->context->cart->id)) { $this->context->smarty->assign('oldMessage', $oldMessage['message']); } }
protected function _processAddressFormat() { $address_delivery = new Address((int) $this->context->cart->id_address_delivery); $address_invoice = new Address((int) $this->context->cart->id_address_invoice); $inv_adr_fields = AddressFormat::getOrderedAddressFields((int) $address_delivery->id_country, false, true); $dlv_adr_fields = AddressFormat::getOrderedAddressFields((int) $address_invoice->id_country, false, true); $requireFormFieldsList = AddressFormat::$requireFormFieldsList; // Add missing require fields for a new user susbscription form foreach ($requireFormFieldsList as $fieldName) { if (!in_array($fieldName, $dlv_adr_fields)) { $dlv_adr_fields[] = trim($fieldName); } } foreach ($requireFormFieldsList as $fieldName) { if (!in_array($fieldName, $inv_adr_fields)) { $inv_adr_fields[] = trim($fieldName); } } $inv_all_fields = array(); $dlv_all_fields = 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); } } ${$adr_type . '_adr_fields'} = array_unique(${$adr_type . '_adr_fields'}); ${$adr_type . '_all_fields'} = array_unique(${$adr_type . '_all_fields'}); $this->context->smarty->assign($adr_type . '_adr_fields', ${$adr_type . '_adr_fields'}); $this->context->smarty->assign($adr_type . '_all_fields', ${$adr_type . '_all_fields'}); } }
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)); } }
public static function getFormattedLayoutData($address) { $layoutData = array(); if ($address && $address instanceof Address) { $layoutData['ordered'] = AddressFormat::getOrderedAddressFields((int) $address->id_country); $layoutData['formated'] = AddressFormat::getFormattedAddressFieldsValues($address, $layoutData['ordered']); $layoutData['object'] = get_object_vars($address); } return $layoutData; }
/** * 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() { $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); $address_delivery = new Address((int) self::$cart->id_address_delivery); $address_invoice = new Address((int) self::$cart->id_address_invoice); $inv_adr_fields = AddressFormat::getOrderedAddressFields((int) $address_delivery->id_country, false, true); $dlv_adr_fields = AddressFormat::getOrderedAddressFields((int) $address_invoice->id_country, false, true); $inv_all_fields = array(); $dlv_all_fields = 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); } } self::$smarty->assign($adr_type . '_adr_fields', ${$adr_type . '_adr_fields'}); self::$smarty->assign($adr_type . '_all_fields', ${$adr_type . '_all_fields'}); } }
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)); }
private function processAddressFormat() { $addressDelivery = new Address((int) self::$cart->id_address_delivery); $addressInvoice = new Address((int) self::$cart->id_address_invoice); $invoiceAddressFields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $deliveryAddressFields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); self::$smarty->assign(array('inv_adr_fields' => $invoiceAddressFields, 'dlv_adr_fields' => $deliveryAddressFields)); }