Craft Posted November 24, 2019 Author Share Posted November 24, 2019 (edited) 38 minutes ago, aissa el youssfu said: thanks for your response this isthe code <?php /* * * Auto Accept Orders * Created By Idan Ben-Ezra * * Copyrights @ Jetserver Web Hosting * www.jetserver.net * * Hook version 1.0.1 * **/ if (!defined("WHMCS")) die("This file cannot be accessed directly"); /********************* Auto Accept Orders Settings *********************/ function jetserverAutoAcceptOrders_settings() { return array( 'apiuser' =>myadminusername '', // one of the admins username 'autosetup' => true, // determines whether product provisioning is performed 'sendregistrar' => true, // determines whether domain automation is performed 'sendemail' => true, // sets if welcome emails for products and registration confirmation emails for domains should be sent 'ispaid' => true, // set to true if you want to accept only paid orders 'paymentmethod' => array(), // set the payment method you want to accept automaticly (leave empty to use all payment methods) * example array('paypal','amazonsimplepay') ); } /********************/ function jetserverAutoAcceptOrders_accept($vars) { $settings = jetserverAutoAcceptOrders_settings(); $ispaid = true; if($vars['InvoiceID']) { $result = localAPI('getinvoice', array( 'invoiceid' => $vars['InvoiceID'], ), $settings['apiuser']); $ispaid = ($result['result'] == 'success' && $result['balance'] <= 0) ? true : false; } if((!sizeof($settings['paymentmethod']) || sizeof($settings['paymentmethod']) && in_array($vars['PaymentMethod'], $settings['paymentmethod'])) && (!$settings['ispaid'] || $settings['ispaid'] && $ispaid)) { $result = localAPI('acceptorder', array( 'orderid' => $vars['OrderID'], 'autosetup' => $settings['autosetup'], 'sendregistrar' => $settings['sendregistrar'], 'sendemail' => $settings['sendemail'], ), $settings['apiuser']); } } add_hook('AfterShoppingCartCheckout', 0, 'jetserverAutoAcceptOrders_accept'); Yea this is the old hook which working on the old versions on WHMCS But you need to replace this code with the updated one to be compatible with the new version of WHMCS But take care, it's working only for hosting orders not for domain registration/transfer orders Here is the update code: <?php /* * * Auto Accept Orders * Created By Idan Ben-Ezra * * Copyrights @ Jetserver Web Hosting * www.jetserver.net * * Hook version 1.0.1 * **/ if (!defined("WHMCS")) die("This file cannot be accessed directly"); /********************* Auto Accept Orders Settings *********************/ function AutoAcceptOrders_settings() { return array( 'apiuser' => 'admin', // one of the admins username 'autosetup' => true, // determines whether product provisioning is performed 'sendregistrar' => false, // determines whether domain automation is performed 'sendemail' => true, // sets if welcome emails for products and registration confirmation emails for domains should be sent 'ispaid' => true, // set to true if you want to accept only paid orders ); } function AutoAcceptOrders_accept($vars) { $settings = AutoAcceptOrders_settings(); $ispaid = true; if($vars['InvoiceID']) { $result = localAPI('GetInvoice', array( 'invoiceid' => $vars['invoiceId'], ), $settings['apiuser']); $ispaid = ($result['result'] == 'success' && $result['balance'] <= 0) ? true : false; } logActivity("Order isPaid: ".$ispaid,0); if(( $settings['ispaid'] && $ispaid)) { $result = localAPI('AcceptOrder', array( 'orderid' => $vars['orderId'], 'autosetup' => $settings['autosetup'], 'sendemail' => $settings['sendemail'], ), $settings['apiuser']); logActivity("Order Accept", 0); if(is_array($result)){ foreach($result as $index=>$value){ logActivity("$index:$value",0); } } } } add_hook('OrderPaid', 1, 'AutoAcceptOrders_accept'); ?> Reference: https://github.com/Jetserver/WHMCS-Auto-Accept-Orders/issues/1 Edited November 24, 2019 by Craft 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 24, 2019 Author Share Posted November 24, 2019 14 minutes ago, aissa el youssfu said: under which name should i save this same file .. take a backup from your current file then replace the code 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 24, 2019 Author Share Posted November 24, 2019 34 minutes ago, aissa el youssfu said: oh yeah thank you so much I think it works but he problem is when a client pays i go to my paypal the payment is recieved but at the client dashboard there still an invoice Share a screenshot to understand you better and try to solve the issue 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 24, 2019 Author Share Posted November 24, 2019 15 minutes ago, aissa el youssfu said: this is the dashboard of one my client, he paid the invoice and the payment is recieved. but as you can see the incoice is still appearing. Yea because (isPaid) function doesn't run successfully. Can you share a screenshot from the Activity log (Utilities >> Log >> Activity Log) 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 24, 2019 Author Share Posted November 24, 2019 24 minutes ago, aissa el youssfu said: please what causes also those errors with green marks This issue is not related to the hook by the way. Your order is now "Active" or still pending? I'm asking about the Order Status not the Order Item! You can check it from the main page of "Orders" tab >> List All Orders 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 25, 2019 Author Share Posted November 25, 2019 26 minutes ago, aissa el youssfu said: still pending That’s correct because the order should be paid first then it will accept the order Now you need to solve the payment issue first 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 25, 2019 Author Share Posted November 25, 2019 1 hour ago, aissa el youssfu said: please what causes also those errors with green marks Make sure that you are using a valid emails here: Setup >> General Settings >> General tab >> (Email Address) field Setup >> General Settings >> Mail tab >> (System Emails From Email) field 1 Quote Link to comment Share on other sites More sharing options...
Bhondawe30 Posted November 29, 2019 Share Posted November 29, 2019 Thanks for sharing your knowledge base, It will be helpful for me. 1 Quote Link to comment Share on other sites More sharing options...
ForestRacks Posted September 30, 2020 Share Posted September 30, 2020 Does anyone have a working WHMCS v8.0 version of this? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 1, 2020 Share Posted October 1, 2020 Kian posted a hook that auto accepts orders when the invoice is paid - I see no reason why it wouldn't work on v8, though I haven't tested it. https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/AcceptOrderOnInvociePaid.php 1 Quote Link to comment Share on other sites More sharing options...
Synister Posted November 15, 2020 Share Posted November 15, 2020 On 10/1/2020 at 10:19 AM, brian! said: Kian posted a hook that auto accepts orders when the invoice is paid - I see no reason why it wouldn't work on v8, though I haven't tested it. https://github.com/Katamaze/WHMCS-Free-Action-Hooks/blob/master/hooks/AcceptOrderOnInvociePaid.php How could this be configured to only Accept Orders that are under $21.00 USD? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 18, 2020 Share Posted November 18, 2020 On 15/11/2020 at 04:27, Synister said: How could this be configured to only Accept Orders that are under $21.00 USD? well this is Kian's baby, but there is a line in the hook... $invoiceAmount = false; // Auto-accept order only if invoice amount is >= $invoiceAmount. Set false to auto-accept everything (Important: currency conversion not supported) if you only have one currency, USD, then you could change that false to 21 and you should be good to go. if you have multiple currencies in WHMCS, then you might need to find the currency of the invoice and alter the hook coding accordingly. 1 Quote Link to comment Share on other sites More sharing options...
Synister Posted November 18, 2020 Share Posted November 18, 2020 Yes. He recently updated it after my request. Thank you 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 19, 2020 Share Posted November 19, 2020 (edited) I just finished adding multi-currency support. Moreover now you can choose the to restrict order acceptance based on invoice amount (>= X or <= X) Edited November 19, 2020 by Kian 1 Quote Link to comment Share on other sites More sharing options...
dbbrito Posted January 20, 2023 Share Posted January 20, 2023 On 11/19/2020 at 11:21 AM, Kian said: I just finished adding multi-currency support. Moreover now you can choose the to restrict order acceptance based on invoice amount (>= X or <= X) Hello, does this hook work for whmcs 8.6.1? Thanks 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted January 21, 2023 Share Posted January 21, 2023 It shouldn't be a problem. 0 Quote Link to comment Share on other sites More sharing options...
dbbrito Posted January 21, 2023 Share Posted January 21, 2023 2 minutes ago, Kian said: It shouldn't be a problem. Hello Kian, yes it is working, is there any configuration to choose only a certain group of products? Thanks 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.