Stock markets are setting records, but Starbucks (SBUX 0.47%) shareholders aren't benefiting from that rally. The coffee titan's stock is trading near its 52-week low of $89 per share even though the S&P 500 has surged 30% higher in the past year. As a result, investors can buy the coffee specialist at an unusually low valuation.

But Starbucks might not be a steal at these prices given the weakening demand trends in its core U.S. market. Let's take a look at whether you should put a venti-size position of this stock in your portfolio today.

Feeling over-caffeinated

The coffee chain's late-January earnings report left investors wanting more. Sure, comparable-store sales jumped 5% across its global sales footprint. And that boost was powered by a healthy mix between rising customer traffic (up 3%) and higher average spending (up 2%).

Yet look a bit deeper and you'll see signs of struggles at the company's cafes. Customer traffic declined in the U.S. market and average spending fell in Starbucks' other big market, China. Management doesn't see a quick end to these challenges, either.

The Chinese market is seeing a flood of low-priced competitors that will pressure earnings for a while before many of them are driven out of the industry. And, while traffic started to rebound in the U.S. toward the end of fiscal Q1, Starbucks has work to do to win back its afternoon visitors. "We feel good about the trajectory over the course of the quarter, but it will take time for plans to be fully realized," CEO Laxman Narasimhan said in a conference call with investors.

Patience is key

There was some good news in Starbucks' earnings update, too. The chain's most loyal customers -- the ones who visit in the morning on most days -- continued to frequent its cafes this past quarter. And Starbucks is getting more efficient thanks to a combination of cost cuts and a few popular product releases. These successes allowed sales to continue rising into early 2024 while earnings jumped 22% to $0.90 per share. Operating profit margin improved to 16% of sales from 14% of sales in the year-ago period.

Cash flow is ample and supports the company's higher spending on growth initiatives along with its rising dividend payment. Starbucks also spent $1.3 billion repurchasing its stock, up from about $200 million a year ago. Investors can feel reasonably confident in these rising direct cash returns continuing in 2024 and beyond, even if takes some time for the chain to recover its growth momentum in the U.S. and China.

An attractive discount

Investors are being offered Starbucks stock at a big discount that seems to reflect too much of a focus on its short-term growth challenges. You can own shares for 24 times earnings and 2.8 times sales, with both ratios representing 52-week lows. If you're risk averse, you might want to wait for a few quarters while Starbucks' strategic and marketing shifts begin building up its growth momentum. By then, some of the competitive challenges in China should be clearing up as well.

Yet you should see the best returns from buying the stock while pessimism is elevated. The chain is highly profitable and cash rich, and it's boosting customer satisfaction among its most loyal shoppers. These factors suggest Starbucks will be back to its winning ways before too long. Looking back in a few years, investors could be happy they decided to snap up Starbucks' shares at a discount in 2024.