Edit: This was marked for visibility and is not considered solved.
@janz797 I've moved your post to the Sims 3 PC tech section. This issue has surfaced today, or maybe yesterday, although some of the people reporting it have mentioned buying from unauthorized third-party sites. Your code should have been fine though; I'm just saying it's not always easy to separate the issues.
Before doing anything else, please make sure that you are in fact entering the code properly, that you're not writing zero instead of the letter o, one instead of the letter i, etc. It would be annoying for you to have to jump through hoops if this was the issue.
Just in case the code did work despite the error message, please clear Origin's cache:
https://help.ea.com/en-us/help/faq/clear-cache-to-fix-problems-with-your-games/
restart your computer, and see whether Generations is present. Open your Origin game library, choose More > Expansion Packs, scroll down to Generations, and see whether you can download it. Let me know either way.
If you're still asked to Buy Now, please try registering the code on the Sims 3 Store site, just to see whether the problem happens there too. Login with your Origin credentials, scroll down to the bottom of the page, click Register a Game, and enter the 20-character code.
https://store.thesims3.com/
Otherwise, you'll need to contact EA customer support and ask about the status of the code. Support is on reduced hours right now: phone calls are entirely unavailable, and live chat is only open from 9 am to midnight GMT, Monday through Saturday.
https://help.ea.com/en/contact-us/
When you contact support, it would be useful to have a photo showing the disc (if you have one), the box it came in, and the insert with the code printed on the back; as well as a photo of the receipt from Walmart. You can upload the photos directly to a live chat session.
However this goes, please let me know what happens. Since this might be a more widespread issue, any info you can provide would be appreciated. And if this isn't a simple fix, I will ask if someone from EA might be able to take a look.