Walther Posted October 20, 2020 Share Posted October 20, 2020 Hello. The API GetTLDPricing ( https://developers.whmcs.com/api-reference/gettldpricing/ ) gives as response an array with all available prices for every available extension domain; and this array may be available in Smarty, getting in Smarty something like: $tldpricing2 Origin: "Smarty object" Value Array (3) result => "success" currency => Array (6) id => "1" code => "USD" prefix => "$" suffix => " USD" format => "1" rate => "1.00000" pricing => Array (13) com => Array (8) categories => Array (2) 0 => "gTLD" 1 => "Popular" addons => Array (3) dns => false email => false idprotect => false group => "" register => Array (1) 1 => "14.95" transfer => Array (1) 1 => "14.95" renew => Array (1) 1 => "14.95" grace_period => Array (2) days => 30 price => WHMCS\View\Formatter\Price Object (0) redemption_period => null net => Array (8) categories => Array (2) 0 => "gTLD" 1 => "Popular" addons => Array (3) dns => false email => false idprotect => false group => "" register => Array (1) 1 => "14.95" transfer => Array (1) 1 => "14.95" renew => Array (1) 1 => "14.95" grace_period => Array (2) days => 30 price => WHMCS\View\Formatter\Price Object (0) redemption_period => null I have two different issues about this... 1 - what's the right syntax to recover, i.e., the registration price for a certain domain? I tried almost every possible syntax (but obviously missed the right one...) I defined the the extension using {$tld2=$tld|ltrim:'.'} and it works, so i.e. $tld2 gives "net" ... But if I try $tldpricing2[pricing][$tld2] [register][1] , or using -> , or any other possible PHP/smarty syntax, I'm getting garbage instead of the desired value... 😕 So, what's the right Smarty syntax to recover that value? 2 - about grace period renewal...WTF is " WHMCS\View\Formatter\Price Object (0) " ?! Why is it now given as any other price for registration, transfer or renew? And how can I convert it into a number (hopely, the right one) ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 22, 2020 Share Posted October 22, 2020 On 20/10/2020 at 15:37, Walther said: So, what's the right Smarty syntax to recover that value? in Smarty, it would be... {$tldpricing2.pricing.$tld2.register[1]} to return a 1 year registration price, in the current currency. On 20/10/2020 at 15:37, Walther said: 2 - about grace period renewal...WTF is " WHMCS\View\Formatter\Price Object (0) " ?! https://classdocs.whmcs.com/8.0/WHMCS/View/Formatter/Price.html On 20/10/2020 at 15:37, Walther said: Why is it now given as any other price for registration, transfer or renew? probably because they can be more flexible to manipulate than if they were strings. On 20/10/2020 at 15:37, Walther said: And how can I convert it into a number (hopely, the right one) ? in Smarty, it would be... {$tldpricing2.pricing.$tld2.register[1]->toNumeric()} 3 Quote Link to comment Share on other sites More sharing options...
Walther Posted October 24, 2020 Author Share Posted October 24, 2020 On 10/22/2020 at 6:00 PM, brian! said: probably because they can be more flexible to manipulate than if they were strings. What is crazy and misleading is that in the very same array you can find values as normal string (register, renew, transfer), and just redemption fee is in form of "Price Object"... Apart from this, thank you for your precious support! 0 Quote Link to comment Share on other sites More sharing options...
Remitur Posted October 24, 2020 Share Posted October 24, 2020 On 10/22/2020 at 6:00 PM, brian! said: in Smarty, it would be... {$tldpricing2.pricing.$tld2.register[1]->toNumeric()} Precisely, it's {$tldpricing2.pricing.$tld2.grace_period.price->toNumeric()} (grace period price and redemption price are the only values got as Price Object; other prices, as registration, renew and trasfer, are provided as string) This thread gave me an idea... news will follow shortly 😉 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2020 Share Posted October 26, 2020 On 24/10/2020 at 10:42, Walther said: What is crazy and misleading is that in the very same array you can find values as normal string (register, renew, transfer), and just redemption fee is in form of "Price Object"... that's mainly a legacy issue where in ye olde days, Price Objects weren't used and everything was either a string or an integer... new pricing values now tend to use the new format, so you end up with mixed arrays containing the results of various methods. 2 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.