WC_Customer_Download_Data_Store::create
Create download permission for a user.
Method of the class: WC_Customer_Download_Data_Store{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WC_Customer_Download_Data_Store = new WC_Customer_Download_Data_Store(); $WC_Customer_Download_Data_Store->create( $download );
- $download(WC_Customer_Download) (required) (passed by reference — &)
- WC_Customer_Download object.
WC_Customer_Download_Data_Store::create() WC Customer Download Data Store::create code WC 10.3.5
public function create( &$download ) {
global $wpdb;
// Always set a access granted date.
if ( is_null( $download->get_access_granted( 'edit' ) ) ) {
$download->set_access_granted( time() );
}
$data = array();
foreach ( self::DOWNLOAD_PERMISSION_DB_FIELDS as $db_field_name ) {
$value = call_user_func( array( $download, 'get_' . $db_field_name ), 'edit' );
$data[ $db_field_name ] = $value;
}
$inserted_id = $this->insert_new_download_permission( $data );
if ( $inserted_id ) {
$download->set_id( $inserted_id );
$download->apply_changes();
}
do_action( 'woocommerce_grant_product_download_access', $data );
}