Walmart said it will bar shoppers from openly carrying guns in its stores and end the sale of ammunition for handguns and assault-style weapons.