WC_Customer_Download_Log_Data_Store::create()
Create download log entry.
Method of the class: WC_Customer_Download_Log_Data_Store{}
Hooks from the method
Return
null
. Nothing (null).
Usage
$WC_Customer_Download_Log_Data_Store = new WC_Customer_Download_Log_Data_Store(); $WC_Customer_Download_Log_Data_Store->create( $download_log );
- $download_log(WC_Customer_Download_Log) (required)
- Customer download log object.
WC_Customer_Download_Log_Data_Store::create() WC Customer Download Log Data Store::create code WC 9.4.2
public function create( WC_Customer_Download_Log &$download_log ) { global $wpdb; // Always set a timestamp. if ( is_null( $download_log->get_timestamp( 'edit' ) ) ) { $download_log->set_timestamp( time() ); } $data = array( 'timestamp' => date( 'Y-m-d H:i:s', $download_log->get_timestamp( 'edit' )->getTimestamp() ), 'permission_id' => $download_log->get_permission_id( 'edit' ), 'user_id' => $download_log->get_user_id( 'edit' ), 'user_ip_address' => $download_log->get_user_ip_address( 'edit' ), ); $format = array( '%s', '%s', '%s', '%s', ); $result = $wpdb->insert( $wpdb->prefix . self::get_table_name(), apply_filters( 'woocommerce_downloadable_product_download_log_insert_data', $data ), apply_filters( 'woocommerce_downloadable_product_download_log_insert_format', $format, $data ) ); do_action( 'woocommerce_downloadable_product_download_log_insert', $data ); if ( $result ) { $download_log->set_id( $wpdb->insert_id ); $download_log->apply_changes(); } else { wp_die( esc_html__( 'Unable to insert download log entry in database.', 'woocommerce' ) ); } }