Walmart (NYSE:WMT) has rapidly expanded its online grocery service following Amazon's (ASDAQ:AMZN) aggressive move into the category. Walmart plans to expand its delivery service to 100 metro areas by the end of this year. The service was only available in six markets as of March 2018.

This article originally appeared in The Motley Fool. 

To its credit, Walmart has made good progress on its expansion plans. Delivery is now available in nearly 50 markets, and delivery was available from over 320 stores by the end of July.

Walmart has tried several approaches to grocery delivery, including (failed) partnerships with Uber and Lyft and trying to convince its workers to deliver items on their way home  from a shift. Now Walmart is testing its own fleet of independent delivery drivers similar to Amazon's Flex program. Amazon uses Flex to deliver items purchased through Prime Now, its 2-hour delivery service available to Prime members in select markets. It's also using those drivers to deliver grocery orders from Whole Foods, a program it plans to expand nationwide in the near future.

Walmart Clothes are displayed during the opening of a new Walmart Store in San Salvador, El Salvador, Aug. 21, 2018. Photo: REUTERS/Jose Cabezas

Can Walmart handle grocery delivery?

Walmart's efforts to expand its online grocery ordering options have put a lot of pressure on its profits. Last quarter, Walmart's overall operating margin fell to 4.5 percent from 4.8 percent in the second quarter last year. Walmart U.S. operating profits, specifically, climbed by $0.1 billion, but the margin fell about 20 basis points to 5.4 percent.

As Walmart expands grocery delivery, it could put further pressure on its operating margin. Unlike Amazon, Walmart is charging shoppers for each delivery. (Amazon includes same-day grocery delivery as part of Prime). The $9.95 fee Walmart charges has to cover the driver delivery fee, paying workers to pick and pack produce, and everything else that goes along with processing online orders. Walmart is also paying a third party to recruit, screen, and handle payment for independent contractors. With a promise of drivers being able to earn over $20 per hour delivering for Walmart, depending on the number of orders delivered, there might not be a lot left over in terms of profit.

Amazon has always been willing to participate in margin-destroying activities in an effort to take market share and scale its operations. Its strategy with Whole Foods seems to be no different, and that's going to impact the biggest players -- such as Walmart -- the most as they try to stay ahead.

Groceries are essential to Walmart's business

Over half of Walmart's revenue comes from groceries. As more shopping shifts online, Walmart has moved quickly to enable online grocery ordering for most of its stores. You can now order groceries for pickup at over 1,800 Walmart locations around the country.

What makes groceries such a valuable market for Walmart is that it brings customers into its stores, where they're likely to pick up a few things from the non-grocery side of the store as well. When people order groceries online and pick them up curbside (or have them delivered to their door), Walmart loses that benefit of its massive grocery business.

Amazon's strategy of integrating Whole Foods delivery and pickup into its Prime membership provides a much greater benefit to Amazon. Prime members generally spend more on Amazon than non-members since there's a bit of a sunk-cost factor pushing them to shop more.

There's still time for Walmart to develop ways to encourage online grocery shoppers to also buy non-grocery items (either online or in stores). It could offer a subscription service, special discounts, or simply offer more convenience items as part of its delivery service (the kind of products available through Prime Now).

However, until Walmart can figure out a way to make online grocery orders benefit the full portfolio of items for sale at Walmart, its efforts to deliver groceries to customers' doors and expand their pickup options will only cut into its profit margin.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Adam Levy  owns shares of Amazon. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy .