/**
  * @deprecated
  */
 function _fetch_merchant_txn_id_old(&$member, $force = false)
 {
     if (!isset($member->payment_info->txn_id) || empty($member->payment_info->txn_id)) {
         // check from transaction table
         $authorizenet_transaction_id = mgm_get_transaction_option($member->transaction_id, 'authorizenet_transaction_id');
         if ((int) $authorizenet_transaction_id > 0) {
             // set
             $member->payment_info->txn_id = $authorizenet_transaction_id;
             // log
             // mgm_log('fetch from transaction option: '. $member->payment_info->txn_id, __FUNCTION__);
             // save
             return $member->save();
         } else {
             // // fetch from batch, @todo test before running
             $authorizenet_transaction_id = mgm_fetch_authorizenet_missing_txn_id($this, $member->id);
             if ((int) $authorizenet_transaction_id > 0) {
                 // set
                 $member->payment_info->txn_id = $authorizenet_transaction_id;
                 // log
                 // mgm_log('fetch from refetch using batch api: '. $member->payment_info->txn_id, __FUNCTION__);
                 // save
                 return $member->save();
             }
         }
     }
 }
/**
 * update transactions missing data
 */
function mgm_update_transaction_data()
{
    // db
    global $wpdb;
    //
    // sql
    $sql = "SELECT id,user_id,module,data,transaction_dt FROM `" . TBL_MGM_TRANSACTION . "` \r\r\n\t         WHERE 1 AND (`user_id` IS NULL OR `user_id` = 0) AND module IS NOT NULL LIMIT 0, 50";
    //  check missing user_id
    if ($transactions = $wpdb->get_results($sql)) {
        // log
        // mgm_log($transactions, __FUNCTION__);
        // loop
        foreach ($transactions as $transaction) {
            // pack
            $pack = json_decode($transaction->data, true);
            // check
            if (isset($pack['user_id']) && (int) $pack['user_id'] > 0) {
                // id
                $user_id = $pack['user_id'];
                // update
                $wpdb->update(TBL_MGM_TRANSACTION, array('user_id' => $user_id), array('id' => $transaction->id));
                // log
                mgm_log($wpdb->last_query, __FUNCTION__);
            }
        }
    }
    // authorizenet module
    $authorizenet = mgm_get_module('authorizenet', 'payment');
    // if active
    if ($authorizenet->is_enabled()) {
        // fetch module transactions
        // mgm_log('Enabled', __FUNCTION__);
        // 1699,1700,1711,1712,1714,1716,1718,1721,1725,1734,1735,1724,1722
        mgm_fetch_authorizenet_missing_txn_id($authorizenet);
    }
}