The solution I use is code injection via Javascript in the footer. For the specific product I want to limit to 5 items, I use the following:
document.addEventListener('DOMContentLoaded', (event) => {
// data-item-id = the product page's qty div
// If someone enters more than 5, the value will revert to 5.
// Be sure to add instructions for the qty limit in the product description.
const quantityInput = document.querySelector('.product-quantity-input[data-item-id="6669115df767f5244f9d1f8d"] input[type="number"]'); quantityInput.addEventListener('input', () => {
if (quantityInput.value > 5) { quantityInput.value = 5; }
});
});