Skip to content

Instantly share code, notes, and snippets.

View raihan004's full-sized avatar
🏠
Working from home

MH Raihan raihan004

🏠
Working from home
View GitHub Profile
@raihan004
raihan004 / gist:133b534a15ac07d2ee488140267bea14
Created April 30, 2018 12:33 — forked from kyleaparker/gist:5949872
Shopify - Show total savings on cart page
{% assign total_saving = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price > item.variant.price %}
{% capture saving %}{{ item.variant.compare_at_price | minus: item.variant.price }}{% endcapture %}
{% assign total_saving = saving | plus: total_saving %}
{% endif %}
...rest of cart code within for loop
{% endfor %}
Display saving:
@raihan004
raihan004 / available-colors.liquid
Created June 18, 2018 01:19 — forked from carolineschnapp/available-colors.liquid
Snippet that says 'also available in colors x and y' on the collection page when a product is available in more than 1 color. To include in product-loop.liquid, or product-grid-item.liquid.
{% comment %}
Do we have a Color option?
If so, is it the first, second or third option of that product?
We will need to access values so we need that color index.
{% endcomment %}
{% assign has_color = false %}
{% assign color_option_index = 0 %}
{% for option in product.options %}
{% assign downcased_option = option | downcase %}
@raihan004
raihan004 / index.html
Created June 24, 2018 20:56 — forked from cole007/index.html
Shopify API filter for product prices
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title>Shopify filtering Boilerplate</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="_assets/css/style.css">
</head>
<body>
@raihan004
raihan004 / random.js
Created July 11, 2018 18:47 — forked from kerimdzhanov/random.js
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@raihan004
raihan004 / html
Last active May 12, 2020 07:48
Quantity
<label for="Quantity">Quantity</label>
<div class="product-quantity product-single__quantity {% unless section.settings.product_quantity_enable %} is-hidden{% endunless %}">
<input value="-" class="qtyminus" field="Quantity" type="button">
<input id="Quantity" name="quantity" value="1" min="1" max="10" data-product-qty="" class="cart__quantity-selector quantity-selector" type="text">
<input value="+" class="qtyplus" field="Quantity" type="button">
</div>
@raihan004
raihan004 / bootstrap-pagination.liquid
Last active August 14, 2018 23:44 — forked from kyleaparker/gist:7588995
Shopify: Show all numbers in pagination
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item {% unless paginate.previous.is_link %} disabled {% endunless %}">
<a class="page-link" href="{{ paginate.previous.url }}" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">{{ 'general.pagination.previous' | t }}</span>
</a>
</li>
{% assign count = paginate.pages %}
{% for part in paginate.parts %}
var pSettings={progressBg:"#23468c",progressBg2:"#d9e3f7",highDemandText:"An item you ordered is in high demand. No worries, we have reserved your order.",discountText:"Enter your discount code here",whyUsImg1:"",whyUsTitle1:"The course helped me put safety back in my daily routine not only in the workplace but at home aswell.",whyUsText1:"-- Rob H. ",whyUsImg2:"",whyUsTitle2:"It made me aware the quickest way to do things is not always the safest way. That you need to be aware of your surroundings and surroundings of others ",whyUsText2:"-- Dave P. ",whyUsImg3:"",whyUsTitle3:"Easy to operate without being a computer expert. ",whyUsText3:"-- Peter S. "};function crC(e,t,s){if(s){var i=new Date;i.setTime(i.getTime()+60*s*1e3);var n="; expires="+i.toUTCString()}else n="";document.cookie=e+"="+t+n+"; path=/"}function rdC(e){for(var t=e+"=",s=document.cookie.split(";"),i=0;i<s.length;i++){for(var n=s[i];" "==n.charAt(0);)n=n.substring(1,n.length);if(0==n.indexOf(t))return n.substring(t.length,n.length)}return n
@raihan004
raihan004 / product-template.liquid
Created September 22, 2018 11:23
how-to-skip-the-cart-page-with-the-carthook-checkout
{% comment %}
-- documentation
-- https://developers.carthook.com/docs/how-to-skip-the-cart-page-with-the-carthook-checkout
{% endcomment %}
<form action="/checkout" style="display: none;">
<a href="/checkout" name="checkout" style="display: none;"></a>
</form>
@raihan004
raihan004 / product.js
Created October 28, 2018 20:33
@shopify/theme-product
this.Shopify = this.Shopify || {};
this.Shopify.theme = this.Shopify.theme || {};
this.Shopify.theme.product = (function (exports) {
'use strict';
/**
* Find a match in the project JSON (using a ID number) and return the variant (as an Object)
* @param {Object} product Product JSON object
* @param {Number} value Accepts Number (e.g. 6908023078973)
* @returns {Object} The variant object once a match has been successful. Otherwise null will be return
@raihan004
raihan004 / gulpfile.js
Created November 9, 2018 17:26 — forked from derekmorash/gulpfile.js
Gulp task to compile Shopify Liquid tags in SASS with Autoprefixer
var gulp = require('gulp');
var sass = require('gulp-sass');
var replace = require('gulp-replace');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
gulp.task('compilesass', function() {
// root SASS file (contains all your includes)
return gulp.src('./sass/style.scss')
// compile SASS to CSS