It’s been a challenging time for consumers and retailers alike.

Consumers have been grappling with sky-high prices for years, and they’re running out of wiggle room in their budgets.

Don’t miss the move: Subscribe to TheStreet’s free daily newsletter

Inflation seems to be showing signs of slowing down. But with tariff policies looming, the fear is that the cost of consumer goods is soon going to rise. And a broad uptick could batter inflation-plagued consumers who are barely hanging on as it is.

Related: Costco CFO sounds tariff warning members need to hear

Inflation has also hit retailers hard, forcing many popular chains into bankruptcy as a result of sluggish sales.

When living costs are high, consumers have to prioritize. That often means putting essentials like groceries ahead of discretionary purchases.

Elevated interest rates haven’t helped matters, either. Consumers don’t want more debt at a time when it’s expensive to borrow. That, too, has cost many retailers a world of foot traffic over the past year.

Temu and Shein just made Walmart happy.

Image source: Jeff Greenberg/Getty

Walmart is better positioned than most retailers

At a time when costs are up and consumers are being choosy, it’s retailers like Walmart that have the potential to benefit.

Walmart has a few strengths that have allowed it to retain customers at a time when people are broadly cutting back.

Related: Target bets on babies, while Walmart goes all-in on cosmetics

First, Walmart’s shelves are filled with essential products, from groceries to toilet paper to cleaning supplies. Even during periods of leaner spending, these are items consumers can’t do without.

Not only does this foster steady spending at Walmart, but it also gets people in the door. That’s huge, because even when times are tough, it’s easy enough to stop at Walmart for a few grocery items and come out with an impulse purchase or two.

Walmart also has a reputation for affordability. Whereas Target and other competitors aren’t seen as budget retailers, Walmart is known for its more competitive prices.

But Walmart has also faced huge competition from low-cost online retailers like Shein and Temu. Not only do Shein and Temu compete with Walmart for customers’ dollars, but there’s a substantial amount of overlap in the products they carry.

Shein and Temu just threw Walmart a bone

Adjusting to tariff policies is going to be a work in progress for most retailers. And the impact on U.S. retailers is still a bit up in the air.

During the company’s most recent earnings call, CEO Doug McMillon reassured investors that the company was prepared to deal with tariffs and wasn’t overly concerned.

Related: Giant retail store closing leaves consumers shocked

“Tariffs are something we’ve managed for many years, and we’ll just continue to manage that,” he said. “We’ve got a great team. We know how to do that. We can’t predict what will happen in the future, but we can manage it really well. And we’re wired to try and save people money.”

But other retailers may have no choice but to be more reactive to tariffs. And Shein and Temu just showed their hand in that regard.

On April 25, both companies raised their prices to get ahead of tariffs set to take effect imminently.

“Due to recent changes in global trade rules and tariffs, our operating expenses have gone up. To keep offering the products you love without compromising on quality, we will be making price adjustments,” Shein said in a notice posted online.

Temu posted something similar.

These increases are apt to be painful for consumers who relied on Shein and Temu for big savings. But while price increases are bad news for customers, they’re great news for Walmart.

More Retail:

Walmart CEO sounds alarm on a big problem for customersTarget makes a change that might scare Walmart, CostcoTop investor takes firm stance on troubled retail brandWalmart and Costco making major change affecting all customers

If Walmart can manage to keep prices fairly steady as the tariff whirlwind unfolds, it could potentially recapture the market share it had previously lost to its online competitors.

Walmart was already making a concerted effort to cut costs even before tariff policies began to take center stage. Last year, it announced that it would aim to restore the price of many items to pre-inflation levels.

If it keeps up that momentum, the big-box giant has a prime opportunity to shine at a time when many other retailers are likely to struggle.