stormy Posted September 23, 2019 Share Posted September 23, 2019 (edited) I'm looking for a way to disclose the domain id protection price in the price summaries: the one in viewcart.tpl and the one in ordersummary.tpl. I haven't found a way to pull the prices of domain addons on those pages, and I'd rather not hardcode the text. Any ideas how to pull this off? Edited September 23, 2019 by stormy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 23, 2019 Share Posted September 23, 2019 35 minutes ago, stormy said: I'm looking for a way to disclose the domain id protection price in the price summaries: the one in viewcart.tpl and the one in ordersummary.tpl. would IDP be shown in the order summary window anyway ?? if you were ordering a product, then you would configure the product (showing order summary) before you go to the domain configuration and enable IDP (there's no summary with the domain config page). 38 minutes ago, stormy said: I haven't found a way to pull the prices of domain addons on those pages, and I'd rather not hardcode the text. Any ideas how to pull this off? in viewcart, by far the safest way would be a ClientAreaPageCart hook that pulled the IDP price from the database in the current currency - then it's just a tweak to the template to output it. in a limited way, you could do it purely in Smarty - but if you charge for other domain addons (e.g DNS Management etc), then you are screwed (technical Smarty term!) - you can get what the register/transfer price would be; you can get what the today price is; then you could take one from the other and the result should give you the IDP price... but as I say, if there are multiple domain addons in play, then that makes the calculation difficult... not impossible, but probably not worth the effort. in viewcart.tpl, you could change... {if $domain.idprotection} » {$LANG.domainidprotection}<br />{/if} to... {if $domain.idprotection} » {$LANG.domainidprotection} {$currency.prefix}{($domain.totaltoday->toNumeric() - $domain.pricing.{$domain.regperiod}.{$domain.type}->toNumeric())|string_format:"%.2f"}{$currency.suffix}<br />{/if} 😲 you'll have to trust me when I tell you that IDP is £5 GBP in the dev and so the calculation is correct. ✔️ 1 Quote Link to comment Share on other sites More sharing options...
stormy Posted September 23, 2019 Author Share Posted September 23, 2019 Hi Brian, Thanks! Some extra info I forgot: I found the problem when looking at domain renewals. Since we don't send automated invoices for domain renewals, customers have to enter a domain renewal order. And there are two different ways to do that! That's why I want the fix on two different places. Now I'll go implement your solution and report back 🙂 0 Quote Link to comment Share on other sites More sharing options...
stormy Posted September 23, 2019 Author Share Posted September 23, 2019 Unfortunately I'm getting a big "Oops! Something went wrong and we couldn't process your request." I'm on WHMCS 7.6.2 - maybe that's why? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 23, 2019 Share Posted September 23, 2019 8 minutes ago, stormy said: I'm on WHMCS 7.6.2 - maybe that's why? I don't think it's that - i've just tried that code on a v7.6.1 dev, using both PHP 5.6 & 7.2, and it works fine. 10 minutes ago, stormy said: Unfortunately I'm getting a big "Oops! Something went wrong and we couldn't process your request." can you check your activity log to see if there is an error shown there, or enable display errors in setup -> other - one of them should give you more details as to the specific cause, .eg what part it didn't like about that code. 0 Quote Link to comment Share on other sites More sharing options...
stormy Posted September 23, 2019 Author Share Posted September 23, 2019 The error is "Error: Call to a member function toNumeric()" 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 23, 2019 Share Posted September 23, 2019 (edited) 2 hours ago, stormy said: Thanks! Some extra info I forgot: I found the problem when looking at domain renewals. aahh - that's the absolutely critical bit of info I was missing... i've been working with the wrong array and assuming you were just thinking of adding domains to the cart. those arrays I was calling exist when it's a domain reg/transfer in the cart, but not when it's a renewal... to make things simpler (though not if you look at the code!), let's do it as a hook and cover both reg and renewals.. i've written the attached hook in such a way that no template changes to viewcart.tpl should be required - so the previous changes can be removed from the template. 🙂 with regards to the order summary box, that's a little trickier as you can't use a hook; you can't really query the db in Smarty (unless you resort to using {php})... it may have to be hardcoded with if statements for multiple currencies... though as you can see from the above screenshot, it will show the IDP price by the time they get to viewcart. tested on 7.6.1 as working - so should work on v7.6.2 ! 🙏 domain_cart_idp.php Edited September 23, 2019 by brian! 1 Quote Link to comment Share on other sites More sharing options...
stormy Posted September 24, 2019 Author Share Posted September 24, 2019 Fantastic!!! Works perfectly, and it's an elegant solution. Thank you very much! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 24, 2019 Share Posted September 24, 2019 2 minutes ago, stormy said: Fantastic!!! Works perfectly, and it's an elegant solution. Thank you very much! oh for a moment then, I thought you were going to say it didn't work lol. 😲 1 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.