Jump to content

Update renewal price after paid invoice


PaulGress

Recommended Posts

Hi all,

i'm newbie with whmcs and i need help to solve a problem. I'm working with whmcs v. 7.x and actually ( not even in 8.x ) there's a way to change hosting price after 1 year, without creating and using a  promotional coupon code .

So i need that one of my product hosting with pid=70 that it's price 20.00$ could be changed automatically to 30.00$ in Recurring Amount   after 1 year. For only client he's buying it.
So after client have bought it and paid invoice, hook could work and update Recurring Amount value in hosting product for client...There's a way to perform it with a hook ?

I'm seeing documentation about whmcs hooks and i found the " OrderPaid " . Something below could be works?

<?php
add_hook('OrderProductPricingOverride', 1, function($vars) {
    $return = [];

 if ($vars['pid'] == 70 {
        $return = ['recurring' => '30.00',];
    }

return $return;
});

Thanks for any help.

Link to comment
Share on other sites

and remember that you're just passing a value, and not a currency - e.g if you pass 100 in the hook and the client uses USD, then that's $100; if they use EUR, then its €100 etc.

so in a multi-currency situation, you should find the clients currency before determining what value to pass in the hook - if your site only uses one currency, then this won't matter.

Link to comment
Share on other sites

On 11/24/2020 at 11:46 PM, steven99 said:

You would want to use the OrderPaid hook instead and then set the recurring amount to whatever it should renew at.   The change can be done via the UpdateClientProduct API call or via internal classes. 

Sure thanks Steven, but from documentation hook OrderPaid it hasn't variable $pid , could you guide me to a correct solution so?

 

<?php
add_hook('OrderPaid', 1, function($vars) {
    $return = [];

 if ($vars['pid'] == 70 {
        $return = ['recurring' => '30.00',];
    }

return $return;
});

i think that it doesn't work 😕
 

On 11/25/2020 at 5:00 PM, brian! said:

and remember that you're just passing a value, and not a currency - e.g if you pass 100 in the hook and the client uses USD, then that's $100; if they use EUR, then its €100 etc.

Hi Brian, thank you, yes i thought it, but i'm using only one currency.

Thanks

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...
On 11/28/2020 at 5:06 PM, PaulGress said:

Sure thanks Steven, but from documentation hook OrderPaid it hasn't variable $pid , could you guide me to a correct solution so?

Not sure if you still need an answer.  Steven had give you a clear direction.  Check the https://developers.whmcs.com/api-reference/updateclientproduct/ for the example on how to make a localAPI call.

Then place this localAPI call in the OrderPaid hook will do.

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.

×
×
  • 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