Yes, they do, unless it's consignment model, which wasn't usually the case for boxed software. The retail sale happens after retail has made the purchase. It’s obviously usually at a higher price than the retailer paid, but they don't take a cut of what the vendor is asking for the software. They pay whatever the vendor (or, often in real retail, a distributor that sits in between) is offering to sell the product for, in advance, and takes a risk that they will be able to sell the units they have purchased at a higher price.
It's structurally not at all the same as what an app store does, where it pays no one, anything (indeed, often charges an access fee up front to the seller) before a sale is made, and then pockets a share of the sale at no risk.
Whether that happens in one simultaneous transaction or two different ones doesn't really make a difference to how much the developer gets paid in the end, which is less with the retail store model compared to the current digital storefront model.
Let's also not forget that Steam launched with a 30% cut a full 5 years before the App Store ever existed, so it's not like Apple dictated this price, they were following industry norms at the time.
Apple act as a middleman and and add on their fees, with absolutely no risk to themselves.
They're very different business models.
https://en.m.wikipedia.org/wiki/Remaindered_book
https://en.m.wikipedia.org/wiki/Cut-out_(recording_industry)
I can't find anything current for boxed software (for obvious reasons), but boxed video and board games cannot be returned unless the retailer has a special deal with the publisher (rare).
https://www.polygon.com/2017/7/17/15974096/what-it-costs-to-...
https://www.ign.com/articles/2014/03/05/inside-the-secret-wo...
https://www.reddit.com/r/boardgames/comments/6asinu/can_reta...
And retail doesn't charge "0%" on boxed products, or they would go out of business. Logistics, distribution, and store markup all add up to the final price of the product on the shelf.