Automattic\WooCommerce\Internal\Admin\Orders

ListTable::bulk_action_notices()publicWC 1.0

Show confirmation message that order status changed for number of orders.

Method of the class: ListTable{}

No Hooks.

Return

null. Nothing.

Usage

$ListTable = new ListTable();
$ListTable->bulk_action_notices();

ListTable::bulk_action_notices() code WC 7.1.0

public function bulk_action_notices() {
	if ( empty( $_REQUEST['bulk_action'] ) ) {
		return;
	}

	$order_statuses = wc_get_order_statuses();
	$number         = absint( $_REQUEST['changed'] ?? 0 );
	$bulk_action    = wc_clean( wp_unslash( $_REQUEST['bulk_action'] ) );
	$message        = '';

	// Check if any status changes happened.
	foreach ( $order_statuses as $slug => $name ) {
		if ( 'marked_' . str_replace( 'wc-', '', $slug ) === $bulk_action ) { // WPCS: input var ok, CSRF ok.
			/* translators: %s: orders count */
			$message = sprintf( _n( '%s order status changed.', '%s order statuses changed.', $number, 'woocommerce' ), number_format_i18n( $number ) );
			break;
		}
	}

	switch ( $bulk_action ) {
		case 'removed_personal_data':
			/* translators: %s: orders count */
			$message = sprintf( _n( 'Removed personal data from %s order.', 'Removed personal data from %s orders.', $number, 'woocommerce' ), number_format_i18n( $number ) );
			echo '<div class="updated"><p>' . esc_html( $message ) . '</p></div>';
			break;

		case 'trashed':
			/* translators: %s: orders count */
			$message = sprintf( _n( '%s order moved to the Trash.', '%s orders moved to the Trash.', $number, 'woocommerce' ), number_format_i18n( $number ) );
			break;

		case 'untrashed':
			/* translators: %s: orders count */
			$message = sprintf( _n( '%s order restored from the Trash.', '%s orders restored from the Trash.', $number, 'woocommerce' ), number_format_i18n( $number ) );
			break;

		case 'deleted':
			/* translators: %s: orders count */
			$message = sprintf( _n( '%s order permanently deleted.', '%s orders permanently deleted.', $number, 'woocommerce' ), number_format_i18n( $number ) );
			break;
	}

	if ( ! empty( $message ) ) {
		echo '<div class="updated"><p>' . esc_html( $message ) . '</p></div>';
	}
}