Jump to content

How can I add domain id protection price to the order pages


stormy

Recommended Posts

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 by stormy
Link to comment
Share on other sites

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}&nbsp;&raquo; {$LANG.domainidprotection}<br />{/if}

to...

{if $domain.idprotection}&nbsp;&raquo; {$LANG.domainidprotection} {$currency.prefix}{($domain.totaltoday->toNumeric() - $domain.pricing.{$domain.regperiod}.{$domain.type}->toNumeric())|string_format:"%.2f"}{$currency.suffix}<br />{/if}

😲

dbmG6nN.png

you'll have to trust me when I tell you that IDP is £5 GBP in the dev and so the calculation is correct. ✔️

Link to comment
Share on other sites

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 🙂

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. aaah.gif

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. 🙂

Rp4GrVi.png

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 by brian!
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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