Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by Kian

  1. Kian

    Cannot put decimal prices

    Hi, Setup > Payments > Currencies. Edit your currency and focus on Format dropdown. Make sure the last item (1,234 - no decimals) is not selected.
  2. Iterate over your array and perform AddClient.
  3. Kian

    Rewrite pricing system

    Where you need that? Cart? Invoice PDF? Back-end? Front-end?
  4. I'm opening this thread to ask for some help but I have no hope. The problem I'm trying to solve is so frustrating that even describing it is a frustrating experience. It's about Upgrades/Downgrades. Preamble For various reasons (tax regulations in force in several countries) I have to consider Add Funds invoices with tax. Normally when you want to add 100 € funds WHMCS issues a 100 € invoice. Customers pay their taxes when the credit is used to pay other invoices. As I said earlier, this is wrong in several countries (please don't ask me to explain 😩) where you have to charge tax every single time you receive a payment. There are no exceptions to this rule. Now let me take Italy as example where VAT is 22%. When you add 100 € funds, the invoice must be corrected to 100 € + 22 € VAT = 122 € (or 81.97 € + 18.03 € VAT = 100 €). The customer has to pay 122 € (or 100 €) and receives 100 € (or 88.97 €). This way we're fine with taxes but when you solve a puzzle a new one spawns. Every time customers use their VAT-free credit to pay invoices, we have to make sure that they don't pay taxes for credit otherwise they're going to pay taxes twice (when they Add Funds and Apply Credit). That means that we have to return/refund VAT. Let me show you an example. This is what WHMCS normally does: Subtotal: 100 € 22% VAT: 22 € Credit: 122 € Total Due: 0 € This is what we're supposed to do: Subtotal: 100 € 22% VAT: 0 € Credit: 100 € Total Due: 0 € Bonus: this invoice must be suppressed since it makes no sense (no payments involved) Things get complicated when you have to deal with partial credit: Subtotal: 100 € 22% VAT: 22 € Credit: 50 € Total Due: 72 € The Total Due and VAT are both wrong. In fact we have to recalculate tax on Subtotal minus Credit: Subtotal: 100 € 22% VAT: 11 € Credit: 50 € Total: 61 € All this mess have to be applied every time an invoice is issued, updated, has a new transaction or credit applied. As you can imagine coding this thing hurts but we managed to solve it with 185 updates 😨 The problem Now that you know the mechanics involved with credit balance, there's an hardcore problem that I can't solve. We have already wasted 2 weeks. As you probably know, when you Upgrade/Downgrade a product WHMCS does two things: Refunds unused resources for the current cycle Charges for the remainder of the cycle at the new price Let me make an example. I want to remove Backup from my hosting package (-50 €) and add Antispam (+50 €). They're both Configurable Options. WHMCS issues the following invoice: Subtotal: 50 € 22% VAT: 11 € Credit: 50 € Total Due: 11 € Too bad that Total Due and Tax are wrong. This is how it should be: Subtotal: 0 € 22% VAT: 0 € Credit: 50 € Total Due: 0 € Bonus: invoice suppressed Here's another example. This time let's suppose that it's -10 € and +50 €: Subtotal: 50 € 22% VAT: 11 € Credit: 10 € Total Due: 51 € While it should be: Subtotal: 40 € 22% VAT: 8.8 € Credit: 10 € Total Due: 38.8 € The problem is that there are no action hooks that allows to correct numbers. We have: OrderProductUpgradeOverride which is cool but works only for Product Upgrades. There's no equivalent for Configurable Options Upgrades InvoicePaid, UpdateInvoiceTotal, InvoiceCreated. None of them can be used since when they trigger tblorders.invoiceid is still "0" even if the invoice already exists hence I cannot select "refunds" details stored in tblupgrades Another place where I could retreive refunds is tblcredit but WHMCS doesn't store any relid or useful description when it runs Upgrade/Downgrade We're on a dead line with literally no possible solution apart from crazy ones that would require me to remove standard WHMCS Upgrade/Downgrade functionality (cool story) and reinvent it. Probably a new hook point could solve my problem but it scares me. I have no idea why I keep putting myself in such awkward situations, fixing things that very few people even understand / care about. I should start designing templates. They're easy, everyone loves you, you get good reviews and you sleep peacefully 😅
  5. Kian

    I propose a tax-free world

    From my experience 99.99% of times PA refuses to pay and rejects the electronic invoice. Split Payment exists for a reason. Here is a very extreme example: Italy: «I need to rent a datacenter for one of my universities» You: «Sure, pay me 1.220.000 euro (1.000.000 + 220.000 VAT)» Italy: «Done» You: «Ops 🙁 my company is in bankruptcy. I'm out of business. I'm so unlucky!» Italy: «I'm going to kill you!» You: «You can't kill me, I'm an LTD! 😎» Italy: «Damn it» Public treasury: «Emh... what about my 220.000 euro? 😡» You: «Bankruptcy» Public treasury: «How dare you...» You: «Bankruptcy» Public treasury: «I know where you live...» Public treasury: «BANKRUPTCY EVERYWHERE» Italy: «Hey, Public treasury could you borrow me 1.220.000 euro?» Public treasury: «Okay 😑» Italy: «I need to rent a datacenter for one of my universities» You: «Do you remember me? Let's do this again!» Split Payment exists to avoid that Public Administrations pay VAT to a "man in the middle". You won't get any chance to refund VAT. Yes, but it works because I fixed the whole thing (totals before the invoice is issued, the invoice itself and credit usage). You can't get it working just by creating the correct invoice on an external software. There's a lot to do both BEFORE and AFTER invoice issuing.
  6. Kian

    I propose a tax-free world

    I wish it was like this but its not. Let's say that you receive a payment for a VPS that costs 100 euro + 22% VAT from the following customer: Italian Public Administration Split Payment WHMCS doesn't know anything about cross out sentences. As result you forced your customer to pay 22 euro for VAT that was not due to Split Payment. Here are the consequences: You charged 122 euro instead of 100 You issued an electronic invoice of 100 + 22% with Split Payment Your customer (Public Administration) paid 22% to Revenue Agency and 22% to your company At the end of the day the customer paid 144 euro instead of 122 and you stole 22 euro not from me or from my grandma but from State. What's the point of issuing the invoice correctly on a third-party platform when this mess happened? You'll need to refund 22 euro issuing a credit note followed by an electronic credit note that I can hardly imagine. But I can imagine a lot of unhappy Public Administrations, state-owned companies and corporations. Here is another example. In WHMCS Add Funds invoices are something special. They're VAT-free for no damn reason. In most EU countries (but I'd say that it's the same everywhere!) you are not allowed to issue an invoice without VAT unless there's a valid reason (eg. VIES, extra-EU, Split Payment, credit usage, special tax regime...). The fact that you're adding funds doesn't make it special so here's the thing. A customer uploads 100 euro of credit and on my third-party platform I issue the correct invoice: Subtotal 81.97 euro Tax (22%) 18.03 euro Total 100 euro In the meantime on WHMCS the customer didn't pay VAT. Here are the consequences: In 2020 WHMCS creates 18.03 euro of money out of nowhere Toc toc... hello Mr. White I'm the Revenue Agency. We need to talk Bonus distaster 1 🍬 In 2022 VAT raises from 22% to 23% Payment received in 2020 I used 50% of 18.03 euro in 2021 with 22% VAT I spend the rest in in 2022 wih 23% VAT Bonus disaster 2 🍬 In Italy you're not allowed to postpone invoicing later than 12 days (if you have electronic invoicing) or 1 month for other countries (generally). Here we have 3 years of delay. If you are italian it means that you're going to pay a fine of 28 euro for each invoice if you report yourself to Revenue Agency or 250 euro if you don't say anything... for an invoice of 81.97 euro. Cool. Go figure out how to fix this mess. I stop here but I cloud go on for days. Sadly not 🙁 as you can see from my first example we've two problems here: issue invoice correctly and charge the right amounts to end-customers. Having perfect invoices on an external system doesn't fix the problem with wrong amounts charged to customers. I remember India and Tunisia but I bet that there are more countries. I can't determine who is using it. Frankly I don't even know if it's true that they really need to use revenue stamps but customers asked to "unlock" this feature and I don't ask question. Italy and EU are enough for me. I don't need to find new problems.
  7. Kian

    I propose a tax-free world

    It's used also in other countries 😪 That's why last year I had to make it activable by companies from any country. End-clients would kill you. People open PayPal dispute and threaten you for much less. It makes sense but it would require 2000 action hooks 🤣 I'm shy 😁
  8. An action hook would be boring as hell. In AdminAreaHeaderOutput with jQuery first you need to retreive an array that contains the ID of all invoices listed in the table. Once you have the array run a query to select invoices that have your "placeholder" in tblinvoices.notes like follows: SELECT id FROM tblinvoices WHERE id IN ($yourArray) AND notes LIKE '%yourPlaceholder% Now that you know what are the invoices "On hold", run another jQuery to iterate such records and place the "On hold" label using ID in selectors.
  9. Happy accountant? They have no feelings and exist to ruin our lifes. For an accountant that doesn't like Cancelled invoices there's one that doesn't like Paid ones. 1000 customers, 1000 accountants, 90000 different points of view. Anyway back on topic Cancelled invoices are fine and even necessary in case you can't issue credit notes.
  10. The error is referring to a Client Custom Field that is named exactly Country and set as required (Setup > Custom Client Field). It's not the country field of WHMCS. That said, you have 3 options: Specify Country custom field in your API call Make it optional Delete it
  11. Kian


    It's an action hook, you can't use it in tpl files. Create a php file in includes/hooks and name it as you prefer (eg. overrideIntoDNS.php) then copy the script in the file and save.
  12. Kian

    i am want to change intodns.com to other

    Today someone else asked the same question. I provided the answer here. The script is the following: <?php add_hook('AdminAreaHeaderOutput', 1, function($vars) { if ($vars['filename'] == 'clientsservices') { $output .= <<<HTML <script type="text/javascript"> $(document).ready(function(){ var url = $('input[name="domain"]').val(); $('input[name="domain"] + div').children('ul').eq(0).append('<li><a href="https://example.com/hello.php?domain='+ url +'" target="_blank"><img src="https://katamaze.com/templates/kata/img/stuff/nyan-cat.png" style="height: 27px;width: 180px;"></a></li>'); }); </script> HTML; return $output; } }); Here's the output:
  13. Kian

    I propose a tax-free world

    What's the point of syncing WHMCS invoices with external accounting softwares when the real problem is that WHMCS issues invoices that are wrong? I mean wrong amounts, tax calculation, rounding, refund and gigantic lacks of billing concepts. I'll give you 6 examples taken from my book of examples: WHMCS issues an invoice where VAT is required but missing since it doesn't understand that AddFunds invoices must be taxed. Instead of 122 euro (100 + 22 VAT) the client paid 100 and I have an invoice that makes no sense. Who's gonna pay 22 euro? Ghostbusters! 👻 WHMCS issues an invoice with VAT but it was not necessary since it doesn't understand the concept of Split Payment. If you happen to have Public Administrations as clients it's game over for you State-owned companies... ouch Credit notes... ouch Refunds that make sense Tax stamp
  14. Send Mass Mail Note down every email that gives "Sending Failed" in a PHP array In AfterCronJob iterate over the array to move the "Sending Failed" customers in a Client Group named "dead people" Make sure that "dead people" Client Group is NOT selected when you send new Mass Mail Repeat the process 2 times then stop because I'm too lazy to continue and find a better solution Keep playing with invoices 😪
  15. Kian


    If I understoon you correctly... <?php add_hook('AdminAreaHeaderOutput', 1, function($vars) { if ($vars['filename'] == 'clientsservices') { $output .= <<<HTML <script type="text/javascript"> $(document).ready(function(){ var url = $('input[name="domain"]').val(); $('input[name="domain"] + div').children('ul').eq(0).append('<li><a href="https://example.com/hello.php?domain='+ url +'" target="_blank"><img src="https://katamaze.com/templates/kata/img/stuff/nyan-cat.png" style="height: 27px;width: 180px;"></a></li>'); }); </script> HTML; return $output; } }); The rainbow cat will open example.com/hello.php?domain={THE_DOMAIN_WRITTEN_IN_THE_INPUT}. p.s. If you are a real man, leave the rainbow cat in production! 😎
  16. Kian


    <?php add_hook('AdminAreaHeaderOutput', 1, function($vars) { if ($vars['filename'] == 'clientsservices') { $output .= <<<HTML <script type="text/javascript"> $(document).ready(function(){ $('input[name="domain"] + div').children('ul').eq(0).append('<li><a href="https://www.youtube.com/watch?v=QH2-TGUlwu4" target="_blank"><img src="https://katamaze.com/templates/kata/img/stuff/nyan-cat.png" style="height: 27px;width: 180px;"></a></li>'); }); </script> HTML; return $output; } }); Here is the output.
  17. IMO the best approach is use transliteration. This way customers can freely register using any alphabet and transliteration will convert them to latin charachers like follows: 川島 永嗣 becomes Eiji Kawashima Mandžukić becomes Mandzukic 颜骏凌 becomes Yan Junling You should transliterate on ClientAdd, ClientEdit, ContactAdd and ContactEdit.
  18. Kian


    Same old way, jQuery. <?php add_hook('AdminAreaHeaderOutput', 1, function($vars) { $output .= <<<HTML <script type="text/javascript"> $(document).ready(function(){ $("#intellisearchval").closest('div').append('<img src="https://katamaze.com/templates/kata/img/stuff/nyan-cat.png" style="height: 27px;width: 180px;">'); }); </script> HTML; return $output; }); Here's the output: AdminAreaHeaderOutput provides variables you need to inject your code in specific pages. As for jQuery, just play with selectors.
  19. Kian

    Dropdown select multiple

    Yeah, it's impractical 😔 anyway I was thinking about a more complex scenario. For example think about Country/Region dropdown combo. Select Italy and get Italian regions, select Germany and get German ones, select Morocco and instead of a dropdown with regions you have a text field. Not to mention you can end up with things like Germany + Italian region stored in database 😭
  20. Kian

    Dropdown select multiple

    Nope. IMO don't even start using _config() function. As you can see it is already limited and with time your addon could become so big and complex that you'll need to find alternatives. Moreover it doesn't support conditional options (e.g. Select A show B hide C). Create a dedicated table (e.g. blabla_config) where you can store anything you need freely. This way you can create a dedicated page/interface if to configure your addon with text, password, multiselect, toggle, file uploader (...) inputs.
  21. Or you can add tracking with action hooks (ClientAreaHeaderOutput, ClientAreaPage etc.)
  22. I'm completing the refactoring of a module that I initially released on 2015 that allows to pay commissions to Affiliates depending on their sales, performance levels and monthly achievements. It has nothing to do with the Affiliates system of WHMCS. The current version of the module is still functional but has a problem. It has too many types of commissions which makes the module very difficult to use. That's what you get when you give too much room to bad users' feedback 🤔 My bad. The refactored module is based on making it simple to use for administrators and affiliates therefore I refused to implement subterfuges like 3% + 5% commissions (you don't get 8%), misleading mechanics and bonus scheme that requires a supercomputer to be explained. I'll never implement such things again. That said, I'm looking for feedback (good ones 😀), ideas and suggestions. Am I missing something important? Backend Commissions [ Click to enlarge ] You can define commission payouts based on specific Products/Services, TLDs and Product Addons both percentage and fixed amount. It is also possible to define group-based commissions (eg. all VPS servers, all TLDs). You can use padlocks to lock certain items so that they don't get updated when you change parents. Achievements [ Click to enlarge ] You can set multiple achievements to encourage Affiliates to keep selling your products. On a monthly basis the module automatically rewards them for reaching the goals you set. Achievements are based on Revenue, New Signups and Number of Sales. These same achievements can be used also to reward Top Affiliates (eg. first 5 Affiliates that brings you 1000€ of Revenue, Affiliates reaching 1000€ earn a bonus of 100€ etc.). The system pays commissions based on the following Attribution Metrics (Manual, Cookie-based, Interactive). You can put limits to Affiliation program and Payouts. There are also many other pages in backend (Dashboard, View/Filter/Manage Affiliates, Sales, Payouts, Settings) but right now I'd like to focus on the above ones. Before you ask the module already handles multiple currencies and conversion rates. Clientarea Earnings [ Click to enlarge ] This is how your Affiliates can monitor their sales, revenues and request payouts from Clientarea. Achievements [ Click to enlarge ] Here they review not only unlocked Achievements but also next ones. At a glance they can get an idea of their progress by simply looking at progress bars. This way they can decide to focus on a particular goal. Subscriptions [ Click to enlarge ] This area is for recurring commissions that can be lifetime or last for a certain amount of months. Statistics [ Click to enlarge ] We're still working on this page since we need to decide what metrics to represent in graphs. Quite frankly I really don't know. Revenue, Commissions, Payouts, ROI... what else? I'm not a "marketing guy".
  23. Kian

    Product upgrade with upfront cost

    I'd say that it's correct since billing cycle is not updated in the process. The new product keeps the billing cycle of the old one. In your specific case it will result in a free upgrade (and renewal) since the new product doesn't have a monthly price. P.s. if you plan to use Configurable Options Upgrades keep in mind that there's a crazy bug (confirmed by WHMCS) I discovered last month so be careful.
  24. Kian

    Redirect loop after migration

    It could be caused by an action hook that forces a redirect when you log in. Make sure there's nothing similar in includes/hooks directory.
  25. Kian

    Send test email in Mass Mail Option

    You could send the email to yourself. Open the Summary of your customer account (I bet you have one) and use the Send Email section to compose an email. Copy/paste the source of your mass mail here and click Send. It's not an elegant solution but at least you can send a real email to yourself for testing purposes.

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated