Location: PHPKode > projects > MembersGear > membersgear/cronjobs/update_product_membership_status_except_expirestatus.php
<?php
  
  require_once "../config/config.php";
  require_once INCLUDE_DIR."/users_class.php";
  require_once INCLUDE_DIR."/PaygearWebserviceClient.php";
  require_once INCLUDE_DIR."/master_class.php";
  
  function UpdateProductStatus()
  {
      $loUserClass = new users_class();
      $loMasterClass = new master_class();
      
      $PaygearWebserviceClient = new PaygearWebserviceClient();
      
      $paymentStatusQuery = 'SELECT paygear_id FROM '.TABLE_PREFIX.'paygear_mastervalues WHERE paygear_master = \'ePaymentStatus\' AND (paygear_value=\'Pending\' OR paygear_value=\'Failed\')';
      $paymentStatusID = $loUserClass->View($paymentStatusQuery,null,null);
      
      $query = 'select * from '.TABLE_PREFIX.'product_users where paygear_epaymentstatus = ? or paygear_epaymentstatus = ?';
      $lsTempProductUsers = array((int)$paymentStatusID[0]['paygear_id'],(int)$paymentStatusID[1]['paygear_id']);
      $laResult = $loUserClass->View($query,$lsTempProductUsers,null);
      
      if(is_array($laResult) and sizeof($laResult) > 0)
      {
              foreach($laResult as $key=>$value)
              {
                  $liPaygearETransactionID = ($value['paygear_etransactionid'] != '') ? (int)$value['paygear_etransactionid'] : 0;     
                  $liPaygearOrderID = ($value['paygear_orderid'] != '') ? (int)$value['paygear_orderid'] : 0;
                  
                  $response = $PaygearWebserviceClient->GetPaygearTransactionDetailByOrderIdAndEtransactionID($liPaygearOrderID,$liPaygearETransactionID);
                  
                  if(is_array($response) and sizeof($response) > 0)
                  {
                        $response = str_replace("!@#$%^*()","=",$response);
                        $paygear_epaymentstatus = explode("=",$response[0]);
                        $paygear_vendorpaymentstatus = explode("=",$response[1]);
                        
//                        echo $paygear_epaymentstatus[1]."<br/>";
//                        echo $paygear_vendorpaymentstatus[1]."<br/>";
                        $updateQuery = 'UPDATE '.TABLE_PREFIX.'product_users SET paygear_epaymentstatus=?,paygear_vendorpaymentstatus=? WHERE id=?';
                        $laUpdateValues = array($paygear_epaymentstatus[1],$paygear_vendorpaymentstatus[1],$value['id']);
                        $updateResult = $loUserClass->Update($updateQuery,$laUpdateValues,null);
                  }
                  //echo "<br/><br/>";
              }
      }   
  }
  
  UpdateProductStatus();
?>
Return current item: MembersGear