WC_Customer_Download_Log_Data_Store::create()publicWC 1.0

Create download log entry.

Метод класса: WC_Customer_Download_Log_Data_Store{}

Возвращает

null. Ничего (null).

Использование

$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) (обязательный)
Customer download log object.

Код WC_Customer_Download_Log_Data_Store::create() WC 8.7.0

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' ) );
	}
}