AladdinJ Posted January 4, 2023 Share Posted January 4, 2023 (edited) you shoud activate mailin payment module it's called " Mail In Payment " in whmcs make sure to activate it in products group also then this hook will allow only Mainin when cart is zero and will auto choose it and hide payment gateway section ( for Logam2) add_hook('ClientAreaPageCart', 1, function($vars) { if ($vars['rawtotal'] == 0.00) { $gateways = $vars['gateways']; $allowed = ['mailin']; foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$allowed)) { unset($gateways[$k]); } } add_hook('ClientAreaFooterOutput', 1, function($vars) { $v = "input[value='mailin']"; $return = ' <script> document.querySelector("'.$v.'").checked = true; const PGC = document.getElementById("paymentGatewaysDetails"); PGC.style.display = "none"; </script> '; return $return; }); return array("gateways" => $gateways); } }); try and tell me if it works with you Edited January 4, 2023 by AladdinJ fixed 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted January 4, 2023 Share Posted January 4, 2023 26 minutes ago, AladdinJ said: Thank you very much for the coffee, that's a lot, There was no need to do that, I really appreciate it ❤️ You're welcome, your help is very much appreciated! 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted January 4, 2023 Share Posted January 4, 2023 (edited) I have edited my last replay couple times , I was testing it , it shoud work now , try and tell me Edited January 4, 2023 by AladdinJ 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted January 4, 2023 Share Posted January 4, 2023 Yes! Works great! Is there any way to do the opposite when the cart is > $0? hide Mailin and only show Credit Card? 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted January 4, 2023 Share Posted January 4, 2023 6 minutes ago, FutureX said: Yes! Works great! Is there any way to do the opposite when the cart is > $0? hide Mailin and only show Credit Card? you are right , this hook will fix this // hide mailin when cart total above zero add_hook('ClientAreaPageCart', 1, function($vars) { if ($vars['rawtotal'] > 0.00) { $gateways = $vars['gateways']; $remove = ['mailin']; foreach ($gateways as $k => $item) { if (in_array($item['sysname'],$remove)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } }); 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted January 4, 2023 Share Posted January 4, 2023 Perfect! Works great! Thank you so much for your help! All of these features should be built into WHMCS already. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted January 4, 2023 Share Posted January 4, 2023 (edited) 6 hours ago, AladdinJ said: the best solution I got , you can activate payment module that called "mailin" then we make the hook when cart is Zero , showing only this payment methods and hide if from user interface Or read the payment methods with a hook, remove the one you want and return the array back to template. Edited January 4, 2023 by pRieStaKos 1 Quote Link to comment Share on other sites More sharing options...
Dkuzik Posted January 11, 2023 Share Posted January 11, 2023 Why don't you use a nulled payment gateway? Payment type says whatever u want like No Payment Required -1 Quote Link to comment Share on other sites More sharing options...
exlhost Posted February 3, 2023 Share Posted February 3, 2023 Hi All Anyone has a working hook to hide a payment methode for public only, (non logged in clients) ? 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted February 3, 2023 Share Posted February 3, 2023 35 minutes ago, DeeeExclusive said: Hi All Anyone has a working hook to hide a payment methode for public only, (non logged in clients) ? hi you can consider if client logged or not using this way $cli = Menu::context('client'); if (!is_null($cli)) { // the client logged in } 0 Quote Link to comment Share on other sites More sharing options...
exlhost Posted February 3, 2023 Share Posted February 3, 2023 thanks, you got the full hook? the one from brian is not working for me 😞 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted February 3, 2023 Share Posted February 3, 2023 (edited) 11 minutes ago, DeeeExclusive said: thanks, you got the full hook? the one from brian is not working for me 😞 ok this example will remove paypal for non logged in clients <?php /** * Hide paymentGateways for non logged in clients * @package WHMCS * @author AladdinJ */ if (!defined("WHMCS")) die("This file cannot be accessed directly"); add_hook('ClientAreaPageCart', 1, function($vars) { $cli = Menu::context('client'); if (is_null($cli)) { $gateways = $vars['gateways']; $remove = ['paypal']; foreach ($gateways as $k => $item) { if (in_array($item['sysname'],$remove)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } }); tell me it it works well with you Edited February 3, 2023 by AladdinJ 0 Quote Link to comment Share on other sites More sharing options...
exlhost Posted February 3, 2023 Share Posted February 3, 2023 hmm i dont understand, its not working for me im trying with banktransfer, and it still exist on cart.php while checking out when im not logged in 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted February 3, 2023 Share Posted February 3, 2023 (edited) 12 minutes ago, DeeeExclusive said: hmm i dont understand, its not working for me im trying with banktransfer, and it still exist on cart.php while checking out when im not logged in I just tested exact code I wrote for you it works with me $remove = ['paypal']; try replace the above line with $remove =array("banktransfer"); Edited February 3, 2023 by AladdinJ 0 Quote Link to comment Share on other sites More sharing options...
exlhost Posted February 3, 2023 Share Posted February 3, 2023 i tried, also switching themes, order forms it keeps active 😞 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted July 24, 2023 Share Posted July 24, 2023 Hi @AladdinJ, This has been working great but I noticed on the client invoice after the Free Trial the "Mail In" option is available. Is there a way to hide the "Mail In" option on the ClientAreaPageViewInvoice hook? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted August 1, 2023 Share Posted August 1, 2023 Just checking back to see if anyone has experience with this. 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted August 2, 2023 Share Posted August 2, 2023 @FutureX please send a photo what you want to hide in ViewInvoice ? 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted August 5, 2023 Share Posted August 5, 2023 The "Mail In Payment" option 0 Quote Link to comment Share on other sites More sharing options...
JHON MOSSES Posted August 26 Share Posted August 26 @AladdinJ Hello I hope you are fine I try the GitHub repo but I it was unable to removing my gateway my gateway is stripe can u please help me Thanks in Advance ❤️ 0 Quote Link to comment Share on other sites More sharing options...
AladdinJ Posted August 26 Share Posted August 26 3 hours ago, JHON MOSSES said: @AladdinJ Hello I hope you are fine I try the GitHub repo but I it was unable to removing my gateway my gateway is stripe can u please help me Thanks in Advance ❤️ Hello, What you need exaclty to do? 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.