Great question — answering as the UphillTech team:
I not sure why you chose these arrays? Why not rewrite them as: $discount_products_count = [273 => [9], 274 => [9], 275 => [9], 276 => [12], 277 => [9], 290 => [9], 291 => [12], 358 => [12], 359 => [12], 380 => [12], 419 => [10], 444 => [15], 445 => [15], 446 => [15], 473 => [12], 475 => [12], 478 => [12], 479 => [12], 500 => [12], 501 => [12], 502 => [12], 967 => [12], 969 => [8], 11613 => [12]]; Note that it is much easier to find a product, and you can have any box sizes you need, not just 8, 9, 10, 12 and 15. Then if you want to test if the discount applies you do: foreach ($cart->cart_contents as $item) { $product_id = $item["product_id"]; $quantity = $item["quantity"]; if...
Full answer by KIKO Software: https://stackoverflow.stackexchange.com/a/79940101 (CC BY-SA 4.0).
Need it done for your business? UphillTech.