NEW YORK (AP) — Walmart reported higher sales in its fiscal third quarter as more Americans look for deals, particularly in groceries, in the face of high inflation.

The nation’s largest retailer raised its full-year earnings outlook on the strong quarterly results.

Also on Tuesday, Walmart agreed to pay $3.1 billion to settle lawsuits nationwide over the impact of prescriptions its pharmacies filled for powerful prescription opioid painkillers. The agreement must still be approved by 43 states, but company shares jumped more than 7% in midday trading.

The settlement is similar to those already announced by CVS Health and Walgreen Co. Walmart said in a statement that it strongly disputes the allegations and that the settlement doesn’t include any admission of liability.

Walmart is among the first major retailers to report fiscal third-quarter results and is considered a barometer of spending given its size, so analysts carefully parse through the data. Home Depot reported on Tuesday that revenue and profit easily topped expectations. But investors were spooked after the nation’s largest home improvement retailer stuck by projections it put out earlier this year.

Walmart CEO Doug McMillon told analysts on a call that the holiday season will be more promotional and it will be prepared to react to any stepped up discounting. Right now, the fate of the holiday shopping season is still unclear.

“It’s still mid-November and there’s a lot of room between now and the end of the holidays including new year,” McMillon said. “This will be one of those years where we’re watching sales closely up until the last minute of Christmas Eve.”

Target is slated to report results on Wednesday, while Macy’s and Kohl’s are among the merchants set to report financial performance on Thursday.

Amazon said late last month that it returned to profitability in its third quarter after two straight quarters of losses, but it also posted weaker-than-expected revenue and issued disappointing projections for the current quarter.

Like many other retailers, Walmart benefited in the early days of the pandemic as shoppers spent heavily to furnish their homes or buy casual clothing as they stayed indoors.

But spending has since shifted away from casual clothes and TVs to necessities. Americans have remained mostly resilient even with inflation near four-decade highs. Yet surging prices for everything from mortgages to rent have increased the anxiety level, while offering less wiggle room to spend on electronics and new clothes.

That shift away from discretionary goods has hurt profits since general merchandise carries higher profit margins. The dramatic swing has also left Walmart and other stores with an excess of items that shoppers don’t want — and that they need to clear.

Walmart said it is trying to control prices where it can and noted that the cost for a basket of staples for a traditional Thanksgiving meal is the same as a year ago. It has also made significant headway in reducing inventory.

Walmart noted that shoppers are trading down to private brands in baby items and baking goods, among other categories. It is also seeing wealthier customers. About three-quarters of Walmart’s market share gains in food came from customers with annual household incomes of $100,000 or more, the company said.

“With the cost of everyday items still stubbornly high in too many categories, more customers and members are choosing us for the value and assortment we’re known for,” McMillon told analysts on a call following the release.

McMillon noted the company is working to retain higher-income shoppers when inflation ebbs by making sure that the groceries and clothing assortments are fresh.

Walmart said it’s also looking to newer businesses like its third-party marketplace and advertising to drive growth. In the U.S., Walmart’s marketplace now offers 370 million different types of items, up from 50% from the second quarter.

Walmart, based in Bentonville, Arkansas, lost $1.79 billion, or 66 cents per share, for the quarter ended Oct. 31, including the opioid settlement. That compares with a profit of $3.11 billion, or $1.11 per share. Adjusted profit totaled $1.50 per share, which handily beat analysts’ estimates for $1.32 per share.

Sales rose 8.7% to $152.81 billion, above estimates of $147.7 billion, according to FactSet.

Comparable sales — those from established stores and online operating over the past 12 months — rose 8.2%, higher than the 6.5% in the previous quarter. Online sales rose 16%.

The company said that its adjusted full-year earnings per share is now expected to decline by 6% to 7%, instead of the 9% to 11% it predicted in August.

The company also announced a new $20 billion share-buyback authorization. It ended the third quarter with roughly $1.9 billion left.

Shares rose $10.15 to $148.60 at midday trading.

_______

AP Writer Geoff Mulvihill in New Jersey and AP Business Writer Michelle Chapman in New York contributed to this report.

____

Follow Anne D’Innocenzio: http://twitter.com/ADInnocenzio