The suspect was also captured on surveillance video waving with his gun at the camera, saying something inaudible, and then shooting out the camera at the front of the store.
A Walgreens in San Francisco has put chains around its freezers to stop shoplifting, which an employee said happens 15 to 20 times a day at the location.
The state is not renewing a contract worth about $54 million that allows California to buy prescription drugs from Walgreens for use mostly by the Department of Corrections.
The change comes after high demand for children's pain and fever medications led some stores, including CVS and Rite Aid, to limit purchases.
It's in response to the White House's call for pharmacies to help make winter healthier for Americans.
CVS said if the settlement is reached, it would pay the states nearly $5 billion over 10 years beginning in 2023. Walgreens said would also pay about $5 billion over the course of 15 years.