The S&P 500 fell into a bear market early last year as economic uncertainty weighed on investor sentiment. The situation has improved very little since then. High inflation and rising interest rates contributed to a sharp slowdown in economic growth in the first quarter this year, and many experts believe the situation will culminate in a recession. But there is a silver lining for patient investors.

Bad news tends to create buying opportunities. The S&P 500 is still down 13%, but history says the next bull market is coming. The benchmark index has recovered from every past bear market and recession, and investors have no reason to expect a different outcome this time. But right now, Shopify (SHOP 3.42%) stock is down 64%, and trading at a discount to its historical valuation. That is a buying opportunity.

Here's what investors should know.

Shopify is the market leader in e-commerce software

Shopify simplifies commerce. Its software allows merchants to manage their businesses across physical stores and digital sales channels from a single dashboard. That includes online marketplaces like Amazon and social media like Facebook by Meta Platforms, but it also includes custom mobile apps and websites. Shopify also provides ancillary solutions for payments, logistics, and financing, and the Shopify App Store includes thousands of third-party integrations.

That turnkey approach to commerce has made Shopify popular with sellers, especially small and medium-sized businesses. Case in point: Shopify is the market leader in e-commerce software in terms of market presence and user satisfaction. But the company is also growing upmarket. Shopify Plus, a more sophisticated platform built for larger brands, is the most popular omnichannel commerce software on the market. That puts the company in a good position.

Ameco Research expects retail e-commerce sales to grow at 14% annually through 2030, and Grand View Research expects wholesale e-commerce sales to grow at 20% annually over the same period. Shopify will benefit from both tailwinds, but it should grow more quickly than either metric suggests due to its strong market presence and broad portfolio of adjacent merchant solutions.

Shopify returned to profitability in the first quarter

Shopify struggled with economic headwinds last year. Sales growth slowed as high inflation hindered consumer spending, and profitability evaporated as ongoing investments put upward pressure on operating costs. But Shopify regained some of its former momentum in the first quarter of this year. Revenue increased 25% to $1.5 billion, an acceleration from 22% growth in the prior year. The company also returned to GAAP profitability with net income of $0.05 per share, up from a loss of $1.17 per share in the prior year.

Investors should also consider two additional metrics. Plus merchants accounted for 34% of monthly recurring revenue, up from 30% in the prior year, indicating that Shopify Plus continues to gain traction with larger brands. Additionally, Shopify reported an attach rate of 3.04%, up from 2.79% in the prior year. Attach rate is defined as revenue divided by gross merchandise volume, and an increasing attach rate means merchants are upgrading to higher subscription tiers and adopting more adjacent services. In other words, Shopify is deepening its relationships with merchants, which makes it more likely those merchants will stick around in the future.

Shopify stock is trading at a reasonable price

Shopify is a compelling commerce partner for businesses of all sizes. Its ability to unify physical and digital sales channels behind a single dashboard gives the company an edge over rivals like Amazon. Moreover, Shopify is effectively a one-stop shop for commerce infrastructure due to its extensive portfolio of adjacent solutions.

The company also has a very capable management team. Shopify has consistently developed new products, and it recently sold its logistics business to Flexport. That was likely a difficult decision given the time and money it invested in the project, but it was the right decision. Shopify can now return to its core competency of building software solutions that simplify commerce. That should give investors confidence.

Shares currently trade at 13 times sales, a bargain compared to the three-year average of 32.3 times sales and a reasonable price to pay given Shopify's strong position in a growing market. That's why this growth stock is worth buying.