当前位置: 首页>>代码示例>>PHP>>正文


PHP AddressFormat::getFormattedLayoutData方法代码示例

本文整理汇总了PHP中AddressFormat::getFormattedLayoutData方法的典型用法代码示例。如果您正苦于以下问题:PHP AddressFormat::getFormattedLayoutData方法的具体用法?PHP AddressFormat::getFormattedLayoutData怎么用?PHP AddressFormat::getFormattedLayoutData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AddressFormat的用法示例。


在下文中一共展示了AddressFormat::getFormattedLayoutData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: assignStoresSimplified

    /**
     * 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));
    }
开发者ID:jpodracky,项目名称:dogs,代码行数:28,代码来源:StoresController.php

示例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);
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:29,代码来源:AddressesController.php

示例3: 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');
 }
开发者ID:zangles,项目名称:lennyba,代码行数:28,代码来源:AddressesController.php

示例4: getSummaryDetails

 /**
  * 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));
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:90,代码来源:Cart.php

示例5: getSummaryDetails

 /**
  * Return useful informations for cart
  *
  * @return array Cart details
  */
 function getSummaryDetails()
 {
     global $cookie;
     $delivery = new Address((int) $this->id_address_delivery);
     $invoice = new Address((int) $this->id_address_invoice);
     // New layout system with personalization fields
     $formattedAddresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
     $formattedAddresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
     $total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
     if ($total_tax < 0) {
         $total_tax = 0;
     }
     $total_free_ship = 0;
     if ($free_ship = Tools::convertPrice((double) Configuration::get('PS_SHIPPING_FREE_PRICE'), new Currency((int) $this->id_currency))) {
         $discounts = $this->getDiscounts();
         $total_free_ship = $free_ship - ($this->getOrderTotal(true, Cart::ONLY_PRODUCTS) + $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
         foreach ($discounts as $discount) {
             if ($discount['id_discount_type'] == 3) {
                 $total_free_ship = 0;
                 break;
             }
         }
     }
     return array('delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'formattedAddresses' => $formattedAddresses, 'carrier' => new Carrier((int) $this->id_carrier, $cookie->id_lang), 'products' => $this->getProducts(false), 'discounts' => $this->getDiscounts(false, true), 'is_virtual_cart' => (int) $this->isVirtualCart(), 'total_discounts' => $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS), 'total_discounts_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_DISCOUNTS), 'total_wrapping' => $this->getOrderTotal(true, Cart::ONLY_WRAPPING), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_WRAPPING), 'total_shipping' => $this->getOrderShippingCost(), 'total_shipping_tax_exc' => $this->getOrderShippingCost(NULL, false), 'total_products_wt' => $this->getOrderTotal(true, Cart::ONLY_PRODUCTS), 'total_products' => $this->getOrderTotal(false, Cart::ONLY_PRODUCTS), 'total_price' => $this->getOrderTotal(), 'total_tax' => $total_tax, 'total_price_without_tax' => $this->getOrderTotal(false), 'free_ship' => $total_free_ship);
 }
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:30,代码来源:Cart.php


注:本文中的AddressFormat::getFormattedLayoutData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。