azzepis Posted May 5, 2021 Share Posted May 5, 2021 Hi. I'm trying to change price on product upgrade. So here is my little hook: add_hook('OrderProductUpgradeOverride', 1, function($vars) { $return = []; if ($vars['oldproductid'] == 111) { $results = localAPI('GetProducts', array('pid' => $vars['newproductid']), ''); if ($results['result'] == 'success') { $price = $results['products']['product'][0]['pricing']['UAH'][$vars['newproductbillingcycle']]; $return['price'] = $price; } } return $return; }); If client is trying to change product with ID = 111 - I'm searching for the full price for selected new period of new product and returning it instead of recalculated price which depends on days and etc. Client has UAH (грн in local language) currency in profile , but in this case he is getting prices in USD (Screenshot_1) If I'm not calling LocalAPI and overriding, for example, like this: add_hook('OrderProductUpgradeOverride', 1, function($vars) { $return = []; if ($vars['oldproductid'] == 111) { $price = 1; $return['price'] = $price; } return $return; }); Currency displayed correctly (Screenshot_2) Can someone help with this? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 5, 2021 Share Posted May 5, 2021 it's probably worth mentioning that during product upgrades, the next due date does not change. so let's say I upgrade the Package One service today, but the next due date is 1st June... WHMCS calculates the upgrade price based on the formula in the docs to upgrade the service to Package Two up until 1st June - you are NOT upgrading the service for another full YEAR/MONTH or whatever the new billingcycle is.... on the 1st June (or whenever automation settings permit it), a renewal invoice would be generated for the upgraded service (Package 2) for the full amount. so knowing that now, do you still need the hook to work in the above way? personally, I would first get the client's currency ID value (unless you're saying that all your clients are using UAH ?) and then query the database direct for the relevant price value (capsule query to tblpricing or using the model method). 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted May 6, 2021 Author Share Posted May 6, 2021 Thank you for your answer. But the main question is - why currency changed on client side? I have used API call to “read only” function GetProducts to get some float value. I didn’t call any function which updates something or changes something. 0 Quote Link to comment Share on other sites More sharing options...
ShiyaWare Posted May 6, 2021 Share Posted May 6, 2021 This one solve my issue, thanks. 0 Quote Link to comment Share on other sites More sharing options...
azzepis Posted May 11, 2021 Author Share Posted May 11, 2021 On 5/6/2021 at 11:43 AM, ShiyaWare said: This one solve my issue, thanks. Not sure I understood your issue. Can you provide more information? I didn’t find any answer or solution for issue from this topic 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.