/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $country = new Country((int) $invoice_address->id_country); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_INVOICE')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $data = array('order' => $this->order, 'order_details' => $order_details, 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer); if (Tools::getValue('debug')) { die(json_encode($data)); } $this->smarty->assign($data); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); }
/** * Returns the template's HTML content * * @return string HTML content */ public function getContent() { $delivery_address = $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $this->order->total_paid_tax_excl = $this->order->total_paid_tax_incl = $this->order->total_products = $this->order->total_products_wt = 0; if ($this->order_slip->amount > 0) { foreach ($this->order->products as &$product) { $product['total_price_tax_excl'] = $product['unit_price_tax_excl'] * $product['product_quantity']; $product['total_price_tax_incl'] = $product['unit_price_tax_incl'] * $product['product_quantity']; if ($this->order_slip->partial == 1) { $order_slip_detail = Db::getInstance()->getRow(' SELECT * FROM `' . _DB_PREFIX_ . 'order_slip_detail` WHERE `id_order_slip` = ' . (int) $this->order_slip->id . ' AND `id_order_detail` = ' . (int) $product['id_order_detail']); $product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl']; $product['total_price_tax_incl'] = $order_slip_detail['amount_tax_incl']; } $this->order->total_products += $product['total_price_tax_excl']; $this->order->total_products_wt += $product['total_price_tax_incl']; $this->order->total_paid_tax_excl = $this->order->total_products; $this->order->total_paid_tax_incl = $this->order->total_products_wt; } } else { $this->order->products = null; } unset($product); // remove reference if ($this->order_slip->shipping_cost == 0) { $this->order->total_shipping_tax_incl = $this->order->total_shipping_tax_excl = 0; } $tax = new Tax(); $tax->rate = $this->order->carrier_tax_rate; $tax_calculator = new TaxCalculator(array($tax)); $tax_excluded_display = Group::getPriceDisplayMethod((int) $customer->id_default_group); $this->order->total_shipping_tax_incl = $this->order_slip->total_shipping_tax_incl; $this->order->total_shipping_tax_excl = $this->order_slip->total_shipping_tax_excl; $this->order_slip->shipping_cost_amount = $tax_excluded_display ? $this->order_slip->total_shipping_tax_excl : $this->order_slip->total_shipping_tax_incl; $this->order->total_paid_tax_incl += $this->order->total_shipping_tax_incl; $this->order->total_paid_tax_excl += $this->order->total_shipping_tax_excl; $total_cart_rule = 0; if ($this->order_slip->order_slip_type == 1 && is_array($cart_rules = $this->order->getCartRules($this->order_invoice->id))) { foreach ($cart_rules as $cart_rule) { if ($tax_excluded_display) { $total_cart_rule += $cart_rule['value_tax_excl']; } else { $total_cart_rule += $cart_rule['value']; } } } $this->smarty->assign(array('order' => $this->order, 'order_slip' => $this->order_slip, 'order_details' => $this->order->products, 'cart_rules' => $this->order_slip->order_slip_type == 1 ? $this->order->getCartRules($this->order_invoice->id) : false, 'amount_choosen' => $this->order_slip->order_slip_type == 2 ? true : false, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address), 'tax_excluded_display' => $tax_excluded_display, 'total_cart_rule' => $total_cart_rule)); $tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('order-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('order-slip.product-tab')), 'total_tab' => $this->smarty->fetch($this->getTemplate('order-slip.total-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('order-slip.payment-tab')), 'tax_tab' => $this->getTaxTabContent()); $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplate('order-slip')); }
/** * Returns the template's HTML content * * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_DELIVERY')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $path = _PS_PROD_IMG_DIR_ . $order_detail['image']->getExistingImgPath() . '.jpg'; $order_detail['image_tag'] = preg_replace('/\\.*' . preg_quote(__PS_BASE_URI__, '/') . '/', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, ImageManager::thumbnail($path, $name, 45, 'jpg', false), 1); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier, 'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY'))); $tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab'))); $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $order_details = $this->order_invoice->getProducts(); if (Configuration::get('PS_PDF_IMG_DELIVERY')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $order_detail['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } } $this->smarty->assign(array('order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
/** * Returns the shop address * * @return string */ protected function getShopAddress() { $shop_address = ''; $shop_address_obj = $this->shop->getAddress(); if (isset($shop_address_obj) && $shop_address_obj instanceof Address) { $shop_address = AddressFormat::generateAddress($shop_address_obj, array(), ' - ', ' '); } return $shop_address; }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $this->smarty->assign(array('order' => $this->order, 'order_details' => $this->order_invoice->getProducts(), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $this->smarty->assign(array('order_return' => $this->order_return, 'return_nb_days' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'), 'products' => OrderReturn::getOrdersReturnProducts((int) $this->order_return->id, $this->order), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'shop_address' => AddressFormat::generateAddress($this->shop->getAddress(), array(), '<br />', ' '))); return $this->smarty->fetch($this->getTemplate('order-return')); }
/** * Returns the shop address * @return string */ protected function getShopAddress() { $shop_address = ''; if (Validate::isLoadedObject($this->shop)) { Shop::setContext(Shop::CONTEXT_SHOP, $this->shop->id); $shop_address_obj = $this->shop->getAddress(); if (isset($shop_address_obj) && $shop_address_obj instanceof Address) { $shop_address = AddressFormat::generateAddress($shop_address_obj, array(), ' - ', ' '); } return $shop_address; } return $shop_address; }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $country = new Country((int) $this->order->id_address_invoice); $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $this->smarty->assign(array('order' => $this->order, 'order_details' => $this->order_invoice->getProducts(), 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer)); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $carrier = new Carrier($this->order->id_carrier); $carrier->name = $carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name; $this->smarty->assign(array('order' => $this->order, 'order_details' => $this->order_invoice->getProducts(), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier)); return $this->smarty->fetch($this->getTemplate('delivery-slip')); }
public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $carrier = new Carrier((int) $this->order->id_carrier); $data = array('order' => $this->order, 'order_details' => $this->order->getProducts(), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'customer' => $customer, 'carrier' => $carrier); $this->smarty->assign($data); $order_pdf_tpl = _PS_MODULE_DIR_ . '/mobassistantconnector/views/templates/front/order_pdf.tpl'; return $this->smarty->fetch($order_pdf_tpl); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $this->order->total_products = $this->order->total_products_wt = 0; foreach ($this->order->products as &$product) { $product['total_price_tax_excl'] = $product['unit_price_tax_excl'] * $product['product_quantity']; $product['total_price_tax_incl'] = $product['unit_price_tax_incl'] * $product['product_quantity']; if ($this->order_slip->partial == 1) { $order_slip_detail = Db::getInstance()->getRow(' SELECT * FROM `' . _DB_PREFIX_ . 'order_slip_detail` WHERE `id_order_slip` = ' . (int) $this->order_slip->id . ' AND `id_order_detail` = ' . (int) $product['id_order_detail']); $product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl']; $product['total_price_tax_incl'] = $order_slip_detail['amount_tax_incl']; } $this->order->total_products += $product['total_price_tax_excl']; $this->order->total_products_wt += $product['total_price_tax_incl']; $this->order->total_paid_tax_excl = $this->order->total_products; $this->order->total_paid_tax_incl = $this->order->total_products_wt; } unset($product); // remove reference if ($this->order_slip->shipping_cost == 0) { $this->order->total_shipping_tax_incl = $this->order->total_shipping_tax_excl = 0; } if ($this->order_slip->partial == 1 && $this->order_slip->shipping_cost_amount > 0) { $this->order->total_shipping_tax_incl = $this->order_slip->shipping_cost_amount; } $tax = new Tax(); $tax->rate = $this->order->carrier_tax_rate; $tax_calculator = new TaxCalculator(array($tax)); $this->order->total_shipping_tax_excl = Tools::ps_round($tax_calculator->removeTaxes($this->order_slip->shipping_cost_amount), 2); $this->order->total_paid_tax_incl += $this->order->total_shipping_tax_incl; $this->order->total_paid_tax_excl += $this->order->total_shipping_tax_excl; $this->smarty->assign(array('order' => $this->order, 'order_slip' => $this->order_slip, 'order_details' => $this->order->products, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod((int) $customer->id_default_group), 'tax_tab' => $this->getTaxTabContent())); return $this->smarty->fetch($this->getTemplate('order-slip')); }
public function getContent() { if (isset($this->order) and Validate::isLoadedObject($this->order) and Module::isInstalled('agilemultipleseller')) { $carrier = new Carrier($this->order->id_carrier); $this->smarty->assign(array('order_number_text' => sprintf('%06d', $this->order->id), 'carrier_name' => $carrier->name)); } $content = parent::getContent(); if (isset($this->order) and Validate::isLoadedObject($this->order) and Module::isInstalled('agilepickupcenter')) { $country = new Country((int) $this->order->id_address_invoice); $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = $formatted_invoice_address; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } require_once _PS_ROOT_DIR_ . "/modules/agilepickupcenter/agilepickupcenter.php"; $pickupcenter = new AgilePickupCenter(); $delivery_address = $formatted_delivery_address . "<BR>" . $pickupcenter->displayInfoByCart($this->order->id_cart); $this->smarty->assign(array('delivery_address' => $delivery_address)); $content = $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); } return $content; }
public static function generateAddressSmarty($params, &$smarty) { return AddressFormat::generateAddress($params['address'], isset($params['patternRules']) ? $params['patternRules'] : array(), isset($params['newLine']) ? $params['newLine'] : "\r\n", isset($params['separator']) ? $params['separator'] : ' ', isset($params['style']) ? $params['style'] : array()); }
/** * @param Object Address $the_address that needs to be txt formated * @return String the txt formated address block */ protected function _getFormatedAddress(Address $the_address, $line_sep, $fields_style = array()) { return AddressFormat::generateAddress($the_address, array('avoid' => array()), $line_sep, ' ', $fields_style); }
public function getTemplateVarShop() { $address = $this->context->shop->getAddress(); $shop = array('name' => Configuration::get('PS_SHOP_NAME'), 'email' => Configuration::get('PS_SHOP_EMAIL'), 'registration_number' => Configuration::get('PS_SHOP_DETAILS'), 'long' => Configuration::get('PS_STORES_CENTER_LONG'), 'lat' => Configuration::get('PS_STORES_CENTER_LAT'), 'logo' => Configuration::get('PS_LOGO') ? _PS_IMG_ . Configuration::get('PS_LOGO') : '', 'stores_icon' => Configuration::get('PS_STORES_ICON') ? _PS_IMG_ . Configuration::get('PS_STORES_ICON') : '', 'favicon' => Configuration::get('PS_FAVICON') ? _PS_IMG_ . Configuration::get('PS_FAVICON') : '', 'favicon_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'address' => array('formatted' => AddressFormat::generateAddress($address, array(), '<br>'), 'address1' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'state' => (new State($address->id_state))->name[$this->context->language->id], 'country' => (new Country($address->id_country))->name[$this->context->language->id]), 'phone' => Configuration::get('PS_SHOP_PHONE'), 'fax' => Configuration::get('PS_SHOP_FAX')); return $shop; }
public static function getFormatedAddress(Address $address, $line_sep, $fields_style = array()) { return AddressFormat::generateAddress($address, array('avoid' => array()), $line_sep, ' ', $fields_style); }
protected function _getFormatedAddress(Address $the_address, $line_sep, $fields_style = array()) { if (method_exists("AddressFormat", "generateAddress")) { return AddressFormat::generateAddress($the_address, array('avoid' => array()), $line_sep, ' ', $fields_style); } else { return self::generateAddress($the_address, array('avoid' => array()), $line_sep, ' ', $fields_style); } }
public function getTemplateVarStores() { $stores = Store::getStores(); foreach ($stores as &$store) { unset($store['active']); // Prepare $store.address $address = new Address(); $store['address'] = []; $attr = ['address1', 'address2', 'postcode', 'city', 'id_state', 'id_country']; foreach ($attr as $a) { $address->{$a} = $store[$a]; $store['address'][$a] = $store[$a]; unset($store[$a]); } $store['address']['formatted'] = AddressFormat::generateAddress($address, array(), '<br />'); // Prepare $store.business_hours // Required for trad $temp = json_decode($store['hours'], true); unset($store['hours']); $store['business_hours'] = [['day' => $this->trans('Monday', array(), 'Shop.Theme'), 'hours' => $temp[0]], ['day' => $this->trans('Tuesday', array(), 'Shop.Theme'), 'hours' => $temp[1]], ['day' => $this->trans('Wednesday', array(), 'Shop.Theme'), 'hours' => $temp[2]], ['day' => $this->trans('Thursday', array(), 'Shop.Theme'), 'hours' => $temp[3]], ['day' => $this->trans('Friday', array(), 'Shop.Theme'), 'hours' => $temp[4]], ['day' => $this->trans('Saturday', array(), 'Shop.Theme'), 'hours' => $temp[5]], ['day' => $this->trans('Sunday', array(), 'Shop.Theme'), 'hours' => $temp[6]]]; $store['image'] = _THEME_STORE_DIR_ . (int) $store['id_store'] . '-stores_default.jpg'; } return $stores; }
private function _sendEmailToStore($params) { //Getting differents vars $id_lang = $this->context->language->id; $id_shop = $this->context->shop->id; $currency = $params['currency']; $order = $params['order']; $customer = $params['customer']; $configuration = Configuration::getMultiple(array('PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR', 'PS_SHOP_EMAIL'), $id_lang, null, $id_shop); $delivery = new Address((int) $order->id_address_delivery); $invoice = new Address((int) $order->id_address_invoice); $order_date_text = Tools::displayDate($order->date_add, (int) $id_lang); $carrier = new Carrier((int) $order->id_carrier); $message = $order->getFirstMessage(); if (!$message || empty($message)) { $message = $this->l('No message'); } $items_table = ''; $products = $params['order']->getProducts(); $customized_datas = Product::getAllCustomizedDatas((int) $params['cart']->id); Product::addCustomizationPrice($products, $customized_datas); foreach ($products as $key => $product) { $unit_price = $product['product_price_wt']; $customization_text = ''; if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']])) { foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization) { if (isset($customization['datas'][_CUSTOMIZE_TEXTFIELD_])) { foreach ($customization['datas'][_CUSTOMIZE_TEXTFIELD_] as $text) { $customization_text .= $text['name'] . ': ' . $text['value'] . '<br />'; } } if (isset($customization['datas'][_CUSTOMIZE_FILE_])) { $customization_text .= count($customization['datas'][_CUSTOMIZE_FILE_]) . ' image(s)<br />'; } $customization_text .= '---<br />'; } $customization_text = rtrim($customization_text, '---<br />'); } $items_table .= '<tr style="background-color:' . ($key % 2 ? '#DDE2E6' : '#EBECEE') . ';"> <td style="padding:0.6em 0.4em;">' . $product['product_reference'] . '</td> <td style="padding:0.6em 0.4em;"> <strong>' . $product['product_name'] . (isset($product['attributes_small']) ? ' ' . $product['attributes_small'] : '') . (!empty($customization_text) ? '<br />' . $customization_text : '') . '</strong> </td> <td style="padding:0.6em 0.4em; text-align:right;">'; $items_table .= Tools::displayPrice($unit_price, $currency, false); $items_table .= '</td> <td style="padding:0.6em 0.4em; text-align:center;">' . (int) $product['product_quantity'] . '</td> <td style="padding:0.6em 0.4em; text-align:right;">'; $items_table .= Tools::displayPrice($unit_price * $product['product_quantity'], $currency, false); $items_table .= '</td></tr>'; } foreach ($params['order']->getCartRules() as $discount) { $items_table .= '<tr style="background-color:#EBECEE;"> <td colspan="4" style="padding:0.6em 0.4em; text-align:right;">' . $this->l('Voucher code:') . ' ' . $discount['name'] . '</td> <td style="padding:0.6em 0.4em; text-align:right;">-' . Tools::displayPrice($discount['value'], $currency, false) . '</td> </tr>'; } if ($delivery->id_state) { $delivery_state = new State((int) $delivery->id_state); } if ($invoice->id_state) { $invoice_state = new State((int) $invoice->id_state); } // Get Store info $id_store = DB::getInstance()->getValue("SELECT id_store FROM " . _DB_PREFIX_ . "store WHERE address1='" . $delivery->address1 . "' AND city='" . $delivery->city . "' AND postcode='" . $delivery->postcode . "'"); $store = new Store($id_store); //used for store email // Filling-in vars for email $template = 'new_order'; $template_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{delivery_block_txt}' => AddressFormat::generateAddress($delivery, array('avoid' => array()), "\n", ' ', array()), '{invoice_block_txt}' => AddressFormat::generateAddress($invoice, array('avoid' => array()), "\n", ' ', array()), '{delivery_block_html}' => AddressFormat::generateAddress($delivery, array('avoid' => array()), '<br />', ' ', array('firstname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>')), '{invoice_block_html}' => AddressFormat::generateAddress($invoice, array('avoid' => array()), '<br />', ' ', array('firstname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . ' font-weight:bold;">%s</span>', 'lastname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>')), '{delivery_company}' => $delivery->company, '{delivery_firstname}' => $delivery->firstname, '{delivery_lastname}' => $delivery->lastname, '{delivery_address1}' => $delivery->address1, '{delivery_address2}' => $delivery->address2, '{delivery_city}' => $delivery->city, '{delivery_postal_code}' => $delivery->postcode, '{delivery_country}' => $delivery->country, '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', '{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile, '{delivery_other}' => $delivery->other, '{invoice_company}' => $invoice->company, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address2, '{invoice_address1}' => $invoice->address1, '{invoice_city}' => $invoice->city, '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', '{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile, '{invoice_other}' => $invoice->other, '{order_name}' => sprintf('%06d', $order->id), '{shop_name}' => $configuration['PS_SHOP_NAME'], '{date}' => $order_date_text, '{carrier}' => $carrier->name == '0' ? $configuration['PS_SHOP_NAME'] : $carrier->name, '{payment}' => Tools::substr($order->payment, 0, 32), '{items}' => $items_table, '{total_tax_paid}' => Tools::displayPrice($order->total_products_wt - $order->total_products + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $currency, false), '{total_paid}' => Tools::displayPrice($order->total_paid, $currency), '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency), '{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency), '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency), '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency), '{currency}' => $currency->sign, '{message}' => $message); $iso = Language::getIsoById($id_lang); if (file_exists(dirname(__FILE__) . '/mails/' . $iso . '/' . $template . '.txt') && file_exists(dirname(__FILE__) . '/mails/' . $iso . '/' . $template . '.html')) { Mail::Send($id_lang, $template, sprintf(Mail::l('New order - #%06d', $id_lang), $order->id), $template_vars, $store->email, null, Configuration::get('PS_SHOP_EMAIL'), $configuration['PS_SHOP_NAME'], null, null, dirname(__FILE__) . '/mails/', null, $id_shop); } }
public function getWidgetVariables($hookName = null, array $configuration = []) { $address = $this->context->shop->getAddress(); $contact_infos = ['company' => Configuration::get('PS_SHOP_NAME'), 'address' => ['formatted' => AddressFormat::generateAddress($address, array(), '<br />'), 'address1' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'state' => (new State($address->id_state))->name[$this->context->language->id], 'country' => (new Country($address->id_country))->name[$this->context->language->id]], 'phone' => Configuration::get('PS_SHOP_PHONE'), 'fax' => Configuration::get('PS_SHOP_FAX'), 'email' => Configuration::get('PS_SHOP_EMAIL')]; return ['contact_infos' => $contact_infos]; }
public function add($autodate = true, $null_values = false) { $address = new Address(); $address->company = Configuration::get('PS_SHOP_NAME'); $address->address1 = Configuration::get('PS_SHOP_ADDR1'); $address->address2 = Configuration::get('PS_SHOP_ADDR2'); $address->postcode = Configuration::get('PS_SHOP_CODE'); $address->city = Configuration::get('PS_SHOP_CITY'); $address->phone = Configuration::get('PS_SHOP_PHONE'); $address->id_country = Configuration::get('PS_SHOP_COUNTRY_ID'); $this->shop_address = AddressFormat::generateAddress($address, array(), '<br />', ' '); $order = new Order($this->id_order); $invoice_address = new Address((int) $order->id_address_invoice); $invoiceAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); $this->invoice_address = AddressFormat::generateAddress($invoice_address, $invoiceAddressPatternRules, '<br />', ' '); $delivery_address = new Address((int) $order->id_address_delivery); $deliveryAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $this->delivery_address = AddressFormat::generateAddress($delivery_address, $deliveryAddressPatternRules, '<br />', ' '); return parent::add(); }
/** * Returns the template's HTML content * * @return string HTML content */ public function getContent() { $invoiceAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); $deliveryAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $invoice_address = new Address((int) $this->order->id_address_invoice); $country = new Country((int) $invoice_address->id_country); if ($this->order_invoice->invoice_address) { $formatted_invoice_address = $this->order_invoice->invoice_address; } else { $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, $invoiceAddressPatternRules, '<br />', ' '); } $delivery_address = null; $formatted_delivery_address = ''; if (isset($this->order->id_address_delivery) && $this->order->id_address_delivery) { if ($this->order_invoice->delivery_address) { $formatted_delivery_address = $this->order_invoice->delivery_address; } else { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, $deliveryAddressPatternRules, '<br />', ' '); } } $customer = new Customer((int) $this->order->id_customer); $order_details = $this->order_invoice->getProducts(); $has_discount = false; foreach ($order_details as $id => &$order_detail) { // Find out if column 'price before discount' is required if ($order_detail['reduction_amount_tax_excl'] > 0) { $has_discount = true; $order_detail['unit_price_tax_excl_before_specific_price'] = $order_detail['unit_price_tax_excl_including_ecotax'] + $order_detail['reduction_amount_tax_excl']; } elseif ($order_detail['reduction_percent'] > 0) { $has_discount = true; $order_detail['unit_price_tax_excl_before_specific_price'] = 100 * $order_detail['unit_price_tax_excl_including_ecotax'] / (100 - $order_detail['reduction_percent']); } // Set tax_code $taxes = OrderDetail::getTaxListStatic($id); $tax_temp = array(); foreach ($taxes as $tax) { $obj = new Tax($tax['id_tax']); $tax_temp[] = sprintf($this->l('%1$s%2$s%%'), $obj->rate + 0, ' '); } $order_detail['order_detail_tax'] = $taxes; $order_detail['order_detail_tax_label'] = implode(', ', $tax_temp); } unset($tax_temp); unset($order_detail); if (Configuration::get('PS_PDF_IMG_INVOICE')) { foreach ($order_details as &$order_detail) { if ($order_detail['image'] != null) { $name = 'product_mini_' . (int) $order_detail['product_id'] . (isset($order_detail['product_attribute_id']) ? '_' . (int) $order_detail['product_attribute_id'] : '') . '.jpg'; $path = _PS_PROD_IMG_DIR_ . $order_detail['image']->getExistingImgPath() . '.jpg'; $order_detail['image_tag'] = preg_replace('/\\.*' . preg_quote(__PS_BASE_URI__, '/') . '/', _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, ImageManager::thumbnail($path, $name, 45, 'jpg', false), 1); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $order_detail['image_size'] = false; } } } unset($order_detail); // don't overwrite the last order_detail later } $cart_rules = $this->order->getCartRules($this->order_invoice->id); $free_shipping = false; foreach ($cart_rules as $key => $cart_rule) { if ($cart_rule['free_shipping']) { $free_shipping = true; /** * Adjust cart rule value to remove the amount of the shipping. * We're not interested in displaying the shipping discount as it is already shown as "Free Shipping". */ $cart_rules[$key]['value_tax_excl'] -= $this->order_invoice->total_shipping_tax_excl; $cart_rules[$key]['value'] -= $this->order_invoice->total_shipping_tax_incl; /** * Don't display cart rules that are only about free shipping and don't create * a discount on products. */ if ($cart_rules[$key]['value'] == 0) { unset($cart_rules[$key]); } } } $product_taxes = 0; foreach ($this->order_invoice->getProductTaxesBreakdown($this->order) as $details) { $product_taxes += $details['total_amount']; } $product_discounts_tax_excl = $this->order_invoice->total_discount_tax_excl; $product_discounts_tax_incl = $this->order_invoice->total_discount_tax_incl; if ($free_shipping) { $product_discounts_tax_excl -= $this->order_invoice->total_shipping_tax_excl; $product_discounts_tax_incl -= $this->order_invoice->total_shipping_tax_incl; } $products_after_discounts_tax_excl = $this->order_invoice->total_products - $product_discounts_tax_excl; $products_after_discounts_tax_incl = $this->order_invoice->total_products_wt - $product_discounts_tax_incl; $shipping_tax_excl = $free_shipping ? 0 : $this->order_invoice->total_shipping_tax_excl; $shipping_tax_incl = $free_shipping ? 0 : $this->order_invoice->total_shipping_tax_incl; $shipping_taxes = $shipping_tax_incl - $shipping_tax_excl; $wrapping_taxes = $this->order_invoice->total_wrapping_tax_incl - $this->order_invoice->total_wrapping_tax_excl; $total_taxes = $this->order_invoice->total_paid_tax_incl - $this->order_invoice->total_paid_tax_excl; $footer = array('products_before_discounts_tax_excl' => $this->order_invoice->total_products, 'product_discounts_tax_excl' => $product_discounts_tax_excl, 'products_after_discounts_tax_excl' => $products_after_discounts_tax_excl, 'products_before_discounts_tax_incl' => $this->order_invoice->total_products_wt, 'product_discounts_tax_incl' => $product_discounts_tax_incl, 'products_after_discounts_tax_incl' => $products_after_discounts_tax_incl, 'product_taxes' => $product_taxes, 'shipping_tax_excl' => $shipping_tax_excl, 'shipping_taxes' => $shipping_taxes, 'shipping_tax_incl' => $shipping_tax_incl, 'wrapping_tax_excl' => $this->order_invoice->total_wrapping_tax_excl, 'wrapping_taxes' => $wrapping_taxes, 'wrapping_tax_incl' => $this->order_invoice->total_wrapping_tax_incl, 'ecotax_taxes' => $total_taxes - $product_taxes - $wrapping_taxes - $shipping_taxes, 'total_taxes' => $total_taxes, 'total_paid_tax_excl' => $this->order_invoice->total_paid_tax_excl, 'total_paid_tax_incl' => $this->order_invoice->total_paid_tax_incl); foreach ($footer as $key => $value) { $footer[$key] = Tools::ps_round($value, _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode); } /** * Need the $round_mode for the tests. */ $round_type = null; switch ($this->order->round_type) { case Order::ROUND_TOTAL: $round_type = 'total'; break; case Order::ROUND_LINE: $round_type = 'line'; break; case Order::ROUND_ITEM: $round_type = 'item'; break; default: $round_type = 'line'; break; } $display_product_images = Configuration::get('PS_PDF_IMG_INVOICE'); $tax_excluded_display = Group::getPriceDisplayMethod($customer->id_default_group); $layout = $this->computeLayout(array('has_discount' => $has_discount)); $legal_free_text = Hook::exec('displayInvoiceLegalFreeText', array('order' => $this->order)); if (!$legal_free_text) { $legal_free_text = Configuration::get('PS_INVOICE_LEGAL_FREE_TEXT', (int) Context::getContext()->language->id, null, (int) $this->order->id_shop); } $data = array('order' => $this->order, 'order_invoice' => $this->order_invoice, 'order_details' => $order_details, 'cart_rules' => $cart_rules, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address), 'tax_excluded_display' => $tax_excluded_display, 'display_product_images' => $display_product_images, 'layout' => $layout, 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer, 'footer' => $footer, 'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_, 'round_type' => $round_type, 'legal_free_text' => $legal_free_text, 'inphone' => $invoice_address->phone, 'inphone_mobile' => $invoice_address->phone_mobile); if (Tools::getValue('debug')) { die(json_encode($data)); } $this->smarty->assign($data); $tpls = array('style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('invoice.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('invoice.product-tab')), 'tax_tab' => $this->getTaxTabContent(), 'payment_tab' => $this->smarty->fetch($this->getTemplate('invoice.payment-tab')), 'total_tab' => $this->smarty->fetch($this->getTemplate('invoice.total-tab'))); $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); }
public function ajaxReturnVars() { $id_cart = (int) $this->context->cart->id; $message_content = ''; if ($message = Message::getMessageByCartId((int) $this->context->cart->id)) { $message_content = $message['message']; } $cart_rules = $this->context->cart->getCartRules(CartRule::FILTER_ACTION_SHIPPING); $free_shipping = false; if (count($cart_rules)) { foreach ($cart_rules as $cart_rule) { if ($cart_rule['id_cart_rule'] == CartRule::getIdByCode(CartRule::BO_ORDER_CODE_PREFIX . (int) $this->context->cart->id)) { $free_shipping = true; break; } } } $addresses = $this->context->customer->getAddresses((int) $this->context->cart->id_lang); foreach ($addresses as &$data) { $address = new Address((int) $data['id_address']); $data['formated_address'] = AddressFormat::generateAddress($address, array(), "<br />"); } return array('summary' => $this->getCartSummary(), 'delivery_option_list' => $this->getDeliveryOptionList(), 'cart' => $this->context->cart, 'currency' => new Currency($this->context->cart->id_currency), 'addresses' => $addresses, 'id_cart' => $id_cart, 'order_message' => $message_content, 'link_order' => $this->context->link->getPageLink('order', false, (int) $this->context->cart->id_lang, 'step=3&recover_cart=' . $id_cart . '&token_cart=' . md5(_COOKIE_KEY_ . 'recover_cart_' . $id_cart)), 'free_shipping' => (int) $free_shipping); }
public function displayAddressDetail($addressDelivery) { return AddressFormat::generateAddress($addressDelivery, array('avoid' => array()), '<br />'); }
public static function getCurrentFormattedShopAddress($id_shop = null) { $address = new Address(); $address->company = Configuration::get('PS_SHOP_NAME', null, null, $id_shop); $address->address1 = Configuration::get('PS_SHOP_ADDR1', null, null, $id_shop); $address->address2 = Configuration::get('PS_SHOP_ADDR2', null, null, $id_shop); $address->postcode = Configuration::get('PS_SHOP_CODE', null, null, $id_shop); $address->city = Configuration::get('PS_SHOP_CITY', null, null, $id_shop); $address->phone = Configuration::get('PS_SHOP_PHONE', null, null, $id_shop); $address->id_country = Configuration::get('PS_SHOP_COUNTRY_ID', null, null, $id_shop); return AddressFormat::generateAddress($address, array(), '<br />', ' '); }
public function displayAddressDetail($addressDelivery) { // Allow to add specific rules $patternRules = array('avoid' => array()); return AddressFormat::generateAddress($addressDelivery, $patternRules, '<br />'); }