Assigning User Group on order creation

  • Posts: 32
  • Thank you received: 5
11 months 1 week ago #357553

-- HikaShop version -- : 5.0.2
-- Joomla version -- : 4.4.1
-- PHP version -- : 8
-- Browser(s) name and version -- : Firefox 120.0.1 (64-bit)

Hi,

I want to assign a user group when a customer orders a certain product.

This is possible by setting "User group after purchase" for the product in question.

However, the user group is only assigned once the order is set to confirmed.

I am aware of the possible implications, but still want to assign user groups immediately after the order is created.

How would I go about doing this?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 months 1 week ago #357566

Hi,

You would have to edit the file plugins/hikashop/group/group.php and change the line:

if($order->order_status != $confirmed){
to:
if($order->order_status != 'created'){
That way, the group would be added when the order is created.

The following user(s) said Thank You: NTV

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 5
11 months 1 week ago #357572

Hi,

works fine, thanks a lot!

But this change will get overridden with the next update to group.php - correct?
If so, is there a way to make an override like with Views?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 months 1 week ago #357574

Hi,

That's correct.
You can make an override. Basically, you need to rename the plugin. Change its folder / files / class to new names based on the Joomla documentation on how to make plugins so that you basically have your own custom user group after purchase plugin.
This requires some development knowledge.

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 5
11 months 3 days ago #357682

Hi,

I think that could be in the realm of my capabilities. Would I need to rename or copy the original Hika Plugin?

If I rename it, would the original not be added again with the new update?

And if I copy it, how would I stop the original from running as well?

Last edit: 11 months 3 days ago by NTV.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 months 3 days ago #357690

Hi,

You would need to copy the plugin. The original plugin will be updated / added back automatically after each update, so if you don't want to use it, you want to disable it in the Joomla plugins manager.

The following user(s) said Thank You: NTV

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum