get_user_products.php 753 B

123456789101112131415161718192021222324
  1. <?php
  2. // returns an array of product ids already bought be the client
  3. if (!defined("WHMCS"))
  4. die("This file cannot be accessed directly");
  5. add_hook('ClientAreaPageCart', 1, function($vars) {
  6. // check client login status
  7. if(!isset($vars['clientsdetails']['id'])) {
  8. return;
  9. }
  10. $active_pids = array();
  11. $clientId = $vars['clientsdetails']['id'];
  12. // get client products
  13. $clientProducts = localAPI('GetClientsProducts', array('clientid' => $clientId, 'stats' => false));
  14. if(!$clientProducts['result'] == 'success'){
  15. return;
  16. }
  17. foreach($clientProducts['products']['product'] as $product) {
  18. array_push($active_pids, $product['pid']);
  19. }
  20. return array('clientPids' => $active_pids);
  21. });