Skip to content

Instantly share code, notes, and snippets.

View unofficialshopify's full-sized avatar

unofficialshopify

View GitHub Profile
@unofficialshopify
unofficialshopify / How to add an announcement bar in shopify?
Last active September 7, 2018 08:09
How to add an announcement bar in shopify?
What is Announcement bar?
An announcement bar is a one- or two-sentence announcement space at the very top of a website. It pops into the top. You can also remove or close if you needed.
Use of Announcement.
Now these days eCommerce websites have many announcement. So they need to notify user about announcements. Like -
@unofficialshopify
unofficialshopify / How to get a visitor’s location and redirect them to right store for Shopify
Last active December 8, 2022 05:58
How to get a visitor’s location and redirect them to right store for Shopify
These days some business have online store in different country with the same name. They have different URL for different country but they are facing a problem that how they can redirect store url based on IP address for eg.
www.domain.us – Customers in the United States
www.domain.ca – Customers in the Canada
www.domain.com – Customers in rest the world
This article guide you to do that.
{% if settings.unofficialshopify_enable_effect %}
<script>
var snowmax={{settings.unofficialshopify_number_of_snowflakes}};
var snowcolor=new Array("#aaaacc","#ddddff","#ccccdd","#f3f3f3","#f0ffff");
var snowtype=new Array("Times","Arial","Times","Verdana");
var snowletter="*";
var sinkspeed={{settings.unofficialshopify_speed_of_sinking}};
var snowmaxsize={{settings.unofficialshopify_maximum_size_snowflakes}};
{% comment %} Width of results box {% endcomment %}
{% assign results_box_width = '242px' %}
{% comment %} Background color of results box {% endcomment %}
{% assign results_box_background_color = '#ffffff' %}
{% comment %} Border color of results box {% endcomment %}
{% assign results_box_border_color = '#d4d4d4' %}
<script>
$(function() {
// Current Ajax request.
{% layout none %}
{% capture results %}
{% for item in search.results %}
{% assign product = item %}
{
"title" : {{ product.title | json }},
"url" : {{ product.url | within: product.collections.last | json }},
"thumbnail": {{ product.featured_image.src | product_img_url: 'thumb' | json }}
}
{% unless forloop.last %},{% endunless %}
@unofficialshopify
unofficialshopify / show-hide-text.htm
Last active September 19, 2016 06:26
How to toggle divs,paragraph or text box when we select a varaint. Basic idea behind this like switch image when we select a variant.
// for paragraph
<p class="description" id="24290057091">Description for variant 1</p>
<p class="description" id="24290057006" style="display: none;">Description for variant 2</p>
<p class="description" id="24290057089" style="display: none;">Description for variant 3</p>
// for div
<div class="description" id="24290057091">Description for variant 1</div>
<div class="description" id="24290057006" style="display: none;">Description for variant 2</div>
@unofficialshopify
unofficialshopify / search-box.liquid
Created September 17, 2016 05:46
How to add search bar or box in shopify
<form action="/search" method="get" class="input-group search-bar" role="search">
{% comment %}<input type="hidden" name="type" value="product">{% endcomment %}
<input type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'Search'}}" class="input-group-field" aria-label="{{ 'Search'}}">
<span class="input-group-btn">
<button type="submit" class="btn icon-fallback-text">
<span class="icon icon-search" aria-hidden="true"></span>
<span class="fallback-text">{{ 'general.search.submit' | t }}</span>
</button>
</span>
</form>
@unofficialshopify
unofficialshopify / remove-sold-out.liquid
Created September 15, 2016 05:06
Remove sold-out variants. Only works for products that have one option. It won't work with products that have two or three options, like Size and Color.
{% if product.options.size == 1 %}
<script>
var $addToCartForm = $('form[action="/cart/add"]');
if (window.MutationObserver && $addToCartForm.length) {
if (typeof observer === 'object' && typeof observer.disconnect === 'function') {
observer.disconnect();
}
var config = { childList: true, subtree: true };
var observer = new MutationObserver(function() {
{% for variant in product.variants %}
@unofficialshopify
unofficialshopify / notifygist.htm
Last active September 14, 2016 05:59
In this tutorial we are going to add a notify/reminder form on product page when product is unavailable or sold out so customer just email to website owner for remind the customer that product is available now.
{% unless product.available %}
<div id="sold-out">
{% form 'contact' %}
{% if form.posted_successfully? %}
<p class="accent-text">Thanks! We will notify you when this product becomes available!</p>
{% else %}
<p>Click <a id="notify-me" href="#"><strong>here</strong></a> to be notified by email when {{ product.title }} becomes available.</p>
{% endif %}
{% if form.errors %}
<div class="error feedback accent-text">
@unofficialshopify
unofficialshopify / home-blog.liquid
Last active September 8, 2016 07:03
How to add shopify blog on frontpage or home page
<div>
<h1>From the Blog</h1>
{% for article in blogs.news.articles limit: 6 %}
<h3><span> >> {{ article.title | link_to: article.url }}</span></h3>
<p>
<span>{{ article.created_at | date: "%d/%m/20%y" }}</span><span> <span> | </span> by {{ article.author }} </span>
</p>
</div>