本文整理汇总了PHP中Order::getCustomerOrders方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getCustomerOrders方法的具体用法?PHP Order::getCustomerOrders怎么用?PHP Order::getCustomerOrders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::getCustomerOrders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplateVarOrders
public function getTemplateVarOrders()
{
$orders = array();
$customer_orders = Order::getCustomerOrders($this->context->customer->id);
foreach ($customer_orders as $customer_order) {
$order = new Order((int) $customer_order['id_order']);
$orders[$customer_order['id_order']] = $this->order_presenter->present($order);
}
return $orders;
}
示例2: process
public function process()
{
parent::process();
if ($orders = Order::getCustomerOrders((int) self::$cookie->id_customer)) {
foreach ($orders as &$order) {
$myOrder = new Order((int) $order['id_order']);
if (Validate::isLoadedObject($myOrder)) {
$order['virtual'] = $myOrder->isVirtual(false);
}
}
}
self::$smarty->assign(array('orders' => $orders, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'slowValidation' => Tools::isSubmit('slowvalidation')));
}
示例3: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if ($orders = Order::getCustomerOrders($this->context->customer->id)) {
foreach ($orders as &$order) {
$myOrder = new Order((int) $order['id_order']);
if (Validate::isLoadedObject($myOrder)) {
$order['virtual'] = $myOrder->isVirtual(false);
}
}
}
$this->context->smarty->assign(array('orders' => $orders, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'reorderingAllowed' => !(int) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), 'slowValidation' => Tools::isSubmit('slowvalidation')));
$this->setTemplate(_PS_THEME_DIR_ . 'history.tpl');
}
示例4: initContent
public function initContent()
{
parent::initContent();
if ($orders = Order::getCustomerOrders($this->context->customer->id)) {
foreach ($orders as &$order) {
$myOrder = new Order((int) $order['id_order']);
if (Validate::isLoadedObject($myOrder)) {
$order['virtual'] = $myOrder->isVirtual(false);
}
}
}
$has_address = $this->context->customer->getAddresses($this->context->language->id);
$this->context->smarty->assign(array('orders' => $orders, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), 'slowValidation' => Tools::isSubmit('slowvalidation'), 'has_customer_an_address' => empty($has_address), 'voucherAllowed' => (int) CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN')));
$this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount'));
$this->setTemplate(_PS_THEME_DIR_ . 'my-account.tpl');
}
示例5: getCustomerOrders
/**
* @param int $customerId
* @param int $limit
* @param int $offset
* @param string $orderDateFrom
* @param string $sortOrder
*
* @return mixed
*/
public function getCustomerOrders($customerId, $limit = 10, $offset = 0, $orderDateFrom = '', $sortOrder = 'created_desc')
{
$orders = Order::getCustomerOrders($customerId);
$orders = $this->sortCoreOrders($orders, $sortOrder);
$orderCount = 0;
$result = array();
if ($orderDateFrom != '') {
$dateTime = new DateTime($orderDateFrom);
$orderDateFrom = $dateTime->getTimestamp();
} else {
$orderDateFrom = false;
}
foreach ($orders as $order) {
/**
* handle offset
*/
if ($orderCount < $offset) {
$orderCount++;
continue;
}
/**
* handle date from
*/
if ($orderDateFrom) {
$dateTime = new DateTime($order['date_add']);
$orderDateFromCompare = $dateTime->getTimestamp();
if ($orderDateFromCompare < $orderDateFrom) {
$orderCount++;
continue;
}
}
/**
* handle limit
*/
if ($orderCount == $limit) {
break;
}
$result[] = $order;
$orderCount++;
}
return $result;
}
示例6: delete
public function delete()
{
if (!count(Order::getCustomerOrders((int) $this->id))) {
$addresses = $this->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
foreach ($addresses as $address) {
$obj = new Address((int) $address['id_address']);
$obj->delete();
}
}
Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'customer_group` WHERE `id_customer` = ' . (int) $this->id);
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'message WHERE id_customer=' . (int) $this->id);
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'specific_price WHERE id_customer=' . (int) $this->id);
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'compare WHERE id_customer=' . (int) $this->id);
$carts = Db::getInstance()->executes('SELECT id_cart
FROM ' . _DB_PREFIX_ . 'cart
WHERE id_customer=' . (int) $this->id);
if ($carts) {
foreach ($carts as $cart) {
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cart WHERE id_cart=' . (int) $cart['id_cart']);
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart=' . (int) $cart['id_cart']);
}
}
$cts = Db::getInstance()->executes('SELECT id_customer_thread
FROM ' . _DB_PREFIX_ . 'customer_thread
WHERE id_customer=' . (int) $this->id);
if ($cts) {
foreach ($cts as $ct) {
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'customer_thread WHERE id_customer_thread=' . (int) $ct['id_customer_thread']);
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'customer_message WHERE id_customer_thread=' . (int) $ct['id_customer_thread']);
}
}
CartRule::deleteByIdCustomer((int) $this->id);
// start of implementation of the module code - taxamo
Taxamoeuvat::deleteCCPrefix($this->id);
// end of code implementation module - taxamo
return parent::delete();
}
示例7: buildXMLOrder
private function buildXMLOrder($id_order)
{
CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, 'construction du flux pour order ' . $id_order);
$order = new Order($id_order);
//gets back the delivery address
$address_delivery = new Address((int) $order->id_address_delivery);
//gets back the invoice address
$address_invoice = new Address((int) $order->id_address_invoice);
//gets back the customer
$customer = new Customer((int) $order->id_customer);
//initializatino of the XML root: <control>
$xml_element_control = new CertissimControl();
//gets the lang used in the order
$id_lang = $order->id_lang;
//sets the gender, depends on PS version
if (_PS_VERSION_ < '1.5') {
$gender = $customer->id_gender == 2 ? $this->l('Ms.') : $this->l('Mr.');
} else {
$customer_gender = new Gender($customer->id_gender);
$lang_id = Language::getIdByIso('en');
if (empty($lang_id)) {
$lang_id = Language::getIdByIso('fr');
}
CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "id_gender = " . $customer->id_gender . ", gender name =" . $customer_gender->name[$lang_id]);
$gender = $this->l($customer_gender->name[$lang_id]);
}
//initialization of the element <utilisateur type='facturation'...>
$xml_element_invoice_customer = new CertissimUtilisateur('facturation', $gender, $address_invoice->lastname, $address_invoice->firstname, $address_invoice->company, $address_invoice->phone, $address_invoice->phone_mobile, null, $customer->email);
//gets customer stats
$customer_stats = $customer->getStats();
//gets already existing orders for the customer
$all_orders = Order::getCustomerOrders((int) $customer->id);
//initialization of the element <siteconso>
$xml_element_invoice_customer_stats = new CertissimSiteconso($customer_stats['total_orders'], $customer_stats['nb_orders'], $all_orders[count($all_orders) - 1]['date_add'], count($all_orders) > 1 ? $all_orders[1]['date_add'] : null);
//gets back the invoice country
$country = new Country((int) $address_invoice->id_country);
//initialization of the element <adresse type="facturation" ...>
$xml_element_invoice_address = new CertissimAdresse('facturation', $address_invoice->address1, $address_invoice->address2, $address_invoice->postcode, $address_invoice->city, $country->name[$id_lang]);
//gets back the carrier used for this order
$carrier = new Carrier((int) $order->id_carrier);
//gets the carrier certissim type
if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
$carrier_type = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE', null, null, $order->id_shop);
} else {
$carrier_type = Configuration::get('CERTISSIM_' . (string) $carrier->id . '_CARRIER_TYPE');
}
//if the order is to be delivered at home: element <utilisateur type="livraison"...> has to be added
if ($carrier_type == 4) {
//initialization of the element <utilisateur type="livraison" ...>
$xml_element_delivery_customer = new CertissimUtilisateur('livraison', $customer->id_gender == 2 ? $this->l('Miss') : $this->l('Mister'), $address_delivery->lastname, $address_delivery->firstname, $address_delivery->company, $address_delivery->phone, $address_delivery->phone_mobile, null, $customer->email);
//gets back the delivery country
$country = new Country((int) $address_delivery->id_country);
//initialization of the element <adresse type="livraison" ...>
$xml_element_delivery_address = new CertissimAdresse('livraison', $address_delivery->address1, $address_delivery->address2, $address_delivery->postcode, $address_delivery->city, $country->name[$id_lang], null);
}
//gets the used currency
$currency = new Currency((int) $order->id_currency);
if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
$siteid = Configuration::get('CERTISSIM_SITEID', null, null, $order->id_shop);
} else {
$siteid = Configuration::get('CERTISSIM_SITEID');
}
//initialize the element <infocommande>
$xml_element_order_details = new CertissimInfocommande($siteid, $order->id, (string) $order->total_paid, self::getIpByOrder((int) $order->id), date('Y-m-d H:i:s'), $currency->iso_code);
//gets the order products
$products = $order->getProducts();
//define the default product type (depends on PS version)
if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
$default_product_type = Configuration::get('CERTISSIM_DEFAULT_PRODUCT_TYPE', null, null, $order->id_shop);
} else {
$default_product_type = Configuration::get('CERTISSIM_DEFAULT_PRODUCT_TYPE');
}
//initialization of the element <list ...>
$xml_element_products_list = new CertissimProductList();
//initialize the boolean that says if all the products in the order are downloadables
$alldownloadables = true;
foreach ($products as $product) {
//check if the visited product is downloadable and update the boolean value
$alldownloadables = $alldownloadables && strlen($product['download_hash']) > 0;
//gets the main product category
$product_categories = Product::getProductCategories((int) $product['product_id']);
$product_category = array_pop($product_categories);
//initilization of the element <produit ...>
$xml_element_product = new CertissimXMLElement("<produit></produit>");
//gets the product certissim category (depends on PS version)
if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) {
$product_type = Configuration::get('CERTISSIM' . $product_category . '_PRODUCT_TYPE', null, null, $order->id_shop);
} else {
$product_type = Configuration::get('CERTISSIM' . $product_category . '_PRODUCT_TYPE');
}
//if a certissim category is set: the type attribute takes the product certissim type value
if ($product_type) {
$xml_element_product->addAttribute('type', Configuration::get('CERTISSIM' . $product_category . '_PRODUCT_TYPE', null, null, $order->id_shop));
} else {
//if certissim category not set: the type attribute takes the default value
$xml_element_product->addAttribute('type', $default_product_type);
}
//sets the product reference that will be inserted into the XML stream
//uses the product name by default
$product_ref = $product['product_name'];
//.........这里部分代码省略.........
示例8: hookNewOrder
public function hookNewOrder($params)
{
if ($params['order']->total_paid <= 0) {
return;
}
if (!$this->needCheck($params['order']->module, $params['order']->total_paid)) {
return false;
}
$address_delivery = new Address((int) $params['order']->id_address_delivery);
$address_invoice = new Address((int) $params['order']->id_address_invoice);
$customer = new Customer((int) $params['order']->id_customer);
$orderFianet = new fianet_order_xml();
$id_lang = Configuration::get('PS_LANG_DEFAULT');
if ($address_invoice->company == '') {
$orderFianet->billing_user->set_quality_nonprofessional();
} else {
$orderFianet->billing_user->set_quality_professional();
}
$orderFianet->billing_user->titre = $customer->id_gender == 1 ? $this->l('Mr.') : ($customer->id_gender == 2 ? $this->l('Mrs') : $this->l('Mr.'));
$orderFianet->billing_user->nom = utf8_decode($address_invoice->lastname);
$orderFianet->billing_user->prenom = utf8_decode($address_invoice->firstname);
$orderFianet->billing_user->societe = utf8_decode($address_invoice->company);
$orderFianet->billing_user->telhome = utf8_decode($address_invoice->phone);
$orderFianet->billing_user->office = '';
$orderFianet->billing_user->telmobile = utf8_decode($address_invoice->phone_mobile);
$orderFianet->billing_user->telfax = '';
$orderFianet->billing_user->email = $customer->email;
$customer_stats = $customer->getStats();
$all_orders = Order::getCustomerOrders((int) $customer->id);
$orderFianet->billing_user->site_conso = new fianet_user_siteconso_xml();
$orderFianet->billing_user->site_conso->ca = $customer_stats['total_orders'];
$orderFianet->billing_user->site_conso->nb = $customer_stats['nb_orders'];
$orderFianet->billing_user->site_conso->datepremcmd = $all_orders[count($all_orders) - 1]['date_add'];
if (count($all_orders) > 1) {
$orderFianet->billing_user->site_conso->datederncmd = $all_orders[1]['date_add'];
}
$orderFianet->billing_adress->rue1 = utf8_decode($address_invoice->address1);
$orderFianet->billing_adress->rue2 = utf8_decode($address_invoice->address2);
$orderFianet->billing_adress->cpostal = utf8_decode($address_invoice->postcode);
$orderFianet->billing_adress->ville = utf8_decode($address_invoice->city);
$country = new Country((int) $address_invoice->id_country);
$orderFianet->billing_adress->pays = utf8_decode($country->name[$id_lang]);
//delivery adresse not send if carrier id is 1 or 2
$carrier_id = array(1, 2);
if (!in_array(Configuration::get('SAC_CARRIER_TYPE_' . (int) $params['cart']->id_carrier), $carrier_id)) {
$orderFianet->delivery_user = new fianet_delivery_user_xml();
$orderFianet->delivery_adress = new fianet_delivery_adress_xml();
if ($address_delivery->company == '') {
$orderFianet->delivery_user->set_quality_nonprofessional();
} else {
$orderFianet->delivery_user->set_quality_professional();
}
$orderFianet->delivery_user->titre = $customer->id_gender == 1 ? $this->l('Mr.') : ($customer->id_gender == 2 ? $this->l('Mrs') : $this->l('Unknown'));
$orderFianet->delivery_user->nom = utf8_decode($address_delivery->lastname);
$orderFianet->delivery_user->prenom = utf8_decode($address_delivery->firstname);
$orderFianet->delivery_user->societe = utf8_decode($address_delivery->company);
$orderFianet->delivery_user->telhome = utf8_decode($address_delivery->phone);
$orderFianet->delivery_user->office = '';
$orderFianet->delivery_user->telmobile = utf8_decode($address_delivery->phone_mobile);
$orderFianet->delivery_user->telfax = '';
$orderFianet->delivery_user->email = $customer->email;
$orderFianet->delivery_adress->rue1 = utf8_decode($address_delivery->address1);
$orderFianet->delivery_adress->rue2 = utf8_decode($address_delivery->address2);
$orderFianet->delivery_adress->cpostal = utf8_decode($address_delivery->postcode);
$orderFianet->delivery_adress->ville = utf8_decode($address_delivery->city);
$country = new Country((int) $address_delivery->id_country);
$orderFianet->delivery_adress->pays = utf8_decode($country->name[$id_lang]);
}
$orderFianet->info_commande->refid = $params['order']->id;
$orderFianet->info_commande->montant = $params['order']->total_paid;
$currency = new Currency((int) $params['order']->id_currency);
$orderFianet->info_commande->devise = $currency->iso_code;
$orderFianet->info_commande->ip = self::getIpByCart((int) $params['cart']->id);
$orderFianet->info_commande->timestamp = date('Y-m-d H:i:s');
$products = $params['cart']->getProducts();
$default_product_type = Configuration::get('SAC_DEFAULT_PRODUCT_TYPE');
foreach ($products as $product) {
$product_categories = Product::getIndexedCategories((int) $product['id_product']);
$have_sac_cat = false;
$produit = new fianet_product_xml();
if (Configuration::get('SAC_CATEGORY_TYPE_' . $product['id_category_default'])) {
$produit->type = Configuration::get('SAC_CATEGORY_TYPE_' . $product['id_category_default']);
} else {
$produit->type = $default_product_type;
}
$produit->ref = utf8_decode((isset($product['reference']) and !empty($product['reference'])) ? $product['reference'] : ((isset($product['ean13']) and !empty($product['ean13'])) ? $product['ean13'] : $product['name']));
$produit->nb = $product['cart_quantity'];
$produit->prixunit = $product['price'];
$produit->name = utf8_decode($product['name']);
$orderFianet->info_commande->list->add_product($produit);
}
$carrier = new Carrier((int) $params['order']->id_carrier);
$orderFianet->info_commande->transport->type = Configuration::get('SAC_CARRIER_TYPE_' . (int) $carrier->id);
$orderFianet->info_commande->transport->nom = $carrier->name;
$orderFianet->info_commande->transport->rapidite = self::getCarrierFastById((int) $carrier->id);
$orderFianet->payment->type = Configuration::get('SAC_PAYMENT_TYPE_' . substr($params['order']->module, 0, 15));
$xml = $orderFianet->get_xml();
$sender = new fianet_sender();
if (Configuration::get('SAC_PRODUCTION')) {
$sender->mode = 'production';
//.........这里部分代码省略.........
示例9: hookAdminCustomers
/**
* Hook display in tab AdminCustomers on BO
* Data table with all sponsors informations for a customer
*/
public function hookAdminCustomers($params)
{
$customer = new Customer(intval($params['id_customer']));
if (!Validate::isLoadedObject($customer)) {
die(Tools::displayError('Incorrect object Customer.'));
}
global $cookie;
$friends = ReferralProgramModule::getSponsorFriend($customer->id);
if ($id_referralprogram = ReferralProgramModule::isSponsorised(intval($customer->id), true)) {
$referralprogram = new ReferralProgramModule($id_referralprogram);
$sponsor = new Customer($referralprogram->id_sponsor);
}
$html = '<h2>' . $this->l('Referral program') . '</h2>';
// link to the detail of the sponsor
$html .= '<h3>' . (isset($sponsor) ? $this->l('Customer\'s sponsor:') . ' <a href="index.php?tab=AdminCustomers&id_customer=' . $sponsor->id . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '">' . $sponsor->firstname . ' ' . $sponsor->lastname . '</a>' : $this->l('No one has sponsored this customer.')) . '</h3>';
if ($friends and sizeof($friends)) {
$html .= '<h3>' . sizeof($friends) . ' ' . (sizeof($friends) > 1 ? $this->l('sponsored customers:') : $this->l('sponsored customer:')) . '</h3>';
$html .= '
<table cellspacing="0" cellpadding="0" class="table">
<tr>
<th class="center">' . $this->l('ID') . '</th>
<th class="center">' . $this->l('Name') . '</th>
<th class="center">' . $this->l('Email') . '</th>
<th class="center">' . $this->l('Registration date') . '</th>
<th class="center">' . $this->l('Sponsored customers') . '</th>
<th class="center">' . $this->l('Placed orders') . '</th>
<th class="center">' . $this->l('Inscribed') . '</th>
</tr>';
foreach ($friends as $key => $friend) {
$orders = Order::getCustomerOrders($friend['id_customer']);
$html .= '
<tr ' . ($key++ % 2 ? 'class="alt_row"' : '') . ' ' . (intval($friend['id_customer']) ? 'style="cursor: pointer" onclick="document.location = \'?tab=AdminCustomers&id_customer=' . $friend['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '\'"' : '') . '>
<td class="center">' . (intval($friend['id_customer']) ? $friend['id_customer'] : '--') . '</td>
<td>' . $friend['firstname'] . ' ' . $friend['lastname'] . '</td>
<td>' . $friend['email'] . '</td>
<td>' . Tools::displayDate($friend['date_add'], intval($cookie->id_lang), true) . '</td>
<td align="right">' . sizeof(ReferralProgramModule::getSponsorFriend($friend['id_customer'])) . '</td>
<td align="right">' . ($orders ? sizeof($orders) : 0) . '</td>
<td align="center">' . (intval($friend['id_customer']) ? '<img src="' . _PS_ADMIN_IMG_ . 'enabled.gif" />' : '<img src="' . _PS_ADMIN_IMG_ . 'disabled.gif" />') . '</td>
</tr>';
}
$html .= '
</table>';
} else {
$html .= $customer->firstname . ' ' . $customer->lastname . ' ' . $this->l('has not sponsored any friends yet.');
}
return $html . '<br/><br/>';
}
示例10: die
die('Error: Invalid Token');
}
$id_shop_group = Tools::getValue('id_shop_group', 'NULL');
$id_shop = Tools::getValue('id_shop', 'NULL');
$sendin = new Sendinblue();
$sendin_order_track_status = Configuration::get('Sendin_order_tracking_Status', '', $id_shop_group, $id_shop);
if ($sendin_order_track_status == 0) {
$handle = fopen(_PS_MODULE_DIR_ . 'sendinblue/csv/ImportOldOrdersToSendinblue.csv', 'w+');
$key_value = array();
$key_value[] = 'EMAIL,ORDER_ID,ORDER_PRICE,ORDER_DATE';
foreach ($key_value as $linedata) {
fwrite($handle, $linedata . "\n");
}
$customer_detail = $sendin->getAllCustomers($id_shop_group, $id_shop);
foreach ($customer_detail as $customer_value) {
$orders = Order::getCustomerOrders($customer_value['id_customer']);
if (count($orders) > 0) {
$data = array();
$data['key'] = Configuration::get('Sendin_Api_Key', '', $id_shop_group, $id_shop);
$data['webaction'] = 'USERS-STATUS';
$data['email'] = $customer_value['email'];
$sendin->curlRequest($data);
$user_status = Tools::jsonDecode($sendin->curlRequest($data), true);
if ($user_status['result'] != '') {
foreach ($orders as $orders_data) {
if (version_compare(_PS_VERSION_, '1.5', '>=')) {
$order_id = $orders_data['reference'];
} else {
$order_id = $orders_data['id_order'];
}
$order_price = Tools::safeOutput($orders_data['total_paid']);
示例11: renderView
public function renderView()
{
if (!($id_customer_thread = (int) Tools::getValue('id_customer_thread'))) {
return;
}
$this->context = Context::getContext();
if (!($thread = $this->loadObject())) {
return;
}
$this->context->cookie->{'customer_threadFilter_cl!id_contact'} = $thread->id_contact;
$employees = Employee::getEmployees();
$messages = CustomerThread::getMessageCustomerThreads($id_customer_thread);
foreach ($messages as $key => $mess) {
if ($mess['id_employee']) {
$employee = new Employee($mess['id_employee']);
$messages[$key]['employee_image'] = $employee->getImage();
}
if (isset($mess['file_name']) && $mess['file_name'] != '') {
$messages[$key]['file_name'] = _THEME_PROD_PIC_DIR_ . $mess['file_name'];
} else {
unset($messages[$key]['file_name']);
}
if ($mess['id_product']) {
$product = new Product((int) $mess['id_product'], false, $this->context->language->id);
if (Validate::isLoadedObject($product)) {
$messages[$key]['product_name'] = $product->name;
$messages[$key]['product_link'] = $this->context->link->getAdminLink('AdminProducts') . '&updateproduct&id_product=' . (int) $product->id;
}
}
}
$next_thread = CustomerThread::getNextThread((int) $thread->id);
$contacts = Contact::getContacts($this->context->language->id);
$actions = array();
if ($next_thread) {
$next_thread = array('href' => self::$currentIndex . '&id_customer_thread=' . (int) $next_thread . '&viewcustomer_thread&token=' . $this->token, 'name' => $this->l('Reply to the next unanswered message in this thread'));
}
if ($thread->status != 'closed') {
$actions['closed'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=2&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Mark as "handled"'), 'name' => 'setstatus', 'value' => 2);
} else {
$actions['open'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Re-open'), 'name' => 'setstatus', 'value' => 1);
}
if ($thread->status != 'pending1') {
$actions['pending1'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=3&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Mark as "pending 1" (will be answered later)'), 'name' => 'setstatus', 'value' => 3);
} else {
$actions['pending1'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Disable pending status'), 'name' => 'setstatus', 'value' => 1);
}
if ($thread->status != 'pending2') {
$actions['pending2'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=4&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Mark as "pending 2" (will be answered later)'), 'name' => 'setstatus', 'value' => 4);
} else {
$actions['pending2'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Disable pending status'), 'name' => 'setstatus', 'value' => 1);
}
if ($thread->id_customer) {
$customer = new Customer($thread->id_customer);
$orders = Order::getCustomerOrders($customer->id);
if ($orders && count($orders)) {
$total_ok = 0;
$orders_ok = array();
foreach ($orders as $key => $order) {
if ($order['valid']) {
$orders_ok[] = $order;
$total_ok += $order['total_paid_real'];
}
$orders[$key]['date_add'] = Tools::displayDate($order['date_add']);
$orders[$key]['total_paid_real'] = Tools::displayPrice($order['total_paid_real'], new Currency((int) $order['id_currency']));
}
}
$products = $customer->getBoughtProducts();
if ($products && count($products)) {
foreach ($products as $key => $product) {
$products[$key]['date_add'] = Tools::displayDate($product['date_add'], null, true);
}
}
}
$timeline_items = $this->getTimeline($messages, $thread->id_order);
$first_message = $messages[0];
if (!$messages[0]['id_employee']) {
unset($messages[0]);
}
$contact = '';
foreach ($contacts as $c) {
if ($c['id_contact'] == $thread->id_contact) {
$contact = $c['name'];
}
}
$this->tpl_view_vars = array('id_customer_thread' => $id_customer_thread, 'thread' => $thread, 'actions' => $actions, 'employees' => $employees, 'current_employee' => $this->context->employee, 'messages' => $messages, 'first_message' => $first_message, 'contact' => $contact, 'next_thread' => $next_thread, 'orders' => isset($orders) ? $orders : false, 'customer' => isset($customer) ? $customer : false, 'products' => isset($products) ? $products : false, 'total_ok' => isset($total_ok) ? Tools::displayPrice($total_ok, $this->context->currency) : false, 'orders_ok' => isset($orders_ok) ? $orders_ok : false, 'count_ok' => isset($orders_ok) ? count($orders_ok) : false, 'PS_CUSTOMER_SERVICE_SIGNATURE' => str_replace('\\r\\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', (int) $thread->id_lang)), 'timeline_items' => $timeline_items);
if ($next_thread) {
$this->tpl_view_vars['next_thread'] = $next_thread;
}
return parent::renderView();
}
示例12: viewcustomer
public function viewcustomer()
{
global $currentIndex, $cookie, $link;
$irow = 0;
$configurations = Configuration::getMultiple(array('PS_LANG_DEFAULT', 'PS_CURRENCY_DEFAULT'));
$defaultLanguage = (int) $configurations['PS_LANG_DEFAULT'];
$defaultCurrency = (int) $configurations['PS_CURRENCY_DEFAULT'];
if (!($customer = $this->loadObject())) {
return;
}
$customerStats = $customer->getStats();
$addresses = $customer->getAddresses($defaultLanguage);
$products = $customer->getBoughtProducts();
$discounts = Discount::getCustomerDiscounts($defaultLanguage, (int) $customer->id, false, false);
$orders = Order::getCustomerOrders((int) $customer->id, true);
$carts = Cart::getCustomerCarts((int) $customer->id);
$groups = $customer->getGroups();
$messages = CustomerThread::getCustomerMessages((int) $customer->id);
$referrers = Referrer::getReferrers((int) $customer->id);
if ($totalCustomer = Db::getInstance()->getValue('SELECT SUM(total_paid_real) FROM ' . _DB_PREFIX_ . 'orders WHERE id_customer = ' . $customer->id . ' AND valid = 1')) {
Db::getInstance()->getValue('SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM ' . _DB_PREFIX_ . 'orders WHERE valid = 1 GROUP BY id_customer HAVING SUM(total_paid_real) > ' . $totalCustomer);
$countBetterCustomers = (int) Db::getInstance()->getValue('SELECT FOUND_ROWS()') + 1;
} else {
$countBetterCustomers = '-';
}
echo '
<fieldset style="width:400px;float: left"><div style="float: right"><a href="' . $currentIndex . '&addcustomer&id_customer=' . $customer->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a></div>
<span style="font-weight: bold; font-size: 14px;">' . $customer->firstname . ' ' . $customer->lastname . '</span>
<img src="../img/admin/' . ($customer->id_gender == 2 ? 'female' : ($customer->id_gender == 1 ? 'male' : 'unknown')) . '.gif" style="margin-bottom: 5px" /><br />
<a href="mailto:' . $customer->email . '" style="text-decoration: underline; color: blue">' . $customer->email . '</a><br /><br />
' . $this->l('ID:') . ' ' . sprintf('%06d', $customer->id) . '<br />
' . $this->l('Registration date:') . ' ' . Tools::displayDate($customer->date_add, (int) $cookie->id_lang, true) . '<br />
' . $this->l('Last visit:') . ' ' . ($customerStats['last_visit'] ? Tools::displayDate($customerStats['last_visit'], (int) $cookie->id_lang, true) : $this->l('never')) . '<br />
' . ($countBetterCustomers != '-' ? $this->l('Rank: #') . ' ' . (int) $countBetterCustomers . '<br />' : '') . '
</fieldset>
<fieldset style="width:300px;float:left;margin-left:50px">
<div style="float: right">
<a href="' . $currentIndex . '&addcustomer&id_customer=' . $customer->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a>
</div>
' . $this->l('Newsletter:') . ' ' . ($customer->newsletter ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />') . '<br />
' . $this->l('Opt-in:') . ' ' . ($customer->optin ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />') . '<br />
' . $this->l('Age:') . ' ' . $customerStats['age'] . ' ' . (!empty($customer->birthday['age']) ? '(' . Tools::displayDate($customer->birthday, (int) $cookie->id_lang) . ')' : $this->l('unknown')) . '<br /><br />
' . $this->l('Last update:') . ' ' . Tools::displayDate($customer->date_upd, (int) $cookie->id_lang, true) . '<br />
' . $this->l('Status:') . ' ' . ($customer->active ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />');
if ($customer->isGuest()) {
echo '
<div>
' . $this->l('This customer is registered as') . ' <b>' . $this->l('guest') . '</b>';
if (!Customer::customerExists($customer->email)) {
echo '
<form method="POST" action="index.php?tab=AdminCustomers&id_customer=' . (int) $customer->id . '&token=' . Tools::getAdminTokenLite('AdminCustomers') . '">
<input type="hidden" name="id_lang" value="' . (int) (sizeof($orders) ? $orders[0]['id_lang'] : Configuration::get('PS_LANG_DEFAULT')) . '" />
<p class="center"><input class="button" type="submit" name="submitGuestToCustomer" value="' . $this->l('Transform to customer') . '" /></p>
' . $this->l('This feature generates a random password and sends an e-mail to the customer') . '</form>';
} else {
echo '</div><div><b style="color:red;">' . $this->l('A registered customer account exists with the same email address') . '</b>';
}
echo '
</div>
';
}
echo '
</fieldset>
<div class="clear"> </div>';
echo '<fieldset style="height:190px"><legend><img src="../img/admin/cms.gif" /> ' . $this->l('Add a private note') . '</legend>
<p>' . $this->l('This note will be displayed to all the employees but not to the customer.') . '</p>
<form action="ajax.php" method="post" onsubmit="saveCustomerNote();return false;" id="customer_note">
<textarea name="note" id="noteContent" style="width:600px;height:100px" onkeydown="$(\'#submitCustomerNote\').removeAttr(\'disabled\');">' . Tools::htmlentitiesUTF8($customer->note) . '</textarea><br />
<input type="submit" id="submitCustomerNote" class="button" value="' . $this->l(' Save ') . '" style="float:left;margin-top:5px" disabled="disabled" />
<span id="note_feedback" style="float:left;margin:10px 0 0 10px"></span>
</form>
</fieldset>
<div class="clear"> </div>
<script type="text/javascript">
function saveCustomerNote()
{
$("#note_feedback").html("<img src=\\"../img/loader.gif\\" />").show();
var noteContent = $("#noteContent").val();
$.post("ajax.php", {submitCustomerNote:1,id_customer:' . (int) $customer->id . ',note:noteContent}, function (r) {
$("#note_feedback").html("").hide();
if (r == "ok")
{
$("#note_feedback").html("<b style=\\"color:green\\">' . addslashes($this->l('Your note has been saved')) . '</b>").fadeIn(400);
$("#submitCustomerNote").attr("disabled", "disabled");
}
else if (r == "error:validation")
$("#note_feedback").html("<b style=\\"color:red\\">' . addslashes($this->l('Error: your note is not valid')) . '</b>").fadeIn(400);
else if (r == "error:update")
$("#note_feedback").html("<b style=\\"color:red\\">' . addslashes($this->l('Error: cannot save your note')) . '</b>").fadeIn(400);
$("#note_feedback").fadeOut(3000);
});
}
</script>';
echo '<h2>' . $this->l('Messages') . ' (' . sizeof($messages) . ')</h2>';
if (sizeof($messages)) {
echo '
<table cellspacing="0" cellpadding="0" class="table">
<tr>
<th class="center">' . $this->l('Status') . '</th>
<th class="center">' . $this->l('Message') . '</th>
//.........这里部分代码省略.........
示例13: viewcustomer_thread
//.........这里部分代码省略.........
<br />' . $this->l('Set this message as handled') . '
</a>');
}
if ($thread->status != "pending1") {
echo $this->displayButton('
<a href="' . $currentIndex . '&viewcustomer_thread&setstatus=3&id_customer_thread=' . Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token . '">
<img src="../img/admin/msg-pending.png" style="margin-bottom:10px" />
<br />' . $this->l('Declare this message') . '<br />' . $this->l('as "pending 1"') . '<br />' . $this->l('(will be answered later)') . '
</a>');
} else {
echo $this->displayButton('
<a href="' . $currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token . '">
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
<br />' . $this->l('Click here to disable pending status') . '
</a>');
}
if ($thread->status != "pending2") {
echo $this->displayButton('
<a href="' . $currentIndex . '&viewcustomer_thread&setstatus=4&id_customer_thread=' . Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token . '">
<img src="../img/admin/msg-pending.png" style="margin-bottom:10px" />
<br />' . $this->l('Declare this message') . '<br />' . $this->l('as "pending 2"') . '<br />' . $this->l('(will be answered later)') . '
</a>');
} else {
echo $this->displayButton('
<a href="' . $currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token . '">
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
<br />' . $this->l('Click here to disable pending status') . '
</a>');
}
echo '</div>';
if ($thread->id_customer) {
$customer = new Customer($thread->id_customer);
$products = $customer->getBoughtProducts();
$orders = Order::getCustomerOrders($customer->id);
echo '<div style="float:left;width:600px">';
if ($orders and sizeof($orders)) {
$totalOK = 0;
$ordersOK = array();
$tokenOrders = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee);
foreach ($orders as $order) {
if ($order['valid']) {
$ordersOK[] = $order;
$totalOK += $order['total_paid_real'];
}
}
if ($countOK = sizeof($ordersOK)) {
echo '<div style="float:left;margin-right:20px;">
<h2>' . $this->l('Orders') . '</h2>
<table cellspacing="0" cellpadding="0" class="table float">
<tr>
<th class="center">' . $this->l('ID') . '</th>
<th class="center">' . $this->l('Date') . '</th>
<th class="center">' . $this->l('Products') . '</th>
<th class="center">' . $this->l('Total paid') . '</th>
<th class="center">' . $this->l('Payment') . '</th>
<th class="center">' . $this->l('State') . '</th>
<th class="center">' . $this->l('Actions') . '</th>
</tr>';
$irow = 0;
foreach ($ordersOK as $order) {
echo '<tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'?tab=AdminOrders&id_order=' . $order['id_order'] . '&vieworder&token=' . $tokenOrders . '\'">
<td class="center">' . $order['id_order'] . '</td>
<td>' . Tools::displayDate($order['date_add'], (int) $cookie->id_lang) . '</td>
<td align="right">' . $order['nb_products'] . '</td>
<td align="right">' . Tools::displayPrice($order['total_paid_real'], new Currency((int) $order['id_currency'])) . '</td>
<td>' . $order['payment'] . '</td>
示例14: hookPayment
//.........这里部分代码省略.........
if ($discount == '0') {
$discount = 'false';
}
if ($discount == '1') {
$discount = 'true';
}
$discount_boolean = $discount == 'true' ? 1 : 0;
$iframe = Configuration::get('PAYLATER_IFRAME');
if ($iframe == 1) {
$iframe = 'true';
}
$endpoint = $this->url;
$order_id = $this->context->cart->id;
//description
$description = implode(',', $desciption);
$convert_price = Tools::convertPrice($this->context->cart->getOrderTotal(true, 3), $this->context->currency);
$amount = number_format($convert_price, 2, '.', '');
$amount = str_replace('.', '', $amount);
if (Configuration::get('PAYLATER_ENVIRONMENT') == 1) {
$key_to_use = Configuration::get('PAYLATER_ACCOUNT_KEY_LIVE');
} else {
$key_to_use = Configuration::get('PAYLATER_ACCOUNT_KEY_TEST');
}
$widget_type = Configuration::get('PAYLATER_TYPE') == 'false' ? '0' : '1';
$total_paid = 0;
$num_prev_orders = 0;
$sign_up_date = '';
$num_partial_refunds = 0;
$amount_refunded = 0;
$num_full_refunds = 0;
$super_checkout_enabled = false;
$onepagecheckoutps_enabled = false;
$onepagecheckout_enabled = false;
if (version_compare(_PS_VERSION_, "1.5", "<")) {
if ($this->context->cookie->logged) {
$orders = Order::getCustomerOrders($this->context->customer->id);
foreach ($orders as $o) {
$total_paid += $o['total_paid'];
$num_prev_orders++;
}
$sign_up_date = Tools::substr($this->context->customer->date_add, 0, 10);
$order_slips = OrderSlip::getOrdersSlip((int) $this->context->cookie->id_customer);
foreach ($order_slips as $o) {
$num_full_refunds++;
$amount_refunded += $o['amount'];
}
}
} else {
//query for paid statuses
$sql = new DbQuery();
$sql->select('id_order_state');
$sql->from('order_state', 'c');
$sql->where('c.paid = 1');
$db_paid_statuses = Db::getInstance()->executeS($sql);
$paid_statuses = [];
foreach ($db_paid_statuses as $p) {
$paid_statuses[] = $p['id_order_state'];
}
if ($this->context->cookie->logged) {
$orders = Order::getCustomerOrders($this->context->customer->id);
foreach ($orders as $o) {
if (array_key_exists('id_order_state', $o) && in_array($o['id_order_state'], $paid_statuses)) {
$total_paid += $o['total_paid'];
$num_prev_orders++;
}
}
$sign_up_date = Tools::substr($this->context->customer->date_add, 0, 10);
$order_slips = OrderSlip::getOrdersSlip((int) $this->context->cookie->id_customer);
foreach ($order_slips as $o) {
$sql = new DbQuery();
$sql->select('total_paid');
$sql->from('orders', 'c');
$sql->where('c.id_order = ' . $o['id_order']);
$db_total_paid = Db::getInstance()->executeS($sql);
if ($db_total_paid[0]['total_paid'] <= $o['amount']) {
$num_full_refunds++;
} else {
$num_partial_refunds++;
}
$amount_refunded += $o['amount'];
}
}
$super_checkout_enabled = Module::isEnabled('supercheckout');
$onepagecheckoutps_enabled = Module::isEnabled('onepagecheckoutps');
$onepagecheckout_enabled = Module::isEnabled('onepagecheckout');
}
//d($key_to_use.$account_id.$order_id.$amount.$this->context->currency->iso_code.$url_OK.$url_NOK);
$text = $key_to_use . $account_id . $order_id . $amount . $this->context->currency->iso_code . $url_OK . $url_NOK . $callback_url . $discount . $cancelled_url;
$signature = hash('sha512', $text);
$this->smarty->assign(array('endpoint' => $endpoint, 'account_id' => $account_id, 'currency' => $this->context->currency->iso_code, 'ok_url' => $url_OK, 'nok_url' => $url_NOK, 'cancelled_url' => $cancelled_url, 'order_id' => $order_id, 'amount' => $amount, 'description' => $description, 'items' => $items, 'signature' => $signature, 'customer_name' => $this->context->cookie->logged ? $this->context->cookie->customer_firstname . ' ' . $this->context->cookie->customer_lastname : $customer->firstname . " " . $customer->lastname, 'customer_email' => $this->context->cookie->logged ? $this->context->cookie->email : $customer->email, 'locale' => $this->context->language->iso_code, 'cart_products' => $cart_products, 'street' => $street, 'city' => $city, 'province' => $province, 'zipcode' => $zipcode, 'sstreet' => $sstreet, 'scity' => $scity, 'sprovince' => $sprovince, 'szipcode' => $szipcode, 'phone' => $phone, 'mobile_phone' => $mobile_phone, 'dni' => $dni, 'callback_url' => $callback_url, 'discount' => $discount, 'discount_boolean' => $discount_boolean, 'dob' => $this->context->customer->birthday ? $this->context->customer->birthday : $customer->birthday, 'iframe' => $iframe, 'total_paid' => $total_paid, 'num_prev_orders' => $num_prev_orders, 'sign_up_date' => $sign_up_date, 'amount_refunded' => $amount_refunded, 'num_full_refunds' => $num_full_refunds, 'num_partial_refunds' => $num_partial_refunds, 'version4' => version_compare(_PS_VERSION_, "1.5", "<"), 'version3' => version_compare(_PS_VERSION_, "1.4", "<"), 'content' => "javascript:\$('#paylater_form').submit();"));
if ($super_checkout_enabled) {
return $this->display(__FILE__, 'views/templates/front/payment_supercheckout.tpl');
} elseif ($onepagecheckoutps_enabled || $onepagecheckout_enabled) {
return $this->display(__FILE__, 'views/templates/front/payment.tpl');
} elseif ($widget_type) {
return $this->display(__FILE__, 'views/templates/front/payment_widget.tpl');
} else {
return $this->display(__FILE__, 'views/templates/front/payment.tpl');
}
}
示例15: getTemplateVarOrders
public function getTemplateVarOrders()
{
$orders = array();
if (!isset($this->customer_thread['id_order']) && $this->context->customer->isLogged()) {
$customer_orders = Order::getCustomerOrders($this->context->customer->id);
foreach ($customer_orders as $customer_order) {
$myOrder = new Order((int) $customer_order['id_order']);
if (Validate::isLoadedObject($myOrder)) {
$orders[$customer_order['id_order']] = $customer_order;
$orders[$customer_order['id_order']]['products'] = $myOrder->getProducts();
}
}
} elseif ((int) $this->customer_thread['id_order'] > 0) {
$myOrder = new Order($this->customer_thread['id_order']);
if (Validate::isLoadedObject($myOrder)) {
$orders[$myOrder->id] = $this->context->controller->objectPresenter->present($myOrder);
$orders[$myOrder->id]['id_order'] = $myOrder->id;
$orders[$myOrder->id]['products'] = $myOrder->getProducts();
}
}
if ($this->customer_thread['id_product']) {
$id_order = 0;
if (isset($this->customer_thread['id_order'])) {
$id_order = (int) $this->customer_thread['id_order'];
}
$orders[$id_order]['products'][(int) $this->customer_thread['id_product']] = $this->context->controller->objectPresenter->present(new Product((int) $this->customer_thread['id_product']));
}
return $orders;
}