Function Reference: geodir_payment_user_invoices

Summary

This function has not been documented yet.

Filters

‘geodir_payment_user_invoices_where’ [Line: 1971]

‘geodir_payment_user_invoices_order_by’ [Line: 1975]

Source Code

function geodir_payment_user_invoices( $args ) {
	global $wpdb;
	$where = array();
	if ( !empty( $args['filter'] ) ) {
		$where = '';
		foreach ( $args['filter'] as $key => $value ) {
			$where[] = $wpdb->prepare( $key . " = %s", array( $value ) );
		}
	}
	$where = !empty( $where ) ? implode( " AND ", $where ) : '';
	
	$where = apply_filters( 'geodir_payment_user_invoices_where', $where, $args );
	$where = $where != '' ? " WHERE " . $where : '';
	
	$order_by = !empty( $args['order_by'] ) ? $args['order_by'] : 'id DESC';
	$order_by = apply_filters( 'geodir_payment_user_invoices_order_by', $order_by, $args );
	$order_by = $order_by != '' ? " ORDER BY " . $order_by : '';
	
	$limit = '';
	$fiedls = '*';
	if ( !empty( $args['count_only'] ) ) {
		$query = "SELECT COUNT(id) FROM " . INVOICE_TABLE . " ". $where;
		$result = (int)$wpdb->get_var($query);
	} else {
		$limit = !empty($args['per_page']) ? $args['per_page'] : 10;
		
		$page = !empty($args['pageno']) ? absint($args['pageno']) : 1;
		if ( !$page ) {
			$page = 1;
		}
		
		if ( $args['total'] < absint( $page * $limit ) ) {
			$page = ceil( $args&#91;'total'&#93; / $limit );
		}
		
		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
		
		$query = "SELECT *, IF(date_updated != '0000-00-00 00:00:00', date_updated, date) AS date_updated FROM " . INVOICE_TABLE . " ". $where . " " . $order_by . " " . $limit;
		$result = $wpdb->get_results($query);
	}
	
	return $result;
}