NeilD Posted October 14, 2013 Share Posted October 14, 2013 Hi, I need to be able to tell which groups a customer belongs to when they make an order on the site. What is the best way to achieve this? Can I display the customer groups on the order page? Thanks Neil Link to comment Share on other sites More sharing options...
vekia Posted October 15, 2013 Share Posted October 15, 2013 hello you want to display it on orders list on in order specification page? Link to comment Share on other sites More sharing options...
NeilD Posted October 15, 2013 Author Share Posted October 15, 2013 Orders list page would be perfect that way I can export them to CSV but either would be good Thanks Link to comment Share on other sites More sharing options...
vekia Posted October 15, 2013 Share Posted October 15, 2013 in this case you have to modify AdminOrdersController.php file (/controllers/admin/AdminOrdersController.php) you've got there code: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; change it to: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`, \' (\', gr.`name`, \')\') AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; effect: J. DOE (customer) - where customer is a group name 1 Link to comment Share on other sites More sharing options...
NeilD Posted October 23, 2013 Author Share Posted October 23, 2013 Fantastic! Thanks very much, Vekia, that's perfect Link to comment Share on other sites More sharing options...
killerkhan Posted May 6, 2014 Share Posted May 6, 2014 Hello, How do i get the state of the customer from the address. With the above reference i am able to get the city of the customer but not able to get the state. Anyone can help me please. Thanks, Link to comment Share on other sites More sharing options...
vekia Posted May 7, 2014 Share Posted May 7, 2014 Hello, How do i get the state of the customer from the address. With the above reference i am able to get the city of the customer but not able to get the state. Anyone can help me please. Thanks, and you want to display it as a separate row of table, or as i added customer group above? Link to comment Share on other sites More sharing options...
killerkhan Posted May 7, 2014 Share Posted May 7, 2014 Hello Vekia, As you added the customer group that is also fine. Thanks in Advance. Link to comment Share on other sites More sharing options...
vekia Posted May 7, 2014 Share Posted May 7, 2014 one last question because i've noticed something while dealing with code. customer can select two addresses, one for delivery address, second for invoice from which one you want to display state? Link to comment Share on other sites More sharing options...
killerkhan Posted May 7, 2014 Share Posted May 7, 2014 one last question because i've noticed something while dealing with code. customer can select two addresses, one for delivery address, second for invoice from which one you want to display state? Hello Vekia, I would like to display the state from the delivery address. Thanks, Link to comment Share on other sites More sharing options...
vekia Posted May 7, 2014 Share Posted May 7, 2014 okay so you ahve to add these two left joins LEFT JOIN `'._DB_PREFIX_.'address` ca ON (a.`id_address_delivery` = ca.`id_address`) LEFT JOIN `'._DB_PREFIX_.'state` css ON (ca.`id_state` = css.`id_state`) then you will be able to use css.name to display state name Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 7, 2014 Share Posted May 7, 2014 in this case you have to modify AdminOrdersController.php file (/controllers/admin/AdminOrdersController.php) you've got there code: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; change it to: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`, \' (\', gr.`name`, \')\') AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; effect: J. DOE (customer) - where customer is a group name Please this trick for 1.6.0.6 Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 8, 2014 Share Posted May 8, 2014 Please Vekia, the trick not works in 1.6.0.6 thanks Link to comment Share on other sites More sharing options...
vekia Posted May 8, 2014 Share Posted May 8, 2014 don't copy whole code, just lines that i added Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 8, 2014 Share Posted May 8, 2014 don't copy whole code, just lines that i added Yes I add only this line and nothing change LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 8, 2014 Share Posted May 8, 2014 Yes I add only this line and nothing change LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') I bit of help please when you can thanks Link to comment Share on other sites More sharing options...
killerkhan Posted May 8, 2014 Share Posted May 8, 2014 okay so you ahve to add these two left joins LEFT JOIN `'._DB_PREFIX_.'address` ca ON (a.`id_address_delivery` = ca.`id_address`) LEFT JOIN `'._DB_PREFIX_.'state` css ON (ca.`id_state` = css.`id_state`) then you will be able to use css.name to display state name Hello Vekia, It worked like a charm. Thanks, Link to comment Share on other sites More sharing options...
vekia Posted May 9, 2014 Share Posted May 9, 2014 Yes I add only this line and nothing change LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') you have to change also SELECT condition Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 9, 2014 Share Posted May 9, 2014 you have to change also SELECT condition Where and how please thanks Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 9, 2014 Share Posted May 9, 2014 Where and how please thanks ok thanks solved Link to comment Share on other sites More sharing options...
vekia Posted May 9, 2014 Share Posted May 9, 2014 just copy SELECT clause that i proposed to use Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 9, 2014 Share Posted May 9, 2014 just copy SELECT clause that i proposed to use solved very thanks Link to comment Share on other sites More sharing options...
FJakub Posted May 15, 2014 Share Posted May 15, 2014 Hello, Is it possible to display the list of customers in what is classified a group? I have a prestashop 1.5.6.2 thank you very much Link to comment Share on other sites More sharing options...
cocodeluxe Posted May 15, 2014 Share Posted May 15, 2014 posibility to show the group´s name only when not it´s customer ? thanks Link to comment Share on other sites More sharing options...
leonetrek Posted June 27, 2014 Share Posted June 27, 2014 (edited) Hello. How can I show the name of the group user on all pages near the price? And in the heder near basket? Thank`s Prestashop 1.5.4.1 Edited June 27, 2014 by leonetrek (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 27, 2014 Share Posted June 27, 2014 hello you mean that you want to display group that customer is associated with? Link to comment Share on other sites More sharing options...
leonetrek Posted June 27, 2014 Share Posted June 27, 2014 hello you mean that you want to display group that customer is associated with? Yes. Thank that have responded. I have already solved this problem. On my 1.5.4.1 It works Here's a link to solve http://www.prestashop.com/forums/topic/228277-get-customer-group-id-in-smarty/ Link to comment Share on other sites More sharing options...
vekia Posted June 27, 2014 Share Posted June 27, 2014 Yes. Thank that have responded. I have already solved this problem. On my 1.5.4.1 It works Here's a link to solve http://www.prestashop.com/forums/topic/228277-get-customer-group-id-in-smarty/ great thank you for sharing url to solution :-) Link to comment Share on other sites More sharing options...
djuhari Posted July 11, 2014 Share Posted July 11, 2014 Could you help me to get name of customer group on order detail page (BO) I now only get the id number in order detail page by editing the veiw.tpl file. (using 1.5.6) Link to comment Share on other sites More sharing options...
vekia Posted July 12, 2014 Share Posted July 12, 2014 hello have you tried method with controller modification that i pasted several posts before/ Link to comment Share on other sites More sharing options...
djuhari Posted July 12, 2014 Share Posted July 12, 2014 Which post. I mean not in order list. But in order detail in bo. I manage it by modifying the controller. But don't know, if the code is beautiful. It works. Copy the code from customer controller. Link to comment Share on other sites More sharing options...
bocane Posted September 8, 2014 Share Posted September 8, 2014 Hi, Adding the shipping chosen by the client in the order list would be a great feature (for example in the same column as the payment method). Thank you! Link to comment Share on other sites More sharing options...
cocodeluxe Posted December 8, 2014 Share Posted December 8, 2014 Please which it´s the Concat query for customer´s complete name and customer group Link to comment Share on other sites More sharing options...
killerkhan Posted May 11, 2015 Share Posted May 11, 2015 in this case you have to modify AdminOrdersController.php file (/controllers/admin/AdminOrdersController.php) you've got there code: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; change it to: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`, \' (\', gr.`name`, \')\') AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; effect: J. DOE (customer) - where customer is a group name Hello Vekia, How can i add state in the Customers->Addresses. Thanks, Link to comment Share on other sites More sharing options...
rjtrabajo Posted July 16, 2015 Share Posted July 16, 2015 Hi, i have 1.6.0.14 and i added the line: LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') but nothing happen, can you tell me what more i have to make? many thanks for your help. Link to comment Share on other sites More sharing options...
rjtrabajo Posted July 16, 2015 Share Posted July 16, 2015 ok i solved! but i have a question, this shows the group where is the customer. i have a modification where customers can change the group, and for example if they buy with GROUP A, in back office show (Group A), but if after they change to GROUP B and make another order, change all orders before too in back office to GROUP B. thanks Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2015 Share Posted July 16, 2015 in this case it will be necessary to store somewhere information what group was used to order stuff from shop. there is no other way. if i were you i will add new column to ps_orders table "customer_group" and i will add there this information then you will be able to display it easily Link to comment Share on other sites More sharing options...
wasyl_sz Posted August 3, 2015 Share Posted August 3, 2015 Please Help me, how can i add state in the Customers->Addresses? Link to comment Share on other sites More sharing options...
pxloft Posted August 6, 2015 Share Posted August 6, 2015 Hi, I am trying to add the customers company in the The same way you did with the customer group... how do I do this? Link to comment Share on other sites More sharing options...
RSI-SHOP Posted November 5, 2015 Share Posted November 5, 2015 Great code work ! Vekia I have question . Possible is display name group in separate column ? Link to comment Share on other sites More sharing options...
CoolSeed Posted February 5, 2016 Share Posted February 5, 2016 Hi! I have the same question basically. Display the group name in the customers listing in the backoffice. So that my client when viewing his customers knows which group clients are into. I can't manage to make my AdminCustomersController override works. I have found this one but it show only the id. I try to fiddle with your code here but no luck. _______ class AdminCustomersController extends AdminCustomersControllerCore { public function __construct() { parent::__construct(); $this->_select .= ', ca.id_group as group_id'; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'customer_group` ca ON (ca.`id_customer` = a.`id_customer`)'; $this->fields_list['group_id'] = array( 'title' => $this->l('Groupe'), 'width' => 200, 'callback' => 'groupe' ); } public function groupe($id_group) { return $id_group; } } _________ If someone knows how to display in a separate column the name of the group on the BO customers list. Best regards, Quentin Link to comment Share on other sites More sharing options...
planetediscount Posted June 7, 2016 Share Posted June 7, 2016 Hello Coolseed, have you arrive to get the name of group, instead of ID ? By the way your code working fine on 1.6.1.4 Link to comment Share on other sites More sharing options...
CoolSeed Posted June 9, 2016 Share Posted June 9, 2016 Hello, No I did not manage to do it. I gave up, needed to move to other issues, and forgot a bit about it But if someone has the solution, I will be happy to give it a try. Link to comment Share on other sites More sharing options...
deffi Posted March 3, 2018 Share Posted March 3, 2018 So we did those changes in code and we see customers group and this is pretty cool but if we could sort customers by group like we sorting them by status it will be super helpful to manage orders. Is there any solutions or thoughts ? Link to comment Share on other sites More sharing options...
beepow Posted December 10, 2019 Share Posted December 10, 2019 On 5/9/2014 at 2:22 PM, vekia said: just copy SELECT clause that i proposed to use How can I Override this instead of changing the original file? (thank you in any case) Link to comment Share on other sites More sharing options...
antonio_fiorella Posted October 21, 2020 Share Posted October 21, 2020 (edited) On 10/15/2013 at 8:00 PM, vekia said: in this case you have to modify AdminOrdersController.php file (/controllers/admin/AdminOrdersController.php) you've got there code: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; change it to: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`, \' (\', gr.`name`, \')\') AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; effect: J. DOE (customer) - where customer is a group name Edited October 21, 2020 by antonio_fiorella (see edit history) Link to comment Share on other sites More sharing options...
tattichemarketing Posted October 21, 2020 Share Posted October 21, 2020 (edited) Ciao facendo la modifica su prestashop 1.7 il sistema mi da questo errore Query SQL non valida Unknown column 'country.id_country' in 'field list' On 10/15/2013 at 8:00 PM, vekia said: in this case you have to modify AdminOrdersController.php file (/controllers/admin/AdminOrdersController.php) you've got there code: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; change it to: $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`, \' (\', gr.`name`, \')\') AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'group_lang` gr ON (gr.`id_group` = c.`id_default_group` AND gr.`id_lang`= '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; effect: J. DOE (customer) - where customer is a group name Edited October 21, 2020 by tattichemarketing (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now