Automattic\WooCommerce\Internal\StockNotifications\Frontend

MyAccountView::get_template_args │ public │ WC 11.2.0

Get template arguments for the stock notifications tables.

Method of the class: MyAccountView{}

No Hooks.

Returns

array<string,mixed>.

Usage

$MyAccountView = new MyAccountView();
$MyAccountView->get_template_args( $pending, $active, $page ): array;
$pending(array) (required)
Pending notifications, newest first.
$active(array) (required)
Active notifications for the current page.
$page(array<string,int>) (required)
Pagination state: current_page, total_pages, total_items, per_page.

Changelog

Since 11.2.0 Introduced.

MyAccountView::get_template_args() code WC 11.2.1

public function get_template_args( array $pending, array $active, array $page ): array {
	$current_page = max( 1, (int) ( $page['current_page'] ?? 1 ) );
	$total_pages  = max( 1, (int) ( $page['total_pages'] ?? 1 ) );

	return array(
		'pending_rows'      => $this->get_rows( $pending, $current_page ),
		'active_rows'       => $this->get_rows( $active, $current_page ),
		'current_page'      => $current_page,
		'total_pages'       => $total_pages,
		'total_items'       => max( 0, (int) ( $page['total_items'] ?? 0 ) ),
		'per_page'          => max( 1, (int) ( $page['per_page'] ?? MyAccountEndpoint::DEFAULT_PER_PAGE ) ),
		'previous_page_url' => $current_page > 1 ? MyAccountEndpoint::get_endpoint_url( $current_page - 1 ) : '',
		'next_page_url'     => $current_page < $total_pages ? MyAccountEndpoint::get_endpoint_url( $current_page + 1 ) : '',
		'shop_url'          => \wc_get_page_permalink( 'shop' ),
	);
}