#1008. Added logic to ensure that offer codes that cannot be used again
are not considered.(cherry picked from commit 0904d7683433bf51397c507b19d7a5fe9654befa)