Shopify (SHOP -5.62%) has gone on the offensive again -- but this time, in the wake of the post-pandemic throttling of the e-commerce industry, Shopify's pioneering efforts are in right-sizing its operations.

Earlier this year, the company announced a sizable layoff of employees and sold its logistics business for a hefty loss (following the acquisition of Deliverr in 2022). The latter, in particular, was a bold move to try to reverse what management quickly came to believe was a mistaken investment.

Through it all, Shopify reported a 31% year-over-year increase in revenue in the second quarter of 2023 as it continues its relentless expansion. But some investors are still worried about the company's losses and contend the stock is overpriced. But is it really?

Three items to monitor

Shopify reported a very steep generally accepted accounting principles (GAAP) operating loss in Q2 2023 of $1.64 billion on revenue of $1.69 billion. Ouch!

Shopify has become something of a poster child for inflated valuation and loss-generating businesses common during the 2021 stock market cloud-computing boom. And it clearly still has work to do to get itself in tip-top financial shape. However, it's important to consider a few items, a couple of them one-time expenses, obscuring Shopify's true ability to operate sustainably.

First is the sale of the logistics business, including Deliverr. Back in 2019, when Shopify announced its Fulfillment Network, there was excitement (from myself included) about the long-term potential to offer small businesses some of the same shipping capabilities as Amazon. But it became increasingly clear that building and operating warehouses is a low-margin game and one that didn't jive with Shopify's software-driven business model.

It's a painful exit, but the band-aid is being ripped off quickly. Shopify announced a $1.34 billion impairment loss on the sale of logistics to start-up Flexport, with Shopify boosting its investment stake in the private company to 17% (more on that momentarily) in the process. At least this $1.34 billion impairment is now in the rearview mirror, and Shopify can get back to focusing on higher-margin software -- including partnering with third-party shipping services via software integration.

Second, Shopify incurred severance expenses in Q2, also a one-time event. Specifically, $148 million of cash expenses and $165 million in non-cash employee stock-based compensation (SBC) were reported to close out employee incentives left from the logistics sale. As for the SBC, Shopify reported $280 million in total in the second quarter, but when subtracting the $165 million accelerated stock payout, total SBC would have been $115 million -- a reduction from the $139 million in SBC reported a year ago.

And third, there are equity investments, which now include more debt convertible to stock in Flexport and also holdings in Global-e Online and Affirm Holdings. From June 2022 to June 2023 (the end of Shopify's Q2), Global-e is back on the mend, while Affirm is still down. In total, Shopify reported a gain in equity value of $281 million. For the sake of getting a pulse on the company's true ability to turn a profit from its own business, let's subtract that, too.

With these items considered, Shopify actually reported an adjusted operating profit margin of 9% in Q2 2023 and an adjusted net income profit margin of 11%. Free cash flow in the quarter was $97 million. Again, there's still work to do, but things aren't as bad at Shopify as they appear on the surface.

Is the stock overpriced?

Now, how about the stock valuation? Shares are again pushing into premium territory at 11 times trailing-12-month sales, perhaps a bit too elevated a price to pay for a company still fighting its way to GAAP profitability. After all, mighty Amazon trades for just 2.6 times trailing-12-month sales. But is it really an egregious price tag for Shopify?

Given how messy Shopify's financials are, it's difficult to say exactly. However, I'm inclined to believe it isn't that ludicrous a premium, given the company is once again forecasting 20%-plus revenue growth for its next quarter (which would put the Q3 total at about $1.6 billion). Additionally, management said free cash flow in Q3 2023 would be higher than the free cash flow generated the entire first half of the year (which, for the record, was $183 million).

That implies Shopify is on a path to exceed 10% free-cash-flow margins on full-year revenue of about $7 billion and is now putting one-time non-cash expenses behind it. The company's market cap is currently $71 billion, so this is certainly a premium-priced stock (let's call it 100 times expected full-year 2023 free cash flow).

Given the current situation, I'm not adding to my Shopify position. However, I wouldn't say the sticker price is all that shocking, especially if you're working under the assumption that the company can continue growing its sales by double-digit percentages and expand its profit margins. With Shopify refocusing on e-commerce software services, that certainly isn't an absurd expectation.

I'm a Shopify fan and still plan to hold for the ultra-long term.