It seems like most of this can be split into another function if necessary (it can loop over the items in `cart` instead of checking them individually like this)