Mica Craig said the reptile pounced as he was shopping at the store in the north-western US state of Washington. The 47-year-old stamped on the serpent and was later treated at hospital with anti-venom, after his hand suffered serious swelling.
Wal-Mart apologised, and said it was investigating how the snake had entered the store in the city of Clarkston.
Kayla Whaling, a spokeswoman for the chain, said: "At this point, it appears to be an isolated incident. "We are working with a pest management team, which is conducting a sweep of the property to ensure there is no additional rattlesnake activity."
Another customer, Maria Geffre, told Reuters news agency the snake was at least 1ft (30cm) long with four rattles.
Mr Craig said the serpent attacked as he reached down to brush away what he thought was a stick from a bag of mulch. The purchase was intended for his marijuana plants, which Mr Craig said he was licensed to grow for medical reasons.