Shopify gives store owners an easy way to build online shops — but if you want your site to look truly professional, you’ll need a few custom code tweaks.
With some simple Liquid, CSS, and JavaScript, you can transform your theme from basic to beautiful. In this tutorial, we’ll go through 10 of the most-searched Shopify custom codes that make your store more engaging, faster, and conversion-friendly.
1️⃣ Sticky Header That Follows You While Scrolling
Keep your navigation visible at all times.
Code Example:
header {
position: sticky;
top: 0;
z-index: 1000;
background: #fff;
}
Why It Works:
Customers can navigate anywhere without scrolling up — smoother UX, especially on mobile.
2️⃣ Custom “Add to Cart” Button Style
Make your call-to-action more eye-catching.
Code Example:
button.add-to-cart {
background-color: #f68b1e;
color: #fff;
padding: 12px 25px;
border-radius: 5px;
transition: all 0.3s;
}
button.add-to-cart:hover {
background-color: #222;
}
Why It Works:
A styled button increases click-through and matches your brand’s look.
3️⃣ Countdown Timer for Flash Sales
Create urgency and boost conversions.
Code Example:
<div id="timer"></div>
<script>
var countDownDate = new Date("Nov 30, 2025 23:59:59").getTime();
var x = setInterval(function(){
var now = new Date().getTime();
var distance = countDownDate - now;
var days = Math.floor(distance / (1000*60*60*24));
var hours = Math.floor((distance%(1000*60*60*24))/(1000*60*60));
var minutes = Math.floor((distance%(1000*60*60))/(1000*60));
document.getElementById("timer").innerHTML = days+"d "+hours+"h "+minutes+"m ";
if(distance<0){clearInterval(x);document.getElementById("timer").innerHTML="EXPIRED";}
},1000);
</script>
Why It Works:
Limited-time offers push shoppers to act quickly.
4️⃣ Back-to-Top Button
A simple way to improve navigation.
Code Example:
<button id="topBtn">↑</button>
<script>
const btn=document.getElementById('topBtn');
window.onscroll=()=>{btn.style.display=window.scrollY>300?'block':'none';};
btn.onclick=()=>window.scrollTo({top:0,behavior:'smooth'});
</script>
Why It Works:
Makes browsing longer pages easier, especially on mobile.
5️⃣ Dynamic Year in Footer
Keep your copyright current automatically.
Code Example:
<p>© {{ "now" | date: "%Y" }} {{ shop.name }}. All Rights Reserved.</p>
Why It Works:
No need to update the footer every new year.
6️⃣ Product Page Tabs (Description, Reviews, Shipping)
Organize long content neatly.
Code Example:
<div class="tabs">
<button onclick="openTab('desc')">Description</button>
<button onclick="openTab('reviews')">Reviews</button>
<div id="desc" class="tab-content">{{ product.description }}</div>
<div id="reviews" class="tab-content" style="display:none;">{{ product.metafields.reviews }}</div>
</div>
<script>
function openTab(id){
document.querySelectorAll('.tab-content').forEach(t=>t.style.display='none');
document.getElementById(id).style.display='block';
}
</script>
Why It Works:
Clean look, easy navigation through product information.
7️⃣ Quick View Popup for Products
View item details without leaving the page.
Code Example:
<button class="quick-view" data-handle="{{ product.handle }}">Quick View</button>
<script>
document.querySelectorAll('.quick-view').forEach(btn=>{
btn.addEventListener('click',()=>{
const h=btn.dataset.handle;
fetch(`/products/${h}.js`).then(r=>r.json()).then(p=>{
alert(p.title + " - $" + p.price/100);
});
});
});
</script>
Why It Works:
Keeps shoppers on the collection page — improves browsing flow.
8️⃣ Sticky Add-to-Cart Bar
Keep your CTA visible while scrolling.
Code Example:
.sticky-cart {
position: fixed;
bottom: 0;
width: 100%;
background: #f68b1e;
text-align: center;
padding: 10px;
}
Why It Works:
Makes checkout always one click away.
9️⃣ Lazy Loading Images
Speed up your store’s performance.
Code Example:
<img src="{{ product.featured_image | img_url: '600x600' }}" loading="lazy" alt="{{ product.title }}">
Why It Works:
Loads images only when needed — improves SEO and speed scores.
🔟 Announcement Bar for Promotions
Highlight deals or shipping offers at the top.
Code Example:
<div class="announcement">🔥 Free Shipping on Orders Over $50!</div>
<style>
.announcement{background:#f68b1e;color:#fff;text-align:center;padding:8px;}
</style>
Why It Works:
Draws attention to special offers and improves engagement.
🎯 Final Thoughts
Adding custom code snippets to your Shopify theme can completely change your store’s design and performance — without hiring a full developer team.
Start by experimenting with these 10 most-searched codes to improve your design, then move to advanced customization (like smart search, dynamic pricing, and packaging calculators) in our upcoming tutorials.