WC_API_Customers::get_customer_downloads() public WC 2.2
Get the available downloads for a customer
{} It's a method of the class: WC_API_Customers{}
Hooks from the method
Return
Array|WP_Error.
Usage
$WC_API_Customers = new WC_API_Customers(); $WC_API_Customers->get_customer_downloads( $id, $fields );
- $id(int) (required)
- the customer ID
- $fields(string)
- fields to include in response
Changelog
Since 2.2 | Introduced. |
Code of WC_API_Customers::get_customer_downloads() WC API Customers::get customer downloads WC 5.0.0
public function get_customer_downloads( $id, $fields = null ) {
$id = $this->validate_request( $id, 'customer', 'read' );
if ( is_wp_error( $id ) ) {
return $id;
}
$downloads = array();
$_downloads = wc_get_customer_available_downloads( $id );
foreach ( $_downloads as $key => $download ) {
$downloads[] = array(
'download_url' => $download['download_url'],
'download_id' => $download['download_id'],
'product_id' => $download['product_id'],
'download_name' => $download['download_name'],
'order_id' => $download['order_id'],
'order_key' => $download['order_key'],
'downloads_remaining' => $download['downloads_remaining'],
'access_expires' => $download['access_expires'] ? $this->server->format_datetime( $download['access_expires'] ) : null,
'file' => $download['file'],
);
}
return array( 'downloads' => apply_filters( 'woocommerce_api_customer_downloads_response', $downloads, $id, $fields, $this->server ) );
}