- Published on
Removing Sold-Out Variants in Shopify Making Shopping a Breeze Again
- Authors
- Name
- Entaice Braintrust
Removing Sold-Out Variants in Shopify: Making Shopping a Breeze Again
Let me take you back to a moment in my life, a whimsical afternoon spent thumbing through the aisles of an impossibly cluttered flea market. The thrill of the hunt was palpable; treasures were buried everywhere, some covered by ancient blankets or hidden beneath tables. However, to my dismay, many of the coveted trinkets were off limits—tantalizingly displayed but long since claimed. This, my friends, is exactly what your customers are facing when they encounter sold-out variants on your Shopify store. Just like those enticing but unattainable flea market finds, out-of-stock options only serve to frustrate and disappoint.
Keeping those unavailable variants front and center is like dangling a chocolate chip cookie in front of someone who's on a diet. So, let's alleviate this predicament, sparing your cherished customers any unnecessary heartache while they navigate your digital storefront. Let's transform that shopping spree into a joyous experience by hiding sold-out variants. It’s easier than you might think!
Step 1: Channel Your Inner Code Whisperer
Sometimes we must roll up our sleeves and tinker under the hood of our virtual carriages. The Pipeline theme you're using doesn’t exactly volunteer the option to hide these zero-stock variants, so we need to get a little technical.
Code Diving: Here’s the Game Plan
Access Shopify Code Editor: Picture yourself donning a code sleuth’s hat, Sherlock style. Head over to your Shopify admin, and on your left panel, tap ‘Online Store’ and then ‘Themes.’ A drop-down list shall appear, choicily select ‘Actions’ and then ‘Edit Code.’
Locate the Culprit (aka the File): We need to find the product template. Scroll down until your eyes meet with
Sections
and click onproduct-template.liquid
—or it could masquerade asproduct.liquid
. Essentially, you’re Indiana Jones locating the precious lost artifact.Champion the JavaScript Section: Wield your keyboard like a mystical wand and cast your spell (or paste your code), specifically after the line of JavaScript responsible for handling variant selections. Usually, this involves locating the section that mentions
new Shopify.OptionSelectors
. Right below, nestle in the following snippet:
var originalSelectorFunc = Shopify.OptionSelectors.prototype.buildSelector;
Shopify.OptionSelectors.prototype.buildSelector = function(selectorId, parent) {
originalSelectorFunc.apply(this, arguments);
var select = document.getElementById(selectorId);
if (select) {
var options = select.querySelectorAll('option');
options.forEach(function(option) {
if (option.getAttribute('data-available') === 'false') {
option.style.display = 'none';
}
});
}
}
And just like a wizard with a dash of potion—voila! Now those dormant variants shall remain hidden, out of sight where they ought to be for the good of your customers.
Step 2: Testing Our Masterpiece
Once we’ve successfully weaved our solution into the theme, we must put on our virtual stethoscope and test to ensure everything breathes as it should. Imagine being in your customer’s shoes—navigate through your shop and witness the absence of those pesky sold-out options. Their disappearance should feel refreshingly neat, much like an organized kitchen drawer where everything is finally in its rightful place.
Step 3: Celebrating Our Small Victory
Here we are, sitting together on this reflective bench. We didn't just code; we delivered magic. Our joint effort has now transformed the once-confounding landscape of your Shopify store into a more navigable, engaging experience. Shoppers arrive, browse, select the available variants, and leave with precisely what their hearts desire—no more unachievable dreams or fruitless clicking.
Why stop here? Share this newfound knowledge with fellow store owners, perhaps at your next neighborhood storytelling circle or an impromptu coffee shop meetup. Transform their bewildered customers into loyal enthusiasts.
And there we have it, a tale of discovery, a sprinkle of geek charm—our venture into Shopify’s underbelly now concludes with a happy, available-ending. Until our next digital escapade, may your shopping journeys always be clutter-free and your cookies never untouchable.