Jump to content

Prevent downgrading configurable options if no free accounts


bernhard

Recommended Posts

Hi!

 

I'm quite new to WHMCS and I'm working on a provisioning module. The product I want to offer uses configurable options to represent the number of user accounts, a customer purchases. I have the following use-case:

 

1. My provisioning modules works with a server and a password, which i set using Server Details fields in "Products/Services"->"Server"

 

2. When a customer wants to downgrade the number of user accounts by setting the configurable option to from Y to X I want to check on my server, if there are (Y-X) not-used accounts it can delete. There is an API Call on the server, which i can use for this, if i have the information from (1.)

 

3. If there are free accounts, the workflow for up/downgrading configurable-options (upgrade.php) can proceed.

 

4. If there are no free accounts, the workflow shall be stopped and a warning is displayed to the customer.

 

To achieve this, I experimented with the ClientAreaPageUpgrade hook.

 

add_hook('ClientAreaPageUpgrade',1,function($vars)
{       
       $additional = array();
       $additional['confopterror'] = 'confopterrornotallowed';
       return $additional;
}

 

I then replaced my upgradesummary.tpl, so it proceeds only if the variable is set.

 

{if $confopterror}
   {include file="$template/includes/alert.tpl" type="error" msg=$LANG.upgradeExchangeAccountErrorTitle textcenter=true}
{$LANG.upgradeExchangeAccountError}
{else}
   {include file="$template/upgradesummaryorder.tpl" }
{/if}

 

All this works quite well. However I lack information in the ClientAreaPageUpgrade hook for my use-case:

 

  • the product id is not available, which i need to process the hook only for a certain product
  • the customer's user information is not available, i need at least his username on my server
  • the server information is not present. neither the servername nor the password for the selected server is available.

 

Can anyone give me a suggestion how to handle with this?

 

Best regards

Bernhard

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated