Walmart is banning shoppers from openly carrying guns in its stores and ending the sale of some types of ammunition in response to two deadly shootings at its stores, the company said Tuesday.

"After selling through our current inventory commitments, we will discontinue sales of short-barrel rifle ammunition such as the .223 caliber and 5.56 caliber that, while commonly used in some hunting rifles, can also be used in large capacity clips on military-style weapons," Walmart CEO Doug McMillon said in a memo to employees on Tuesday.

He said the company will also end the sale of handguns in Alaska — the only state where Walmart sells handguns — and stop selling ammunition for all handguns nationwide.