本文整理汇总了PHP中Customer::getAddresses方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::getAddresses方法的具体用法?PHP Customer::getAddresses怎么用?PHP Customer::getAddresses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::getAddresses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initObjects
/**
* Init objects necessary for orders
*/
private function initObjects()
{
$invoice_address = false;
$this->customer = $this->getCustomerByEmail($this->datas->customer->emailAddress, true, $this->datas->customer->lastName, $this->datas->customer->firstName, $this->datas->customer->emailAddress);
$addresses = $this->customer->getAddresses((int) $this->context->language->id);
$find = false;
if (!isset($this->datas->customer->shippingAddress->friendlyName)) {
$friendlyName = $this->module->l('My address');
} else {
$friendlyName = $this->datas->customer->shippingAddress->friendlyName;
}
foreach ($addresses as $addr) {
if ($addr['alias'] == $friendlyName) {
$find = true;
$address = new Address((int) $addr['id_address']);
break;
}
}
if (!$find) {
$address = $this->createAddress($this->datas->customer->shippingAddress);
} else {
$address = $this->createAddress($this->datas->customer->shippingAddress, $address);
}
if (isset($this->datas->customer->billingAddress)) {
$invoice_address = $this->createAddress($this->datas->customer->billingAddress);
}
if (Validate::isLoadedObject($address)) {
$this->address = $address;
$this->invoice_address = $address;
} else {
$this->address = false;
return false;
}
if (Validate::isLoadedObject($invoice_address)) {
$this->invoice_address = $invoice_address;
}
}
示例2: getCustomer
public function getCustomer($user, $pass)
{
$id_customer = (int) Db::getInstance()->getValue('
SELECT `id_customer`
FROM `' . _DB_PREFIX_ . 'customer`
WHERE
`active` AND
`email` = \'' . pSQL($user) . '\' AND
`passwd` = \'' . Tools::encrypt($pass) . '\' AND
`deleted` = 0
' . (version_compare(_PS_VERSION_, '1.4.1.0', '>=') ? ' AND `is_guest` = 0' : ''));
if (!$id_customer) {
throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_WRONG_USERNAME_OR_PASSWORD, 'Username or password is incorrect');
}
$customer = new Customer($id_customer);
$gender = array(1 => 'm', 2 => 'f', 9 => null);
$shopgateCustomer = new ShopgateCustomer();
$shopgateCustomer->setCustomerId($customer->id);
$shopgateCustomer->setCustomerNumber($customer->id);
$shopgateCustomer->setCustomerGroup(Db::getInstance()->getValue('SELECT `name` FROM `' . _DB_PREFIX_ . 'group_lang` WHERE `id_group`=\'' . $customer->id_default_group . '\' AND `id_lang`=' . $this->id_lang));
$shopgateCustomer->setCustomerGroupId($customer->id_default_group);
$shopgateCustomer->setFirstName($customer->firstname);
$shopgateCustomer->setLastName($customer->lastname);
$shopgateCustomer->setGender(isset($gender[$customer->id_gender]) ? $gender[$customer->id_gender] : null);
$shopgateCustomer->setBirthday($customer->birthday);
$shopgateCustomer->setMail($customer->email);
$shopgateCustomer->setNewsletterSubscription($customer->newsletter);
$addresses = array();
foreach ($customer->getAddresses($this->id_lang) as $a) {
$address = new ShopgateAddress();
$address->setId($a['id_address']);
$address->setFirstName($a['firstname']);
$address->setLastName($a['lastname']);
$address->setCompany($a['company']);
$address->setStreet1($a['address1']);
$address->setStreet2($a['address2']);
$address->setCity($a['city']);
$address->setZipcode($a['postcode']);
$address->setCountry($a['country']);
$address->setState($a['state']);
$address->setPhone($a['phone']);
$address->setMobile($a['phone_mobile']);
array_push($addresses, $address);
}
$shopgateCustomer->setAddresses($addresses);
return $shopgateCustomer;
}
示例3: customerImport
public function customerImport()
{
$customer_exist = false;
$this->receiveTab();
$handle = $this->openCsvFile();
$default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
$id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
if (!Validate::isUnsignedId($id_lang)) {
$id_lang = $default_language_id;
}
AdminImportController::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
if (Tools::getValue('convert')) {
$line = $this->utf8EncodeArray($line);
}
$info = AdminImportController::getMaskedRow($line);
AdminImportController::setDefaultValues($info);
if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) {
$customer = new Customer((int) $info['id']);
} else {
if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
$customer = new Customer((int) $info['id']);
} else {
$customer = new Customer();
}
}
if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
$current_id_customer = $customer->id;
$current_id_shop = $customer->id_shop;
$current_id_shop_group = $customer->id_shop_group;
$customer_exist = true;
$customer_groups = $customer->getGroups();
$addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
}
// Group Importation
if (isset($info['group']) && !empty($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
$group = trim($group);
if (empty($group)) {
continue;
}
$id_group = false;
if (is_numeric($group) && $group) {
$my_group = new Group((int) $group);
if (Validate::isLoadedObject($my_group)) {
$customer_groups[] = (int) $group;
}
continue;
}
$my_group = Group::searchByName($group);
if (isset($my_group['id_group']) && $my_group['id_group']) {
$id_group = (int) $my_group['id_group'];
}
if (!$id_group) {
$my_group = new Group();
$my_group->name = array($id_lang => $group);
if ($id_lang != $default_language_id) {
$my_group->name = $my_group->name + array($default_language_id => $group);
}
$my_group->price_display_method = 1;
$my_group->add();
if (Validate::isLoadedObject($my_group)) {
$id_group = (int) $my_group->id;
}
}
if ($id_group) {
$customer_groups[] = (int) $id_group;
}
}
} elseif (empty($info['group']) && isset($customer->id) && $customer->id) {
$customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
if ($customer->passwd) {
$customer->passwd = Tools::encrypt($customer->passwd);
}
$id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
$customers_shop = array();
$customers_shop['shared'] = array();
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
if (Shop::isFeatureActive() && $id_shop_list) {
foreach ($id_shop_list as $id_shop) {
if (empty($id_shop)) {
continue;
}
$shop = new Shop((int) $id_shop);
$group_shop = $shop->getGroup();
if ($group_shop->share_customer) {
if (!in_array($group_shop->id, $customers_shop['shared'])) {
$customers_shop['shared'][(int) $id_shop] = $group_shop->id;
}
} else {
$customers_shop[(int) $id_shop] = $group_shop->id;
}
}
} else {
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
$default_shop->getGroup();
$customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
}
//.........这里部分代码省略.........
示例4: customerImport
public function customerImport()
{
$customer_exist = false;
$this->receiveTab();
$handle = $this->openCsvFile();
AdminImportController::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
if (Tools::getValue('convert')) {
$line = $this->utf8EncodeArray($line);
}
$info = AdminImportController::getMaskedRow($line);
AdminImportController::setDefaultValues($info);
if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
$customer = new Customer((int) $info['id']);
$current_id_customer = $customer->id;
$current_id_shop = $customer->id_shop;
$current_id_shop_group = $customer->id_shop_group;
$customer_exist = true;
$customer_groups = $customer->getGroups();
$addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
foreach ($customer_groups as $key => $group) {
if ($group == $customer->id_default_group) {
unset($customer_groups[$key]);
}
}
} else {
$customer = new Customer();
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
if ($customer->passwd) {
$customer->passwd = Tools::encrypt($customer->passwd);
}
$id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
$customers_shop = array();
$customers_shop['shared'] = array();
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
if (Shop::isFeatureActive() && $id_shop_list) {
foreach ($id_shop_list as $id_shop) {
$shop = new Shop((int) $id_shop);
$group_shop = $shop->getGroup();
if ($group_shop->share_customer) {
if (!in_array($group_shop->id, $customers_shop['shared'])) {
$customers_shop['shared'][(int) $id_shop] = $group_shop->id;
}
} else {
$customers_shop[(int) $id_shop] = $group_shop->id;
}
}
} else {
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
$default_shop->getGroup();
$customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
}
//set temporally for validate field
$customer->id_shop = $default_shop->id;
$customer->id_shop_group = $default_shop->getGroup()->id;
$res = true;
if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
foreach ($customers_shop as $id_shop => $id_group) {
if ($id_shop == 'shared') {
foreach ($id_group as $key => $id) {
$customer->id_shop = (int) $key;
$customer->id_shop_group = (int) $id;
if ($customer_exist && ($current_id_shop_group == $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) {
$customer->id = $current_id_customer;
$res &= $customer->update();
} else {
unset($customer->id);
$res &= $customer->add();
if (isset($customer_groups)) {
$customer->addGroups($customer_groups);
}
if (isset($addresses)) {
foreach ($addresses as $address) {
$address['id_customer'] = $customer->id;
unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']);
Db::getInstance()->insert('address', $address);
}
}
}
}
} else {
$customer->id_shop = $id_shop;
$customer->id_shop_group = $id_group;
if ($customer_exist && $id_shop == $current_id_shop) {
$customer->id = $current_id_customer;
$res &= $customer->update();
} else {
unset($customer->id);
$res &= $customer->add();
if (isset($customer_groups)) {
$customer->addGroups($customer_groups);
}
if (isset($addresses)) {
foreach ($addresses as $address) {
$address['id_customer'] = $customer->id;
unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']);
Db::getInstance()->insert('address', $address);
}
}
//.........这里部分代码省略.........
示例5: afterDelete
protected function afterDelete($object, $old_id)
{
$customer = new Customer($old_id);
$addresses = $customer->getAddresses($this->default_form_language);
foreach ($addresses as $k => $v) {
$address = new Address($v['id_address']);
$address->id_customer = $object->id;
$address->save();
}
return true;
}
示例6: sendSMStoClient
public function sendSMStoClient($id_customer, $id_order, $msg)
{
$mobile = '';
$error = $this->l('Error : SMS not send!');
$status = "erro";
$customer = new Customer($id_customer);
$address = $customer->getAddresses($customer->id_lang);
foreach ($address as $key => $addr) {
if (!empty($addr['phone_mobile'])) {
$mobile = $this->mobileProcess($addr['phone_mobile'], $addr['id_country']);
break;
}
}
if (!empty($mobile)) {
if ($this->sendSMS($mobile, $msg)) {
$status = "ok";
$error = "";
$this->updatemanualmsg($id_customer, $id_order, $msg);
}
}
return Tools::jsonEncode(array('status' => $status, 'error' => $error));
}
示例7: doHook
/**
* Function DO HOOK
*/
public function doHook($params)
{
if ($this->_allowToWork == false) {
return;
}
$customer = new Customer($params['cart']->id_customer);
$currency = new Currency($params['cart']->id_currency);
$address = $customer->getAddresses($params['cart']->id_lang);
$address = $address[0];
// for 1.3 compatibility
$type_both = 3;
$type_only_shipping = 5;
$tva = $params['cart']->getOrderTotal(true, $type_both) - $params['cart']->getOrderTotal(false, $type_both);
$tax = $tva * 100 / $params['cart']->getOrderTotal(true, $type_both);
$params_to_twenga = array();
$params_to_twenga['total_ht'] = $params['cart']->getOrderTotal(false, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING);
$params_to_twenga['basket_id'] = $params['cart']->id;
$params_to_twenga['currency'] = $currency->iso_code;
$params_to_twenga['total_ttc'] = $params['cart']->getOrderTotal(true, Twenga::BOTH);
$params_to_twenga['shipping'] = $params['cart']->getOrderTotal(true, Twenga::ONLY_SHIPPING);
$params_to_twenga['tax'] = Tools::ps_round($tax, 2);
$params_to_twenga['tva'] = $tva;
$params_to_twenga['cli_firstname'] = $customer->firstname;
$params_to_twenga['cli_lastname'] = $customer->lastname;
$params_to_twenga['cli_city'] = $address['city'];
$params_to_twenga['cli_state'] = $address['state'];
$params_to_twenga['cli_country'] = $address['country'];
$params_to_twenga['items'] = array();
foreach ($params['cart']->getProducts() as $product) {
$arr_item = array();
if ($product['total'] != '') {
$arr_item['total_ht'] = (double) $product['total'];
}
if ($product['cart_quantity'] != '') {
$arr_item['quantity'] = (int) $product['cart_quantity'];
}
if ($product['reference'] != '') {
$arr_item['sku'] = (string) $product['reference'];
}
if ($product['name'] != '') {
$arr_item['name'] = (string) $product['name'];
}
if ($product['category']) {
$arr_item['category_name'] = (string) $product['category'];
}
$params_to_twenga['items'][] = $arr_item;
}
$params_to_twenga = array_filter($params_to_twenga);
try {
// twenga don't saved double orders with the same id,
// so don't need to use TwengaObj::orderExist() method.
$tracking_code = self::$obj_twenga->getTrackingScript($params_to_twenga);
return $tracking_code;
} catch (TwengaFieldsException $e) {
return $this->l('Error occurred when params passed in Twenga API') . ' : <br />' . $e->getMessage();
} catch (Exception $e) {
return $e->getMessage();
}
}
示例8: hookPayment
public function hookPayment($params)
{
if (!$this->active) {
return;
}
// Verify if customer has memorized tokens
$cart = $this->context->cart;
$tokens = HipayToken::getTokens($cart->id_customer);
// Retrieve list of tokens
if (isset($tokens['0'])) {
$token_display = 'true';
} else {
$token_display = 'false';
}
if (_PS_VERSION_ >= '1.5') {
// Get invoice Country
$customer = new Customer((int) $cart->id_customer);
$customerInfo = $customer->getAddresses((int) $cart->id_lang);
foreach ($customerInfo as $key => $value) {
if ($value['id_address'] == $cart->id_address_invoice) {
$invoice_country = HipayClass::getCountryCode($value['country']);
}
}
}
// End Get invoice country
// Verify if systems should display memorized tokens
$allow_memorize = HipayClass::getShowMemorization();
// If both are true, activate additional info to allow payment via existing token
if ($allow_memorize == 'true') {
$currency_array = $this->getCurrency((int) $cart->id_currency);
$currency = $currency_array[0]['iso_code'];
foreach ($currency_array as $value) {
if ($value['id_currency'] == $cart->id_currency) {
$actual_currency = $value['iso_code'];
}
}
if ($currency != $actual_currency) {
$currency = $actual_currency;
}
$this->context->smarty->assign(array('cart_id' => $cart->id, 'currency' => $currency, 'amount' => $cart->getOrderTotal(true, Cart::BOTH)));
}
// Create dynamic payment button
$card_str = Configuration::get('HIPAY_ALLOWED_CARDS');
// Cards filter by country
if ($invoice_country != 'FR') {
$card_str = str_replace('cb', '', $card_str);
}
if ($invoice_country != 'BE') {
$card_str = str_replace('bcmc', '', $card_str);
}
$cart_arr = explode(',', $card_str);
$card_currency = Configuration::get('HIPAY_CURRENCY_CARDS');
$card_curr_val = array();
if (Tools::strlen($card_currency) > 3) {
$currency_array = $this->getCurrency((int) $cart->id_currency);
$currency = $currency_array[0]['iso_code'];
foreach ($currency_array as $value) {
if ($value['id_currency'] == $cart->id_currency) {
$actual_currency = $value['iso_code'];
}
}
$card_currency_arr = explode(',', Tools::substr($card_currency, 1, -1));
foreach ($card_currency_arr as $value) {
foreach ($cart_arr as $cardvalue) {
if ($value == '"' . $actual_currency . '-' . $cardvalue . '"') {
$card_curr_val[$cardvalue] = true;
}
}
}
} else {
foreach ($cart_arr as $cardvalue) {
$card_curr_val[$cardvalue] = true;
}
}
$btn_image = '';
$card_currency_ok = '0';
$payment_product_list_upd = '';
$count_ccards = 0;
foreach ($cart_arr as $value) {
if ($value == 'visa' && $card_curr_val['visa']) {
$btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/visa_small.png" alt="Visa" />';
$card_currency_ok = '1';
$payment_product_list_upd .= 'visa,';
$count_ccards++;
}
if ($value == 'mastercard' && $card_curr_val['mastercard']) {
$btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/mc_small.png" alt="MasterCard" />';
$card_currency_ok = '1';
$payment_product_list_upd .= 'mastercard,';
$count_ccards++;
}
if ($value == 'american-express' && $card_curr_val['american-express']) {
$btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/amex_small.png" alt="American Express" />';
$card_currency_ok = '1';
$payment_product_list_upd .= 'american-express,';
$count_ccards++;
}
if ($value == 'bcmc' && $card_curr_val['bcmc']) {
$btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/bcmc_small.png" alt="Bancontact / Mister Cash" />';
$card_currency_ok = '1';
//.........这里部分代码省略.........
示例9: ajaxProcessSearchCustomers
public function ajaxProcessSearchCustomers()
{
$searches = explode(' ', Tools::getValue('customer_search'));
$customers = array();
$searches = array_unique($searches);
foreach ($searches as $search) {
$sql_base = 'SELECT *
FROM `' . _DB_PREFIX_ . 'customer`';
$sql = '(' . $sql_base . ' WHERE `email` LIKE \'%' . pSQL($search) . '%\')';
$sql .= ' UNION (' . $sql_base . ' WHERE `id_customer` = ' . (int) $search . ')';
$sql .= ' UNION (' . $sql_base . ' WHERE `lastname` LIKE \'%' . pSQL($search) . '%\')';
$sql .= ' UNION (' . $sql_base . ' WHERE `firstname` LIKE \'%' . pSQL($search) . '%\')';
$sql .= ' LIMIT 0, 50';
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!empty($search) && $results) {
foreach ($results as $result) {
if ($result['active']) {
$customer = new Customer($result['id_customer']);
$addresses = $customer->getAddresses((int) Context::getContext()->language->id);
$result['address'] = $addresses[0];
$customers[$result['id_customer']] = $result;
}
}
}
}
if (count($customers)) {
$to_return = array('customers' => $customers, 'found' => true);
} else {
$to_return = array('found' => false);
}
$this->content = Tools::jsonEncode($to_return);
}
示例10: doHook
/**
* Function DO HOOK
*/
public function doHook($aParams, $sEvent = '')
{
if ($this->_allowToWork == false) {
return;
}
$oCustomer = new Customer($aParams['cart']->id_customer);
$oCurrency = new Currency($aParams['cart']->id_currency);
$aAddress = $oCustomer->getAddresses($aParams['cart']->id_lang);
$aAddress = $aAddress[0];
$sUserCountry = '';
if (isset($aAddress['id_country']) && !empty($aAddress['id_country'])) {
$sUserCountry = Country::getIsoById($aAddress['id_country']);
}
// for 1.3 compatibility
$tva = false;
if (isset($aParams['objOrder']) && !empty($aParams['objOrder'])) {
$tax = $aParams['objOrder']->total_paid_tax_incl - $aParams['objOrder']->total_shipping_tax_incl - ($aParams['objOrder']->total_paid_tax_excl - $aParams['objOrder']->total_shipping_tax_excl);
$tva = $aParams['objOrder']->carrier_tax_rate;
} else {
$tax = $aParams['cart']->getOrderTotal(true, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING) - $aParams['cart']->getOrderTotal(false, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING);
if ($aParams['cart']->getOrderTotal(false, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING) > 0) {
$tva = $tax * 100 / $aParams['cart']->getOrderTotal(false, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING);
}
}
$aParamsToTwenga = array();
$aParamsToTwenga['event'] = $sEvent;
$aParamsToTwenga['user_id'] = $aParams['cart']->id_customer;
$aParamsToTwenga['user_global_id'] = md5($oCustomer->email);
$aParamsToTwenga['user_email'] = $oCustomer->email;
$aParamsToTwenga['user_firstname'] = $oCustomer->firstname;
$aParamsToTwenga['user_city'] = $aParams['cart']->id_customer ? $aAddress['city'] : '';
$aParamsToTwenga['user_state'] = $aParams['cart']->id_customer ? $aAddress['state'] : '';
$aParamsToTwenga['user_country'] = $aParams['cart']->id_customer ? $sUserCountry : '';
$aParamsToTwenga['user_segment'] = '';
$aParamsToTwenga['user_is_customer'] = 1;
$aParamsToTwenga['ecommerce_platform'] = 'Prestashop';
$aParamsToTwenga['tag_platform'] = '';
$aParamsToTwenga['basket_id'] = $aParams['cart']->id;
$aParamsToTwenga['currency'] = $oCurrency->iso_code;
$aParamsToTwenga['total_ht'] = isset($aParams['objOrder']) ? $aParams['objOrder']->total_paid_tax_excl - $aParams['objOrder']->total_shipping_tax_excl : $aParams['cart']->getOrderTotal(false, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING);
$aParamsToTwenga['tva'] = $tva !== false ? Tools::ps_round($tva, 2) : '';
$aParamsToTwenga['total_ttc'] = isset($aParams['objOrder']) ? $aParams['objOrder']->total_paid_tax_incl - $aParams['objOrder']->total_shipping_tax_incl : $aParams['cart']->getOrderTotal(true, Twenga::ONLY_PRODUCTS_WITHOUT_SHIPPING);
$aParamsToTwenga['shipping'] = isset($aParams['objOrder']) ? $aParams['objOrder']->total_shipping_tax_incl : $aParams['cart']->getOrderTotal(true, Twenga::ONLY_SHIPPING);
$aParamsToTwenga['tax'] = $tax;
if (isset($aParams['objOrder']) && !empty($aParams['objOrder'])) {
$aParamsToTwenga['order_id'] = $aParams['objOrder']->id;
}
$aParamsToTwenga['items'] = array();
if ($sEvent == 'product' && isset($_POST['id_product']) || isset($_GET['id_product'])) {
$iIdProduct = isset($_POST['id_product']) ? $_POST['id_product'] : $_GET['id_product'];
$oProduct = new Product($iIdProduct);
if ($oProduct) {
$oCategory = new Category($oProduct->id_category_default);
if ($oCategory) {
$arr_item = array();
$arr_item['price'] = $oProduct->price;
$arr_item['quantity'] = '';
$arr_item['ref_id'] = $oProduct->reference;
$arr_item['item_id'] = $iIdProduct;
$arr_item['name'] = $oProduct->name[1];
$arr_item['category_name'] = $oCategory->name;
$aParamsToTwenga['items'][] = $arr_item;
}
}
} elseif (isset($aParams['objOrder']) && !empty($aParams['objOrder'])) {
foreach ($aParams['objOrder']->getProducts() as $product) {
$oCategory = new Category($product['id_category_default']);
$arr_item = array();
if ($product['unit_price_tax_excl'] != '') {
$arr_item['price'] = (double) $product['unit_price_tax_excl'];
}
if ($product['product_quantity'] != '') {
$arr_item['quantity'] = (int) $product['product_quantity'];
}
if ($product['reference'] != '') {
$arr_item['ref_id'] = (string) $product['reference'];
}
if ($product['id_product'] != '') {
$arr_item['item_id'] = (string) $product['id_product'];
}
if ($product['product_name'] != '') {
$arr_item['name'] = (string) $product['product_name'];
}
if (isset($oCategory) && !empty($oCategory)) {
$arr_item['category_name'] = $oCategory->name;
}
$aParamsToTwenga['items'][] = $arr_item;
}
} else {
foreach ($aParams['cart']->getProducts() as $product) {
$arr_item = array();
if ($product['price'] != '') {
$arr_item['price'] = (double) $product['price'];
}
if ($product['cart_quantity'] != '') {
$arr_item['quantity'] = (int) $product['cart_quantity'];
}
//.........这里部分代码省略.........
示例11: renderView
public function renderView()
{
$neoExchange = new NeoExchanges(Tools::getValue('id_neo_exchange'));
$order = new Order(Tools::getValue('id_neo_exchange'));
if (!Validate::isLoadedObject($neoExchange)) {
$this->errors[] = Tools::displayError('The order cannot be found within your database.');
}
$customer = new Customer($neoExchange->id_customer);
//$carrier = new Carrier($neoExchange->id_carrier);
$currency = new Currency((int) $neoExchange->id_currency);
$buys = new NeoItemsBuyCore(Tools::getValue('id_neo_exchange'));
$sales = new NeoItemsSalesCore(Tools::getValue('id_neo_exchange'));
$products = $this->getProducts($buys);
$products2 = $this->getProducts($sales);
//$products = $this->getProducts($neoExchange);
// Carrier module call
/*$carrier_module_call = null;
if ($carrier->is_module)
{
$module = Module::getInstanceByName($carrier->external_module_name);
if (method_exists($module, 'displayInfoByCart'))
$carrier_module_call = call_user_func(array($module, 'displayInfoByCart'), $neoExchange->id_cart);
}
// Retrieve addresses information
$addressInvoice = new Address($neoExchange->id_address_invoice, $this->context->language->id);
if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state)
$invoiceState = new State((int)$addressInvoice->id_state);
if ($neoExchange->id_address_invoice == $neoExchange->id_address_delivery)
{
$addressDelivery = $addressInvoice;
if (isset($invoiceState))
$deliveryState = $invoiceState;
}
else
{
$addressDelivery = new Address($neoExchange->id_address_delivery, $this->context->language->id);
if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state)
$deliveryState = new State((int)($addressDelivery->id_state));
}*/
$this->toolbar_title = sprintf($this->l('Intercambio #%1$d (%2$s) - %3$s %4$s'), $neoExchange->id, $neoExchange->reference, $customer->firstname, $customer->lastname);
if (Shop::isFeatureActive()) {
$shop = new Shop((int) $neoExchange->id_shop);
$this->toolbar_title .= ' - ' . sprintf($this->l('Shop: %s'), $shop->name);
}
// gets warehouses to ship products, if and only if advanced stock management is activated
$warehouse_list = null;
$payment_methods = array();
foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
$module = Module::getInstanceByName($payment['name']);
if (Validate::isLoadedObject($module) && $module->active) {
$payment_methods[] = $module->displayName;
}
}
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $neoExchange->getCurrentOrderState();
if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) {
$display_out_of_stock_warning = true;
}
$total_buy = 0;
$total_sale = 0;
$products_buy = count($products);
$products_sale = count($products2);
// products current stock (from stock_available)
foreach ($products as &$product) {
$total_buy += $product['price'];
}
foreach ($products2 as &$product) {
$total_sale += $product['price'];
}
$gender = new Gender((int) $customer->id_gender, $this->context->language->id);
$history = $neoExchange->getHistory($this->context->language->id);
foreach ($history as &$order_state) {
$order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black';
}
// Smarty assign
$this->tpl_view_vars = array('order' => $neoExchange, 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'customerStats' => $customer->getStats(), 'products' => $products, 'products2' => $products2, 'total_buy' => $total_buy, 'total_sale' => $total_sale, 'products_buy' => $products_buy, 'products_sale' => $products_sale, 'neo_order_shipping_price' => 0, 'orders_total_paid_tax_incl' => $neoExchange->getOrdersTotalPaid(), 'total_paid' => $neoExchange->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($neoExchange->id_customer, $neoExchange->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($neoExchange->id_customer), 'orderMessages' => OrderMessage::getOrderMessages($neoExchange->id_lang), 'messages' => Message::getMessagesByOrderId($neoExchange->id, true), 'history' => $history, 'neoStatus' => NeoStatusCore::getNeoStatus(), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($neoExchange->id), 'currentState' => $neoExchange->getCurrentOrderState(), 'currency' => new Currency($neoExchange->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($neoExchange->id_shop), 'previousOrder' => $neoExchange->getPreviousOrderId(), 'nextOrder' => $neoExchange->getNextOrderId(), 'current_index' => self::$currentIndex, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $neoExchange->getInvoicesCollection(), 'not_paid_invoices_collection' => $neoExchange->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $neoExchange->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)));
return parent::renderView();
}
示例12: hookOrderConfirmation
/**
* Execute hook
*
* @param mixed $params
*/
public function hookOrderConfirmation($params)
{
global $smarty, $cookie, $link;
if (!$this->active) {
return;
}
// seting error handler
eval('function itembaseErrorHandler($errno, $errstr, $errfile, $errline) {
' . ((bool) Configuration::get('PS_ITEMBASE_DEBUG') ? 'echo "
<!--ITEMBASE
".print_r(array($errno, $errstr, $errfile, $errline), true)."ITEMBASE-->
";' : '') . '
return true;
}');
set_error_handler('itembaseErrorHandler', E_ALL);
try {
include_once rtrim(_PS_MODULE_DIR_, '/') . '/itembase/plugindata.php';
include_once rtrim(_PS_MODULE_DIR_, '/') . '/itembase/oauth.php';
// geting access token
$responseArray = $this->jsonDecode(authenticateClient(Configuration::get('PS_ITEMBASE_APIKEY'), Configuration::get('PS_ITEMBASE_SECRET')));
if (!isset($responseArray['access_token'])) {
itembaseErrorHandler(0, 'no access_token for ' . Tools::safeOutput(Configuration::get('PS_ITEMBASE_APIKEY')) . ' ' . substr(Tools::safeOutput(Configuration::get('PS_ITEMBASE_SECRET')), 0, 4) . '... ' . PS_ITEMBASE_SERVER_OAUTH . ' ' . print_r($responseArray, true), __FILE__, __LINE__ - 1);
}
// order data gathering
$order = new Order($params['objOrder']->id, NULL);
$currency = Currency::getCurrency((int) $order->id_currency);
$carrier = new Carrier((int) $order->id_carrier);
$language = Language::getLanguage((int) $cookie->id_lang);
$customer = new Customer((int) $order->id_customer);
$address = $customer->getAddresses($cookie->id_lang);
if (is_object($address)) {
$address = (array) $address;
}
if (isset($address['0'])) {
$address = $address['0'];
}
// products data gathering
$allProducts = array();
foreach ($order->getProductsDetail() as $order_detail) {
$product_id = $order_detail['product_id'];
$product = new Product($product_id, true, null);
$cover = Product::getCover($product_id);
$product_img = $link->getImageLink($product->link_rewrite, $product_id . '-' . $cover['id_image']);
if (strpos($product_img, 'http') !== 0) {
$product_img = Tools::getHttpHost(true) . $product_img;
}
$category = new Category($product->id_category_default);
$allProducts[] = array('id' => $order_detail['product_id'], 'category' => $category->name, 'name' => $product->name, 'quantity' => $order_detail['product_quantity'], 'price' => $product->getPrice(true, NULL, 2), 'ean' => $product->ean13, 'isbn' => '', 'asin' => '', 'description' => $product->description_short, 'pic_thumb' => $product_img, 'pic_medium' => $product_img, 'pic_large' => $product_img, 'url' => $product->getLink(), 'presta_lang_id' => $language['id_lang']);
}
$dataForItembase = array('access_token' => $responseArray['access_token'], 'email' => $customer->email, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'street' => $address['address1'] . ($address['address2'] ? ' ' . $address['address2'] : ''), 'zip' => $address['postcode'], 'city' => $address['city'], 'country' => $address['country'], 'phone' => $address['phone'], 'lang' => $language['iso_code'], 'purchase_date' => $order->date_add, 'currency' => $currency['iso_code'], 'total' => $order->total_products_wt, 'order_number' => $order->id, 'customer_id' => $order->id_customer, 'invoice_number' => $order->invoice_number, 'shipping_cost' => $order->total_shipping, 'carrier' => $carrier->name, 'payment_option' => $order->payment, 'is_opt_in' => $customer->newsletter, 'shop_name' => class_exists('Context', false) ? Context::getContext()->shop->name : Configuration::get('PS_SHOP_NAME'), 'products' => $allProducts);
// encoding data
utf8EncodeRecursive($dataForItembase);
$smarty->assign('ibdata', $dataForItembase);
$smarty->assign('ibdatajson', $this->jsonEncode($dataForItembase));
$smarty->assign('ibembedserver', PS_ITEMBASE_SERVER_EMBED);
$smarty->assign('ibhostserver', PS_ITEMBASE_SERVER_HOST);
$smarty->assign('ibpluginversion', PS_ITEMBASE_PLUGIN_VERSION);
$smarty->assign('ibtop', Configuration::get('PS_ITEMBASE_TOP'));
} catch (Exception $e) {
itembaseErrorHandler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
}
// restoring error handler
restore_error_handler();
return $this->display(__FILE__, 'views/templates/front/checkout_plugin.tpl');
}
示例13: hookPaymentTop
public function hookPaymentTop($param)
{
if (!$this->_activeVerification()) {
return false;
}
$smarty = Context::getContext()->smarty;
$customer = new Customer($param['cart']->id_customer);
$addresses = $customer->getAddresses(Context::getContext()->language->id);
$address = new Address($addresses[0]['id_address']);
$cart = new Cart($param['cart']->id);
$link = new Link();
$fidbag_user = new FidbagUser($param['cart']->id_customer);
$fidbag_user->getFidBagUser();
$var = array('path' => $this->_path, 'img' => _PS_IMG_, 'id_customer' => $param['cart']->id_customer, 'id_cart' => $param['cart']->id, 'fidbag_token' => Configuration::get('FIDBAG_TOKEN'), 'module' => _PS_MODULE_DIR_ . $this->_moduleName . '/');
$smarty->assign('glob', $var);
$smarty->assign('main_url', $this->getMainUrl());
$smarty->assign('fidbag_token', Tools::encrypt((int) $param['cart']->id_customer));
$smarty->assign('price', $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING));
$smarty->assign('shipment', $cart->getOrderTotal(true, Cart::ONLY_SHIPPING));
$smarty->assign('total_cart', $cart->getOrderTotal());
$smarty->assign('shipping', $cart->getOrderTotal(true, Cart::ONLY_SHIPPING));
$smarty->assign('discount', $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
$smarty->assign('fidbag_login', $fidbag_user->getLogin());
$smarty->assign('fidbag_password', $fidbag_user->getPassword());
if (_PS_VERSION_ < '1.5') {
$smarty->assign('base_dir', Tools::getProtocol() . Tools::getHttpHost() . __PS_BASE_URI__);
}
if ((int) Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
$smarty->assign('redirect', $link->getPageLink('order-opc.php'));
} else {
if (_PS_VERSION_ >= '1.5') {
$smarty->assign('redirect', $link->getPageLink('order.php', false, null, array('step' => '3')));
} else {
$smarty->assign('redirect', $link->getPageLink('order.php?step=3'));
}
}
if (isset($customer->id_gender)) {
$smarty->assign('sub_gender', $customer->id_gender);
}
$smarty->assign('sub_lastname', $customer->lastname);
$smarty->assign('sub_firstname', $customer->firstname);
$smarty->assign('sub_email', $customer->email);
$smarty->assign('sub_address', $address->address1 . ' ' . $address->address2);
$smarty->assign('sub_zipcode', $address->postcode);
$smarty->assign('sub_city', $address->city);
if (_PS_VERSION_ < '1.5') {
return $this->display(__FILE__, 'views/templates/hook/payment_top_14x.tpl');
}
return $this->display(__FILE__, 'views/templates/hook/payment_top.tpl');
}
示例14: renderView
//.........这里部分代码省略.........
$shop = new Shop((int) $order->id_shop);
$this->toolbar_title .= ' - ' . sprintf($this->trans('Shop: %s', array(), 'Admin.OrdersCustomers.Feature'), $shop->name);
}
// gets warehouses to ship products, if and only if advanced stock management is activated
$warehouse_list = null;
$order_details = $order->getOrderDetailList();
foreach ($order_details as $order_detail) {
$product = new Product($order_detail['product_id']);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) {
$warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']);
foreach ($warehouses as $warehouse) {
if (!isset($warehouse_list[$warehouse['id_warehouse']])) {
$warehouse_list[$warehouse['id_warehouse']] = $warehouse;
}
}
}
}
$payment_methods = array();
foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
$module = Module::getInstanceByName($payment['name']);
if (Validate::isLoadedObject($module) && $module->active) {
$payment_methods[] = $module->displayName;
}
}
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $order->getCurrentOrderState();
if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) {
$display_out_of_stock_warning = true;
}
// products current stock (from stock_available)
foreach ($products as &$product) {
// Get total customized quantity for current product
$customized_product_quantity = 0;
if (is_array($product['customizedDatas'])) {
foreach ($product['customizedDatas'] as $customizationPerAddress) {
foreach ($customizationPerAddress as $customizationId => $customization) {
$customized_product_quantity += (int) $customization['quantity'];
}
}
}
$product['customized_product_quantity'] = $customized_product_quantity;
$product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']);
$resume = OrderSlip::getProductSlipResume($product['id_order_detail']);
$product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity'];
$product['amount_refundable'] = $product['total_price_tax_excl'] - $resume['amount_tax_excl'];
$product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl'];
$product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency);
$product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']);
$product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']);
// if the current stock requires a warning
if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) {
$this->displayWarning($this->trans('This product is out of stock: ', array(), 'Admin.OrdersCustomers.Notification') . ' ' . $product['product_name']);
}
if ($product['id_warehouse'] != 0) {
$warehouse = new Warehouse((int) $product['id_warehouse']);
$product['warehouse_name'] = $warehouse->name;
$warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']);
if (!empty($warehouse_location)) {
$product['warehouse_location'] = $warehouse_location;
} else {
$product['warehouse_location'] = false;
}
} else {
$product['warehouse_name'] = '--';
$product['warehouse_location'] = false;
}
}
// Package management for order
foreach ($products as &$product) {
$pack_items = $product['cache_is_pack'] ? Pack::getItemTable($product['id_product'], $this->context->language->id, true) : array();
foreach ($pack_items as &$pack_item) {
$pack_item['current_stock'] = StockAvailable::getQuantityAvailableByProduct($pack_item['id_product'], $pack_item['id_product_attribute'], $pack_item['id_shop']);
// if the current stock requires a warning
if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) {
$this->displayWarning($this->trans('This product, included in package (' . $product['product_name'] . ') is out of stock: ', array(), 'Admin.OrdersCustomers.Notification') . ' ' . $pack_item['product_name']);
}
$this->setProductImageInformations($pack_item);
if ($pack_item['image'] != null) {
$name = 'product_mini_' . (int) $pack_item['id_product'] . (isset($pack_item['id_product_attribute']) ? '_' . (int) $pack_item['id_product_attribute'] : '') . '.jpg';
// generate image cache, only for back office
$pack_item['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $pack_item['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg');
if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
$pack_item['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
} else {
$pack_item['image_size'] = false;
}
}
}
$product['pack_items'] = $pack_items;
}
$gender = new Gender((int) $customer->id_gender, $this->context->language->id);
$history = $order->getHistory($this->context->language->id);
foreach ($history as &$order_state) {
$order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black';
}
// Smarty assign
$this->tpl_view_vars = array('order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->access('edit'), 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'carrier_list' => $this->getCarrierList($order), 'recalculate_shipping_cost' => (int) Configuration::get('PS_ORDER_RECALCULATE_SHIPPING'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer)));
return parent::renderView();
}
示例15: getCustomersInfo
private function getCustomersInfo()
{
$customer_orders = array();
$customer_addresses = array();
$query_limit = 0;
$query_offset = 0;
if ($this->page !== null && !empty($this->page) && $this->show !== null && !empty($this->show)) {
$query_limit = ((int) $this->page - 1) * (int) $this->show;
$query_offset = (int) $this->show;
}
$customer = new Customer((int) $this->user_id);
// Get all cutomer addresses
$addresses = $customer->getAddresses($this->def_lang);
foreach ($addresses as $address) {
$customer_addresses[] = array('dni' => $address['dni'], 'alias' => $address['alias'], 'first_name' => $address['firstname'], 'last_name' => $address['lastname'], 'company' => $address['company'], 'vat_number' => $address['vat_number'], 'address1' => $address['address1'], 'address2' => $address['address2'], 'postcode' => $address['postcode'], 'city' => $address['city'], 'country' => $address['country'], 'state' => $address['state'], 'phone' => $address['phone'], 'phone_mobile' => $address['phone_mobile'], 'other' => $address['other']);
}
// Get customer general information
$customer_info = array('id_customer' => $customer->id, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'date_add' => $customer->date_add, 'email' => $customer->email);
// Get customer orders
$customer_orders_obj = new DbQuery();
$customer_orders_obj->select('
o.id_order,
o.date_add,
o.total_paid,
o.id_currency,
osl.name AS ord_status,
c.iso_code,
c.sign,
c.format,
SUM(od.product_quantity) AS pr_qty
');
$customer_orders_obj->from('orders', 'o');
$customer_orders_obj->leftJoin('currency', 'c', 'o.id_currency = c.id_currency');
$customer_orders_obj->leftJoin('order_detail', 'od', 'od.id_order = o.id_order');
$customer_orders_obj->leftJoin('order_state_lang', 'osl', 'osl.id_order_state = o.current_state AND osl.id_lang = ' . (int) $this->def_lang);
$customer_orders_obj->where('o.id_customer = ' . (int) $this->user_id);
$customer_orders_obj->groupBy('o.id_order');
$customer_orders_obj->orderBy('o.id_order DESC');
$customer_orders_obj->limit($query_offset, $query_limit);
$customer_orders_sql = $customer_orders_obj->build();
$customer_orders_res = Db::getInstance()->executeS($customer_orders_sql);
foreach ($customer_orders_res as $customer_order) {
if ($this->currency_code != $customer_order['id_currency']) {
$customer_order['total_paid'] = $this->convertPrice($customer_order['total_paid'], $customer_order['id_currency']);
}
$customer_order['total_paid'] = $this->displayPrice($customer_order['total_paid'], $customer_order['id_currency']);
unset($customer_order['id_currency']);
$customer_orders[] = $customer_order;
}
// Get count of orders for customer
$customer_orders_count_obj = new DbQuery();
$customer_orders_count_obj->select('
COUNT(o.id_order) AS count_ords,
SUM(o.total_paid/o.conversion_rate) AS sum_ords
');
$customer_orders_count_obj->from('orders', 'o');
$customer_orders_count_obj->where('o.id_customer = ' . (int) $this->user_id);
$customer_orders_count_sql = $customer_orders_count_obj->build();
$customer_orders_count_res = Db::getInstance()->executeS($customer_orders_count_sql);
$customer_orders_count = array_shift($customer_orders_count_res);
if ($this->currency_code != $this->def_currency) {
$customer_orders_count['sum_ords'] = $this->convertPrice($customer_orders_count['sum_ords'], $this->def_currency);
}
$customer_orders_count['sum_ords'] = $this->displayPrice($customer_orders_count['sum_ords'], $this->currency_code, true);
return array('user_info' => $customer_info, 'addresses' => $customer_addresses, 'customer_orders' => $customer_orders, 'c_orders_count' => (int) $customer_orders_count['count_ords'], 'sum_ords' => $customer_orders_count['sum_ords']);
}