How can I check for multiples of a product ID with the API? E.g. Code: require_once '....../bootstrap.php'; $user = Am_Di::getInstance()->userTable->findFirstBy(array('login' => $username)); $active_subs = $user->getActiveProductIds(); print_r($active_subs); This would show E.g. Array ( [0] => 9 [1] => 39 [2] => 71 ) Whereas the user actually has multiples of product ID 39. Is there a way to get active product ID's, or to check how many multiples a user has of a specific product ID?
You need to query database to get this info. Here is example code: PHP: $qty = Am_Di::getInstance()->db->selectCell( "SELECT SUM(qty) FROM ?_access WHERE product_id=? AND user_id=? AND begin_date<=? AND expire_date>=?", 39, //pid $user->pk(), //uid sqlDate('now'), sqlDate('now')); Please note result can be 0 - it means user has not active access to this product (with id 39).