Vaunted market beater Starbucks (SBUX -1.75%) has fallen on some hard times. The stock, which has historically trounced the S&P 500, is down over 30% from its high and has lagged the broader market for the past year.

The business has hit a rough patch with global sales down 4% year over year in its fiscal second quarter, ended March 31. Investors now have to determine whether Starbucks' struggles are just a blip or a significant turning point for the worst.

Only time will tell, but there is opportunity in uncertainty. I've outlined below why investors should consider an optimistic view on the coffee giant, what could be ailing sales, and why the stock could be a smart long-term buy.

Here is what you need to know.

The U.S. consumer is putting pressure on sales

Starbucks operates a massive global network of quick-service coffee restaurants. Nearly 39,000 Starbucks locations are open worldwide, making it one of the world's most prominent consumer brands. It's also a discretionary product as consumers don't need to visit a Starbucks; most do so because they want to do so.

One could argue that financial pressure on consumers is driving some of the company's recent struggles. For instance, the U.S. consumer is saving money at nearly the lowest rate in a decade:

US Personal Savings Rate Chart

US Personal Savings Rate data by YCharts

I know many people who love their Starbucks, but fancy coffee will be on the chopping block when budgets get tight. Is Starbucks' brand intact? I think so. The company's U.S. loyalty program grew memberships by 6% year over year in Q2 despite a 7% decline in traffic. In other words, people aren't abandoning the brand; they're just getting the product less frequently to save money.

The good news is that the economy works in cycles, and that means the consumer should eventually be back in a better financial position and able to indulge their Starbucks habits.

Low-priced competition is heating up in China

China has become a tremendous bet for Starbucks. It's investing aggressively in opening stores there to take market share in the enormous Chinese population. Starbucks has a whopping 7,093 stores in China as of Q2, a 12% year-over-year bump in store count. The investment thesis for China is straightforward. China's population of 1.4 billion should translate to an enormous middle-class demographic over the coming decades.

Starbucks is aggressively positioning itself in the market to build brand awareness and strength, which should hopefully pay off handsomely over time. However, Starbucks isn't alone; the company is caught in a competitive war with Luckin Coffee, a less expensive alternative with approximately 10,000 stores in China today.

A lower-priced competitor has seemingly spooked the market, especially since Starbucks' Q2 sales in China were down 11% year over year, led by an 8% headwind due to price cuts. Many Chinese consumers are gravitating to a lower-priced alternative. However, the population is so large that it's hard not to see enough room for Starbucks to ultimately carve out its share in the premium segment. The company's loyalty program grew to 21 million members in China in Q2, so there is positive momentum.

Chinese consumers are also struggling with economic pressures, which could create a favorable environment for Luckin Coffee. At the same time, many consumers may step up to Starbucks as a premium product during better financial times, assuming Starbucks successfully communicates the brand's value to the market.

Consumer spending pressures seem to be the real problem here, not so much an existential threat from Luckin Coffee. Like with the United States market, this should pass over time, and this lapse in confidence from Wall Street could wind up looking like a buying opportunity in hindsight.

Looking at the numbers

Starbucks shares trade hands at under 23 times earnings at the current price. That's down quite a ways from what was as high as nearly 40 times earnings a few years ago. You can see below how Wall Street sentiment (earnings estimates) once drove a high valuation but has dragged everything down as estimates fall to low double digits.

The shares are reasonably priced at 22 to 23 times earnings, considering even 12% earnings growth. The upside could come in the future as consumer spending recovers and Starbucks magically hits another gear as it has many times before.

SBUX EPS LT Growth Estimates Chart

SBUX EPS LT Growth Estimates data by YCharts

Starbucks has short-term headaches but has proven to be a quality stock over the years. No company avoids adversity forever. Notably, the brand seems intact. The company's struggles look like symptoms of a weak consumer more than anything. Long-term investors who believe in the company's ability to navigate these waters and rebound are usually rewarded in time.