API -> change package - but - preserve options

smilie

Verified User
Joined
Jul 2, 2010
Messages
5
Hi,

I need to achieve following (not sure it is possible with 1 call tho').

Oke, scenario:
Package 1 = 100 MB disc space, 200 MB traffic, domains = 1;
Package 2 = 200 MB disc space, 400 MB traffic, domains = 1.

User has package 1; at some point, he get's extra domain, so package 1 is modified through API to make domains = domains + 1 (2 in total at that moment).

Now, client wants to switch from package 1 to package 2.
If I do this through API, client does get package 2 (with 200 MB disc space and 400 MB traffic) - but his domains het also reset to 1 - which is not intended :-)

Is there a way (system wide setting or so?) to disable this 'behavior' and to preserve options?

If not - does anyone have a script that would do this (change package but preserve options)?

Thanx!
Aleks
 
Why would you expect it to do that? of course it is going to switch domains to whatever the package is set to. Im sure there is some api command where you can check values so you know what to change it to.
 
Yeah, I can 'walk' manualy through options and set them back - but I was hoping there was an API call that would do that for me automagically. I thought this was common used options among other DA users as well...

Well, as they say: If you wanna win, you may not loose - thus I am gonna make one function to do this :-)

Will post it here afterwards so other may use it as well.

Regards,
Aleks
 
Oke, I found it.
When you change package name, it will preserve only those options that are in use.

Example:
Package 1 has by default 0 domain pointers;
Package 2 has by default also 0 domain pointers.

Client has package 1; client adds extra control panel, so domain pointers goes +1;

Client wants to upgrade to package 2. Once upgrade (through API) is done, extra control panel remains working although domain pointers is gone back to 0 (default).

So - only problem (which we do not come against) is following scenario:
Client has package 1 with 0 pointers;
Client 'buys' 3 domain pointers, but is really using only 1 pointer;
Client upgrades to package 2 -> hereby his 1 used domain pointer remains working, but he can never use other 2 (already bought) pointers as default is gone back to 0.

Hope this helps someone.

Regards
Aleks
 
Hello,

Just for clarification, if you make any customizations to a User, he's no longer using a package. His package setting in his user.conf becomes "package=custom".

If you decide you want to change the details of package1, since that User is not using package1, he won't get those changed details.

As for your case, the User became "custom" when the domain pointers were changed. Setting him to package2.. gives him everything that package2 has to offer, thus it gets set back to whatever package2 has.

If you're doing this with the API.. the way to keep the domain pointers would be to:
1) grab the current User settings
2) grab the package1 settings
3) do the math to see what was customized.. save the difference in a temp variable.
4) apply the new package
5) apply the difference that was in the temp variable to increase the domain pointer to it's previous custom value.

The User would become "custom" again though.. so the API wouldn't really know that he was using package1 in the first place.. unless you have that saved in your billing system somewhere.

John
 
Back
Top