فهرست منبع

add new files

andre 4 سال پیش
والد
کامیت
7808582c45
2فایلهای تغییر یافته به همراه49 افزوده شده و 0 حذف شده
  1. 25 0
      accept_order.php
  2. 24 0
      get_user_products.php

+ 25 - 0
accept_order.php

@@ -0,0 +1,25 @@
+<?php
+
+// this hook sets the order status to accepted after the invoice is fully paid
+
+if (!defined("WHMCS"))
+    die("This file cannot be accessed directly");
+
+use WHMCS\Database\Capsule;
+function get_order($invoiceid) {
+    $order = Capsule::table('tblorders')->where('invoiceid', $invoiceid)->first();
+    return $order->id;
+}
+
+add_hook('InvoicePaid', 1, function($vars) {
+    $orderId = get_order($vars['invoiceid']);
+    $api = localAPI('acceptorder', array('orderid' => $orderId));
+    if ($api['result'] == 'success') {
+        return true;
+    } else {
+        $errormessage .= $api['message'];
+        return false;
+    }
+});
+
+?>

+ 24 - 0
get_user_products.php

@@ -0,0 +1,24 @@
+<?php
+
+// returns an array of product ids already bought be the client
+
+if (!defined("WHMCS"))
+    die("This file cannot be accessed directly");
+
+add_hook('ClientAreaPageCart', 1, function($vars) {
+    // check client login status
+    if(!isset($vars['clientsdetails']['id'])) {
+        return;
+    }
+    $active_pids = array();
+    $clientId = $vars['clientsdetails']['id'];
+    // get client products
+    $clientProducts = localAPI('GetClientsProducts', array('clientid' => $clientId, 'stats' => false));
+    if(!$clientProducts['result'] == 'success'){
+        return;
+    }
+    foreach($clientProducts['products']['product'] as $product) {
+        array_push($active_pids, $product['pid']);
+    }
+    return array('clientPids' => $active_pids);
+});