Costco (NASDAQ:COST) has been remarkably steady in a climate where other retailers have struggled as more consumers move at least some of their shopping online.

That's at least partly because while Amazon (NASDAQ:AMZN) and other digital retailers may offer comparable (or even better pricing) they can't equal the warehouse club's shopping experience. Certainly many consumers go to Costco because of price, but others shop there because of the fun of discovering what deal may be offered that day or what limited-time seasonal merchandise may be on the chain's no-frill shelves.

Of course, some people also visit the warehouse club because of the free samples, while others enjoy the ability to get a cheap meal before or after shopping. It's a mix that has kept the chain growing despite it having a very limited online business.

Costco posted a decent 3% increase in United States comparable store sales in December 2016 and a fairly impressive 6% gain in January 2017. Those may not be Amazon-like growth numbers, but they are increases that the vast majority of retailers would be thrilled to have.

The problem the chain faces -- and it's a big risk going forward -- is that people are shopping in stores less and less. Eventually it's possible, maybe even probable, that Costco's immunity to this trend -- which has impacted so many other retailers -- will end.

US E-Commerce Sales as Percent of Retail Sales Chart

Image source:

Where are people shopping?

While it may feel like a massive amount of the total retail sales have moved online, in reality, digital sales only accounted for 8.4% of all sales in Q3 2016, according to data from the U.S. Census Bureau. The problem for retailers, as you can see on the chart above, is that the number has been steadily climbing.

The Q3 2016 data represents a full 1% increase year-over-yer from Q3 2015. Online sales have not made massive gains each year, but consumers are migrating and given the increased ease of buying things online, there's every reason to believe the trend will not only continue, but accelerate.

Those increases may not impact Costco at first but they are clearly hurting other retailers. A number of chains including Sports Authority, Linens-N-Things, Borders Books, Circuit City, and others have gone out of business over the past few years while a handful of top names are teetering on the edge in 2017.

It's possible that some of those losses actually have helped Costco, but at some point the death of physical retailers will push more consumers online. With less physical shopping choices consumers may simply decide that shopping is something they mostly do online and some, maybe many, could fall out of the Costco habit.

A store with "going out of business" signs.

As other retailers close Costco could gain customers or people could decide to shop online more. Image source: Getty Images.

How can Costco fight this?

The warehouse club chain has committed to beefing up its digital presence and it has shown some strong early results. On a global basis in Q1 2017, "total online sales were up 8% in the quarter and 7% on a comp basis," according to CFO Richard Galanti in the company's earnings call with investors. The CFO also pointed out that during the week of Thanksgiving and the two that followed, digital sales rose by the low-to-mid teens.

Galanti reiterated that the company would be investing in improving the digital experience by doing things like making it easier to check out and improving the returns process. Growing digital sales is a small hedge against customers shopping in stores less, but most consumers are not likely to stay Costco members, paying $55 or $110 a year, to mostly shop at a website.

For Costco to deal with the risk posed by the declining amount of money being spent overall in physical stores it must invest in making sure its warehouses remain destinations. That means increasing spending on everything from sampling to making sure its in-house restaurants remain a very cheap way to eat a meal or snack. The chain has to expand its focus on making people want to come to its stores because as they buy more and more online it could become harder to get them to leave the house just to shop.