Automattic\WooCommerce\Internal\Products

ProductsOrderingMoveService::compose_anchor_positions │ private │ WC 1.0

Fetches the current menu_order for the anchor products.

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

Хуков нет.

Возвращает

array<int,int>.

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

// private - только в коде основоного (родительского) класса
$result = $this->compose_anchor_positions( $previous_id, $product_id, $next_id ): array;
$previous_id(int) (обязательный)
ID of the product immediately before the target position, or 0 when moving to the start.
$product_id(int) (обязательный)
ID of the product being repositioned.
$next_id(int) (обязательный)
ID of the product immediately after the target position, or 0 when moving to the end.

Код ProductsOrderingMoveService::compose_anchor_positions() WC 11.2.2

private function compose_anchor_positions( int $previous_id, int $product_id, int $next_id ): array {
	global $wpdb;

	return array_column(
		$wpdb->get_results(
			$wpdb->prepare(
				"SELECT ID, menu_order FROM {$wpdb->posts} WHERE ID IN (%d, %d, %d) ORDER BY menu_order ASC",
				$previous_id,
				$product_id,
				$next_id
			)
		),
		'menu_order',
		'ID'
	);
}