Hello ,
I want to list all my customers who have more than 3(or any number) completed orders.
I want to send them a spacial code and add them to another customer groups.
However i could not find any way to do in in admin panel. Is there any way to do it ?
Thanks all your help.
[quote name='urbanp' timestamp='1417872646' post='198929']
Hello ,
I want to list all my customers who have more than 3(or any number) completed orders.
I want to send them a spacial code and add them to another customer groups.
However i could not find any way to do in in admin panel. Is there any way to do it ?
Thanks all your help.
[/quote]
[color=#282828][font=arial, verdana, tahoma, sans-serif]1. Create “[/font][/color]func.php[color=#282828][font=arial, verdana, tahoma, sans-serif]” in “[/font][/color]app/addons/my_changes[color=#282828][font=arial, verdana, tahoma, sans-serif]” folder with this content:[/font][/color]
```php
use Tygh\Registry;
if (!defined('BOOTSTRAP')) { die('Access denied'); }
function fn_my_changes_get_users_pre(&$params, $auth, $items_per_page, $custom_view) {
if (!empty($params['order_status']) && !empty($params['order_count'])) {
$users = db_get_array("SELECT user_id, COUNT(order_id) as orders_count FROM ?:orders WHERE status = ?s GROUP by user_id HAVING orders_count > ?i", $params['order_status'], $params['order_count']);
foreach ($users as $u_data) {
$params['user_id'][] = $u_data['user_id'];
}
}
return true;
}
function fn_my_changes_get_users_post(&$users, $params, $auth) {
if (!empty($params['order_status']) && !empty($params['order_count']) && empty($params['user_id'])) {
$users = array();
}
return true;
}
```
[color=#282828][font=arial, verdana, tahoma, sans-serif]2. Create "[/font][/color]init.php[color=#282828][font=arial, verdana, tahoma, sans-serif]" in "[/font][/color]app/addons/my_changes[color=#282828][font=arial, verdana, tahoma, sans-serif]" folder with this content:[/font][/color]
```php
if (!defined('BOOTSTRAP')) { die('Access denied'); }
fn_register_hooks(
'get_users_pre',
'get_users_post'
);
```
[color=#282828][font=arial, verdana, tahoma, sans-serif]3. Don't forget enable the "My changes" add-on.[/font][/color]
4. Now, just enter in browser address line the following:
```php [Your domain]/admin.php?dispatch=profiles.manage&user_type=C&order_status=C&order_count=1 ```
where:
orders_status=[ANY STATUS YOU NEED TAKE INTO ACCOUNT]
order_count=[AMOUNT OF ORDERS WITH DEFINED STATUS]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Best regards,[/font][/color]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Leonid[/font][/color]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Chief Technology Officer of CSExperts [/font][/color]
Hello Leonid,
Thank you for your detailed helpful answer.
I have created required files and installed the add-on.
However, when i enter the browser code, it just gets all active customer list. Not my selection.
Should i do any modification ?
Thanks
i think you need to change the C, is basic for clients. if you use another group it should be another sign.
Go over a name from that group and see what “user_type=X” has. X is the letter from that usergroup.
Example:
Cange the X from the usergroup ID
[Your domain]/admin.php?dispatch=profiles.manage&user_type=X&order_status=C&order_count=3
hope this help you further
Yes, Anaconda is right. You just need try as mentioned above.
[color=#282828][font=arial, verdana, tahoma, sans-serif]Best regards,[/font][/color]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Leonid[/font][/color]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Chief Technology Officer of CSExperts [/font][/color]