Browser: Chrome 110
OS: Windows
After updating to 1.9.6 and 1.9.6.1, the Query editor (PHP) in the query loop does not work (the output results are not in the right quantity and sorted correctly). I tested in 1.9.2-1.9.5 and they all work.
Issue:
I am using the following PHP to display up-sells products on the woocommerce cart page.
$up_sells = array();
$cart_ids = array(); // Store IDs of products in the cart
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$product = $cart_item['data'];
if ($product && $product->exists()) {
$cart_ids[] = $product->get_id(); // Save each product ID in the cart
if ($product->get_upsell_ids()) {
$up_sells = array_merge($up_sells, $product->get_upsell_ids());
}
}
}
// Use array_diff to remove products from $up_sells that are already in the cart
$up_sells = array_diff($up_sells, $cart_ids);
$up_sells = array_unique($up_sells);
return [
'post_type' => 'product',
'posts_per_page' => 3,
'orderby' => 'menu_order title',
'order' => 'ASC',
'post__in' => $up_sells,
];
The correct display result in 1.9.2-1.9.5 is:
The wrong result In 1.9.6 and 1.9.6.1 is: