本文整理汇总了PHP中AddressFormat::getOrderedAddressFields方法的典型用法代码示例。如果您正苦于以下问题:PHP AddressFormat::getOrderedAddressFields方法的具体用法?PHP AddressFormat::getOrderedAddressFields怎么用?PHP AddressFormat::getOrderedAddressFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AddressFormat
的用法示例。
在下文中一共展示了AddressFormat::getOrderedAddressFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processStoreAddress
/**
* 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;
}
示例2: process
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);
}
示例3: getFormat
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));
}
示例4: process
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);
}
示例5: initContent
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');
}
}
示例6: _buildOrderedFieldsShop
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];
}
}
}
示例7: initContent
/**
* 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');
}
示例8: preProcess
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);
}
}
示例9: _processStoreAddress
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;
}
示例10: initContent
/**
* 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');
}
示例11: processAddressFormat
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);
}
示例12: _getTxtFormatedAddress
/**
* @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;
}
示例13: getFormattedLayoutData
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;
}
示例14: assignAddressFormat
/**
* 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));
}
示例15: process
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);
}
}