$cartGoods = json_decode(file_get_contents('php://input'), true);
$goodsId = implode(",", array_map(
function ($e) {
return array_keys($e)[0];
},
$cartGoods
));
$goods = mysqli_query($connection, "SELECT * FROM `goods` WHERE `id` in ($goodsId)");
while ($item = mysqli_fetch_assoc($goods)) {
...
}