For the U.S. the answer to the question is Sections 2-713 and 2-715 of the Uniform Commercial Code that has been adopted by all States and Territories. Section 2-713 Identifies Buyers damages as "the difference between the market price at the time for tender under the contract and the contract price" together with any incidental or consequential damages under Section 2-715, but less expenses saved in consequence of the seller's breach. Section 2-15 specifically defines Incidental damages as "expenses reasonably incurred in inspection, receipt, transportation and care and custody of goods rightfully rejected, any commercially reasonable charges, expenses or commissions in connection with effecting cover and any other reasonable expense incident to the delay or other breach".
When you have a contract in the U,S, that limits recovery to only direct damages, that language overrides only that portion of that section of the UCC that allows for incidental and consequential damages. That leaves you with the remaining damages specified in Section 2-713, which is the difference in contract price (which is the cost of cover).
The United Nation's Convention on Contracts for the International sale of Goods (CISG) in force in many countries that adopted it specifically provides for cover damages. Under its article 75, a party may recover the difference between the contract price and the price for the substitute transaction. This is in addition to any other damages including loss of profit, suffered by the party as a consequence of the breach, limited to a foreseeability requirement (CISG. art. 74). If a party (be it seller or buyer) decided not to enter into a substitute transaction, it may obtain current price damages, estimated as of the time of breach (CISG art. 76).
In both situations contract drafters need to understand that when you are dealing with an applicable law that has adopted either the UCC or CISG, if within your limitation of liability you fail to specifically exclude incidental, consequential damages, those laws would be applied and you would be subject to direct, incidental and consequential damages (which would include lost profits).