Hosting & Domaining Forum

Hosting Discussion => Hosting Software and Control Panels => Hosting Software & CPs Related Offers & Requests => Topic started by: vingler on Mar 18, 2023, 03:06 AM

Title: WHMCS
Post by: vingler on Mar 18, 2023, 03:06 AM
Is there a way to set up the WHMCS hook so that it creates services based on the selected server locations? For example, I have different server locations like USA, UK, etc., and I have customized settings for each of them. The payment has been successfully made.

Currently, WHMCS only creates a service on the default server. However, I would like the service to be configured in such a way that if the customer chooses a custom US option, it will be built on servers in the USA. Similarly, if the customer selects the UK option, the service should be created in the UK.

It's worth mentioning that I have already created server groups in WHMCS based on server locations.

I am aware that there are paid WHMCS modules available, but I prefer to install my own hooks.

I would greatly appreciate any assistance and support you can provide.
Title: Re: WHMCS hook
Post by: nationwide on Mar 18, 2023, 03:58 AM
I believe that there is a discussion on the WHMCS forums regarding this particular topic. In essence, by utilizing the "orderaccepted" hook, you can retrieve custom field values associated with a specific group of servers. Then, you can set the server used by the service to be one of these servers within the group.

By doing so, you can bypass WHMCS' default server selection process and eliminate the need for subsequent rebalancing.

Additionally, it may be beneficial to explore the experiences and insights shared by other WHMCS users on the forums, as they may provide further guidance on implementing this solution effectively.
Title: Re: WHMCS
Post by: purnima on Jul 20, 2023, 09:56 AM
Yes, it is possible to set up a WHMCS hook to create services based on selected server locations. The WHMCS API provides hooks that allow you to customize various aspects of the system's behavior.

To achieve this, you can utilize the "AfterShoppingCartCheckout" hook, which is triggered after a successful payment. In your custom hook, you can access the selected server location from the shopping cart and use it to determine the appropriate server to assign for the service.

Here are the general steps you can follow in your hook:

1. Retrieve the selected server location from the shopping cart using the WHMCS API.
2. Determine the corresponding server group that matches the selected server location.
3. Retrieve a list of servers belonging to that server group using the WHMCS API.
4. Choose a server from the list based on your criteria (e.g., load balancing, availability).
5. In your hook, use the WHMCS API to create the service using the chosen server.

By implementing these steps in your custom hook, you can ensure that the selected server location is taken into account when creating services in WHMCS.

Keep in mind that the specific implementation details may vary depending on your WHMCS version and the structure of your customizations. It's recommended to consult the WHMCS dоcumentation and API reference for more detailed information on how to integrate custom hooks.
Title: Re: WHMCS
Post by: _XyJIuGaN_ on Feb 19, 2025, 10:52 AM
You can do this by creating a PHP file in the hooks directory of your WHMCS installation and naming it createService.php. In this file, you'll need to use the getServerGroupID function to retrieve the ID of the server group corresponding to the selected location, and then use the createService function to create the new service on the desired server.
This will require some custom coding, but it's definitely possible with some PHP expertise.