Automattic\WooCommerce\Internal\StockNotifications\Frontend

MyAccountView::get_template_args │ public │ WC 11.2.0

Get template arguments for the stock notifications tables.

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

Хуков нет.

Возвращает

array<string,mixed>.

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

$MyAccountView = new MyAccountView();
$MyAccountView->get_template_args( $pending, $active, $page ): array;
$pending(array) (обязательный)
Pending notifications, newest first.
$active(array) (обязательный)
Active notifications for the current page.
$page(array<string,int>) (обязательный)
Pagination state: current_page, total_pages, total_items, per_page.

Список изменений

С версии 11.2.0 Введена.

Код MyAccountView::get_template_args() WC 11.2.2

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