public static function getFormattedLayoutData($address) { $layoutData = array(); if ($address && $address instanceof JeproshopAddressModelAddress) { $layoutData['ordered'] = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields((int) $address->country_id); $layoutData['formatted'] = JeproshopAddressFormatModelAddressFormat::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; }
/** * Generates the full address text * @param is|JeproshopAddressModelAddress $address is an instantiate object of Address class * @param array $patternRules * @param is|string $newLine is a string containing the newLine format * @param is|string $separator is a string containing the separator format * @param array $style * @return string * @internal param is $patternPules a defined rules array to avoid some pattern */ public static function generateAddress(JeproshopAddressModelAddress $address, $patternRules = array(), $newLine = "\r\n", $separator = ' ', $style = array()) { $addressFields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($address->country_id); $addressFormattedValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($address, $addressFields); $addressText = ''; foreach ($addressFields as $line) { if ($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)) { $tmpText = ''; foreach ($patternsList as $pattern) { if (!array_key_exists('avoid', $patternRules) || array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid'])) { $tmpText .= isset($addressFormattedValues[$pattern]) && !empty($addressFormattedValues[$pattern]) ? (isset($style[$pattern]) ? sprintf($style[$pattern], $addressFormattedValues[$pattern]) : $addressFormattedValues[$pattern]) . $separator : ''; } } $tmpText = trim($tmpText); $addressText .= !empty($tmpText) ? $tmpText . $newLine : ''; } } $addressText = preg_replace('/' . preg_quote($newLine, '/') . '$/i', '', $addressText); $addressText = rtrim($addressText, $separator); return $addressText; }
public function initOrderDetails() { $this->context->controller->init(); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); //$this->initContent(); $app = JFactory::getApplication(); $order_id = $app->input->get('order_id'); if (!$order_id || !JeproshopTools::isUnsignedInt($order_id)) { $this->errors[] = Tools::displayError('Order ID required'); } else { $order = new JeproshopOrderModelOrder($order_id); if (JeproshopTools::isLoadedObject($order, 'order_id') && $order->customer_id == $this->context->customer->customer_id) { $order_status_id = (int) $order->getCurrentState(); $carrier = new JeproshopCarrierModelCarrier((int) $order->carrier_id, (int) $order->lang_id); $invoiceAddress = new JeproshopAddressModelAddress((int) $order->address_invoice_id); $deliveryAddress = new JeproshopAddressModelAddress((int) $order->address_delivery_id); $invoice_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($invoiceAddress->country_id); $delivery_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($deliveryAddress->country_id); $invoiceAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($invoiceAddress, $invoice_address_fields); $deliveryAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($deliveryAddress, $delivery_address_fields); if ($order->total_discounts > 0) { $oldTotal = (double) ($order->total_paid - $order->total_discounts); $this->assignRef('old_total', $oldTotal); } $products = $order->getProducts(); /* DEPRECATED: customizedDatas @since 1.5 */ $customizedDatas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $order->cart_id); JeproshopProductModelProduct::addCustomizationPrice($products, $customizedDatas); JeproshopOrderReturnModelOrderReturn::addReturnedQuantity($products, $order->order_id); $customer = new JeproshopCustomerModelCustomer($order->customer_id); $this->assignRef('order', $order); $isReturnable = (int) $order->isReturnable(); $this->assignRef('return_allowed', $isReturnable); $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id)); $order_status_id = (int) $order_status_id; $this->assignRef('order_status_id', $order_status_id); $invoiceAllowed = (int) JeproshopSettingModelSetting::getValue('invoice_allowed'); $this->assignRef('invoice_allowed', $invoiceAllowed); $invoice = JeproshopOrderStatusModelOrderStatus::invoiceAvailable($order_status_id) && count($order->getInvoicesCollection()); $this->assignRef('invoice', $invoice); $this->assignRef('order_history', $order->getHistory($this->context->language->lang_id, false, true)); $this->assignRef('products', $products); $this->assignRef('discounts', $order->getCartRules()); $this->assignRef('carrier', $carrier); $this->assignRef('invoice_address', $invoiceAddress); $this->assignRef('invoice_status', JeproshopTools::isLoadedObject($invoiceAddress, 'address_id') && $invoiceAddress->state_id ? new JeproshopStatusModelStatus($invoiceAddress->state_id) : false); $this->assignRef('delivery_address', $deliveryAddress); $this->assignRef('invoice_address_fields', $invoice_address_fields); $this->assignRef('delivery_address_fields', $delivery_address_fields); $this->assignRef('invoice_address_format_values', $invoiceAddressFormatValues); $this->assignRef('delivery_address_format_values', $deliveryAddressFormatValues); $this->assignRef('delivery_status', JeproshopTools::isLoadedObject($deliveryAddress, 'address_id') && $deliveryAddress->state_id ? new JeproshopStatusModelStatus($deliveryAddress->state_id) : false); $this->assignRef('messages', JeproshopCustomerMessageModelCustomerMessage::getMessagesByOrderId((int) $order->order_id, false)); $files = JeproshopProductModelProduct::CUSTOMIZE_FILE; $this->assignRef('CUSTOMIZE_FILE', $files); $text_fields = JeproshopProductModelProduct::CUSTOMIZE_TEXT_FIELD; $this->assignRef('CUSTOMIZE_TEXT_FIELD', $text_fields); //$this->assignRef('isRecyclable', JeproshopSettingModelSetting::getValue('PS_RECYCLABLE_PACK')); $this->assignRef('use_tax', JeproshopSettingModelSetting::getValue('use_tax')); $group_use_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($customer->default_group_id) == COM_JEPROSHOP_TAX_INCLUDED; $this->assignRef('group_use_tax', $group_use_tax); $this->assignRef('display_price', JeproshopSettingModelSetting::getValue('display_price')); /* DEPRECATED: customizedDatas @since 1.5 */ $this->assignRef('customizedDatas', $customizedDatas); $reordering_allowed = (int) JeproshopSettingModelSetting::getValue('enable_history_reordering'); $this->assignRef('reordering_allowed', $reordering_allowed); /* $this->context->smarty->assign(array( 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->state_id) ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXT_FIELD' => Product::CUSTOMIZE_TEXT_FIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->default_group_id) == PS_TAX_INC), /* DEPRECATED: customizedDatas @since 1.5 * / 'customizedDatas' => $customizedDatas, /* DEPRECATED: customizedDatas @since 1.5 * / )); */ if ($carrier->url && $order->shipping_number) { $this->assignRef('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'); }