accept_order.php 639 B

12345678910111213141516171819202122232425
  1. <?php
  2. // this hook sets the order status to accepted after the invoice is fully paid
  3. if (!defined("WHMCS"))
  4. die("This file cannot be accessed directly");
  5. use WHMCS\Database\Capsule;
  6. function get_order($invoiceid) {
  7. $order = Capsule::table('tblorders')->where('invoiceid', $invoiceid)->first();
  8. return $order->id;
  9. }
  10. add_hook('InvoicePaid', 1, function($vars) {
  11. $orderId = get_order($vars['invoiceid']);
  12. $api = localAPI('acceptorder', array('orderid' => $orderId));
  13. if ($api['result'] == 'success') {
  14. return true;
  15. } else {
  16. $errormessage .= $api['message'];
  17. return false;
  18. }
  19. });
  20. ?>