Skip to content

Instantly share code, notes, and snippets.

View atikju's full-sized avatar

MD. Atiqur Rahman atikju

View GitHub Profile
@atikju
atikju / functions.php
Created October 13, 2016 04:13 — forked from mikejolley/functions.php
WooCommerce - Hide price suffix when product is not taxable.
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'woocommerce_get_price_suffix', 'custom_woocommerce_get_price_suffix', 10, 2 );
function custom_woocommerce_get_price_suffix( $price_display_suffix, $product ) {
if ( ! $product->is_taxable() ) {
return '';
@atikju
atikju / savings.liquid
Last active October 2, 2018 17:18
Shopify - Display Total Savings on Cart
{% assign total_saving = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price > item.variant.price %}
{% assign saving = item.variant.compare_at_price | minus: item.variant.price | times: item.quantity %}
{% assign total_saving = saving | plus: total_saving %}
{% endif %}
{% endfor %}
You Saved: {{ total_saving }} //example: $40
//this script requires jQuery
function isVisibleOnScreen(target){
var depth = $(target).offset().top; //depth from the top
var targetHeight = $(target).height(); //height of the target element
var winHeight = $(window).height(); //current window height
var totalTargetDepth = parseInt(targetHeight)+parseInt(depth)+winHeight; //total depth
var scrolledDepth = $(window).scrollTop(); //how far you scrolled
var elmVisible = winHeight+scrolledDepth; //the point where the target starts displaying at the bottom of the screen
//console.log(scrolledDepth+'-'+elmVisible+'-'+depth);
//runs the logic condition
@atikju
atikju / total-stock.liquid
Created October 17, 2018 19:45
Shopify - Display Total Stock Quantity
{% assign total=0 %}
{%for variant in product.variants %}
{% capture i %}{{ total | plus:variant.inventory_quantity }}{%endcapture%}
{% assign total = i %}
{%endfor%}
Total Stock: {{ total }}
@atikju
atikju / realTimeCartUpdate.liquid
Last active October 25, 2018 17:38
Shopify - Real time cart update
{% for item in cart.items %}
<div class="mbl-cart-container" id="DevLine-{{forloop.index}}">
<div class="mbl-quantity">
<p><i class="fas fa-plus" data-line-id="{{ forloop.index }}"></i></p>
<p class="dev-line-qty" id="Q-{{forloop.index}}">{{ item.quantity }}</p>
<p><i class="fas fa-minus" data-line-id="{{ forloop.index }}"></i></p>
</div>
<div class="mbl-line-image">
<a href="{{ item.url }}">
@atikju
atikju / ChangeVariantOnImageClick.liquid
Created October 23, 2018 16:22
Shopify - change variant on Product thumbnail image click or change
<script>
$(document).ready(function(){
/*
STEPS:
1. Grab the img id from the src on gallery thumb click
2. loop thru the radio button images and grab the img src
2a. click the button that's it!
*/
/*
@atikju
atikju / compareTwoArrays.js
Last active October 24, 2018 13:07
JS - compare two arrays and find the mismatched elements
var current = [1, 2, 3, 4, 7, 8],
prev = [1, 2, 4],
isMatch = false,
missing = null;
var i = 0, y = 0,
lenC = current.length,
lenP = prev.length;
for ( ; i < lenC; i++ ) {
@atikju
atikju / cartDiscount.liquid
Created October 24, 2018 20:45
Shopify - Apply Discount / Coupon / Promo Code on cart page
<div class="cart-promo">
<h2>ENTER A PROMO CODE</h2>
<input type="text" id="devPromo">
<a href="/checkout?discount=none" id="redemDevPromo">Apply Coupon</a>
</div>
<script>
$(document).ready(function(){
//listen to the promo button click
$('#redemDevPromo').on('click', function(event){
//disable the button event
@atikju
atikju / removeItemCart
Created October 25, 2018 17:39
Shopify - Remove item from Cart
{% for item in cart.items %}
<a class="cart-removal" data-line-id="{{ forloop.index }}" href="/cart/change?line={{ forloop.index }}&quantity=0" rel="{{ item.id }}">Remove Item</a>
{% endfor %}
@atikju
atikju / ajax-search-form.liquid
Last active December 15, 2023 13:40
Shopify Ajax Search
{% comment %}
This file can be added as a snippet and add it anywhere you want to display
{% endcomment %}
<div id="pageheader">
<div class="util-area">
<div class="search-box">
<form class="search-form" action="/search" method="get" _lpchecked="1">
<i class="icon-mag"></i>
<input type="text" name="q" placeholder="Search" autocomplete="off">
<input type="submit" value="→">