Skip to content

Instantly share code, notes, and snippets.

View unofficialshopify's full-sized avatar

unofficialshopify

View GitHub Profile
@unofficialshopify
unofficialshopify / repeat-order.liquid
Last active May 10, 2018 14:01
How to add last or past orders in the cart in shopify. Add this liquid code under snippets folder
{% if order.line_items.size > 0 %}
<p>
<button class="btn place-same-order">Add order to cart</button>
<script>
(function(){
/* Check for the button */
var buttonOrder = document.getElementsByClassName('place-same-order') || false;
if(!buttonOrder){ return }
/* Setup the order object. Extend this as needed. */
var order = {
@unofficialshopify
unofficialshopify / share shopify product on whatsapp
Last active February 19, 2021 23:31
Share your shopify product on whatsapp
<a href="whatsapp://send?text=Hey Checkout this {{ product.title | escape }} {{ shop.url | escape }}{{ product.url | escape }}"> Share on Whatsapp </a>
@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>
@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 / 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 / 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 / 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>
{% 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 %}
{% 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.
{% 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}};