- Posts: 196
- Thank you received: 15
Changing the user group after the 3rd purchase
- StudioPrzyLesie
-
Topic Author
- Offline
Less
More
2 years 11 months ago #357378
by StudioPrzyLesie
Changing the user group after the 3rd purchase was created by StudioPrzyLesie
Hi,
Is it possible to configure it so that after placing the third order, the customer will be automatically transferred to another Joomla user group? So as to assign it to a group with a specific discount.
Tom
Is it possible to configure it so that after placing the third order, the customer will be automatically transferred to another Joomla user group? So as to assign it to a group with a specific discount.
Tom
Please Log in or Create an account to join the conversation.
2 years 11 months ago #357382
by nicolas
Replied by nicolas on topic Changing the user group after the 3rd purchase
Hi,
There is no option to do it.
However, you should be able to do it with a bit of coding and a mass action.
For example, you can create a mass action "order" with a trigger "after an order is updated" and with an action "run PHP code" with such code:
where XXX is the id of the user group you want to add to the user account.
There is no option to do it.
However, you should be able to do it with a bit of coding and a mass action.
For example, you can create a mass action "order" with a trigger "after an order is updated" and with an action "run PHP code" with such code:
Code:
$db = JFactory::getDBO();
$db->setQuery('SELECT count(order_id) FROM #__hikashop_order WHERE order_user_id={order_user_id} AND order_status IN ("confirmed", "shipped")');
$number_of_orders = $db->loadResult();
if($number_of_orders >= 3) {
$userClass = hikashop_get('class.user');
$hkUser = $userClass->get({order_user_id});
if(!empty($hkUser->user_cms_id)) {
$user = clone(JFactory::getUser($hkUser->user_cms_id));
jimport('joomla.access.access');
$userGroups = JAccess::getGroupsByUser($hkUser->user_cms_id, true);
$userGroups[] = XXX;
$user->set('groups',$userGroups);
$user->save();
}
}
Please Log in or Create an account to join the conversation.
- StudioPrzyLesie
-
Topic Author
- Offline
Less
More
- Posts: 196
- Thank you received: 15
2 years 11 months ago #357399
by StudioPrzyLesie
Replied by StudioPrzyLesie on topic Changing the user group after the 3rd purchase
Thank you, I will test 
Tom
Tom
Please Log in or Create an account to join the conversation.
Time to create page: 0.043 seconds