ActionScheduler_DBLogger::bulk_log_cancel_actions()publicWC 1.0

Bulk add cancel action log entries.

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

Хуков нет.

Возвращает

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

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

$ActionScheduler_DBLogger = new ActionScheduler_DBLogger();
$ActionScheduler_DBLogger->bulk_log_cancel_actions( $action_ids );
$action_ids(массив) (обязательный)
List of action ID.

Код ActionScheduler_DBLogger::bulk_log_cancel_actions() WC 8.7.0

public function bulk_log_cancel_actions( $action_ids ) {
	if ( empty( $action_ids ) ) {
		return;
	}

	/** @var \wpdb $wpdb */ //phpcs:ignore Generic.Commenting.DocComment.MissingShort
	global $wpdb;
	$date     = as_get_datetime_object();
	$date_gmt = $date->format( 'Y-m-d H:i:s' );
	ActionScheduler_TimezoneHelper::set_local_timezone( $date );
	$date_local = $date->format( 'Y-m-d H:i:s' );
	$message    = __( 'action canceled', 'woocommerce' );
	$format     = '(%d, ' . $wpdb->prepare( '%s, %s, %s', $message, $date_gmt, $date_local ) . ')';
	$sql_query  = "INSERT {$wpdb->actionscheduler_logs} (action_id, message, log_date_gmt, log_date_local) VALUES ";
	$value_rows = array();

	foreach ( $action_ids as $action_id ) {
		$value_rows[] = $wpdb->prepare( $format, $action_id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
	}
	$sql_query .= implode( ',', $value_rows );

	$wpdb->query( $sql_query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}