Skip to main content

Making an item "Sold Out" in Gravity Forms

Gravity Forms for Word Press  is pretty awesome, especially with integration with Stripe for selling things. The only problem I've run into is when I have a thing with a limited quantity and it sells out. There's a great snippet if you want to install some extra php. Best practices would be to use the snippet. I strongly encourage you to do so -- it's a better solution.

But if you want something faster to implement that can be installed by a developer who doesn't have the ability to upload/create php, you're going to need to use Javascript.

So adding a little javascript gets us there pretty easily:


<script type="application/javascript">
//get the existing quanity field you want to hide
var myfield=document.getElementById('ginput_quantity_12_7');
//create a span for the message
var soldoutSpan = document.createElement('span')
//make the message
soldoutSpan.innerHTML = '<b>SOLD OUT</b>';
//add the message AFTER the quantity field
myfield.parentNode.appendChild(soldoutSpan);
//hide the quantity field (you could delete it if you wanted to)
myfield.style.display="none";
//make your text red
soldoutSpan.style.color="red";
</script>

Of course you want to make sure you are validating your inputs for obvious reasons.

 

Comments

Popular posts from this blog

Preventing accidental large deletes.

Instructions for Developers on Using the safe_delete Stored Procedure To enhance safety and auditability of delete operations within our databases, we have implemented a controlled deletion process using a stored procedure named safe_delete . This procedure relies on a temporary table ( temp_delete_table ) that lists complete records intended for deletion, not just their IDs. This approach helps prevent accidental deletions and provides a traceable audit log of delete actions. Why We Are Doing This Controlled Deletions : Centralizing delete operations through a stored procedure reduces the risk of erroneous or unauthorized deletions. Auditability : Using a temporary table to store complete records before deletion allows for an in-depth review and verification process, enhancing our ability to confirm and audit delete operations accurately. Security : Restricting direct delete permissions and channeling deletions through a specific proced...
 In software engineering, accumulating code behind a release wall is akin to gathering water behind a dam. Just as a dam must be built higher and stronger to contain an increasing volume of water, the more code we delay releasing, the more resources we must allocate to prevent a catastrophic flood—major bugs or system failures—while also managing the inevitable trickles—minor issues and defects. Frequent, smaller releases act like controlled spillways, effectively managing the flow of updates and reducing the risk of overwhelming both the system and the team. The ideal of ci/cd may not be achievable for all teams, but smaller and faster is always better.

So You're Looking for Work in Tech

So You're Looking for Work in Tech It's a more competitive market than it's ever been—but don't despair! There are still plenty of jobs out there for humans who can demonstrate insight, creativity, and the ability to execute. Here's a practical guide to help you prove you can do just that. 0. File for Unemployment (If Applicable) If you were recently laid off, file for unemployment right now . This won’t help your job search directly, but it will help you financially. Get that support—you earned it. 1. Buy a Domain and Invest in Yourself If you don’t own a domain, buy one today. Get a GSuite (Google Workspace) account and start using a professional email like yourname@yourdomain.com . Avoid using email services like GoDaddy, Zoho, or Office365. Google is the gold standard—invest in the best. 2. Hire Yourself Give yourself a tech project—because this is your job now. Choose a project that will add value to your life while forcing you to learn new ...