Automattic\WooCommerce\Internal\Products
ProductsOrderingMoveService::compose_anchor_positions
Fetches the current menu_order for the anchor products.
Method of the class: ProductsOrderingMoveService{}
No Hooks.
Returns
array<int,int>.
Usage
// private - for code of main (parent) class only $result = $this->compose_anchor_positions( $previous_id, $product_id, $next_id ): array;
- $previous_id(int) (required)
- ID of the product immediately before the target position, or 0 when moving to the start.
- $product_id(int) (required)
- ID of the product being repositioned.
- $next_id(int) (required)
- ID of the product immediately after the target position, or 0 when moving to the end.
ProductsOrderingMoveService::compose_anchor_positions() ProductsOrderingMoveService::compose anchor positions code WC 11.3.0
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'
);
}