WC_Customer_Download_Data_Store::read()
Method to read a download permission from the database.
Method of the class: WC_Customer_Download_Data_Store{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Customer_Download_Data_Store = new WC_Customer_Download_Data_Store(); $WC_Customer_Download_Data_Store->read( $download );
- $download(WC_Customer_Download) (required) (passed by reference — &)
- WC_Customer_Download object.
WC_Customer_Download_Data_Store::read() WC Customer Download Data Store::read code WC 9.4.2
public function read( &$download ) { global $wpdb; if ( ! $download->get_id() ) { throw new Exception( __( 'Invalid download.', 'woocommerce' ) ); } $download->set_defaults(); $raw_download = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE permission_id = %d", $download->get_id() ) ); if ( ! $raw_download ) { throw new Exception( __( 'Invalid download.', 'woocommerce' ) ); } $download->set_props( array( 'download_id' => $raw_download->download_id, 'product_id' => $raw_download->product_id, 'user_id' => $raw_download->user_id, 'user_email' => $raw_download->user_email, 'order_id' => $raw_download->order_id, 'order_key' => $raw_download->order_key, 'downloads_remaining' => $raw_download->downloads_remaining, 'access_granted' => strtotime( $raw_download->access_granted ), 'download_count' => $raw_download->download_count, 'access_expires' => is_null( $raw_download->access_expires ) ? null : strtotime( $raw_download->access_expires ), ) ); $download->set_object_read( true ); }