Skip to content

Instantly share code, notes, and snippets.

View aaliyan111's full-sized avatar

Aaliyan Gul aaliyan111

  • Codehouse.pk
  • pakistan
View GitHub Profile
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
<script>
// <![CDATA[
var selectCallback = function(variant, selector) {
if (variant) {
if (variant.available) {
// Selected a valid variant that is available.
$('#add-to-cart-button').removeClass('disabled').removeAttr('disabled').html('Add to Cart');
} else {
@aaliyan111
aaliyan111 / shopify-add-to-cart
Created March 30, 2021 22:17 — forked from lucased/shopify-add-to-cart
Shopify - Add product to cart automatically
if (typeof Shopify === 'undefined') var Shopify = {};
Shopify.cart = {{ cart | json }};
Shopify.toAdd = 378589397;
var surchargeInCart = false;
var total = 2507; // total in cents.
for (var i=0; i<Shopify.cart.items.length; i++) {
if (Shopify.cart.items[i].id === Shopify.toAdd) {
surchargeInCart = true;
total -= Shopify.cart.items[i].line_price;
@aaliyan111
aaliyan111 / shopify-variant-filters.txt
Created November 22, 2020 21:24 — forked from tanmay27vats/shopify-variant-filters.txt
Showing Shopify product's variants (Size / Length / Color) as filters on collection page.
/*****
Here, I am assuming that you have already assigned all variants as tags of a product. Because Shopify filter does not work with variant options.
And, if you assigns all variants as tags you can not differentiate them from tags.
Here I code that is working for 2 filters Size & Length (with mulitple options. ie mulitple sizes, multiple lengths, etc
*****/
<div class="filters-toolbar">
<div class="filters-toolbar__item size-filter">
{% assign variant_sizes = "" %}
{% assign variant_lengths = "" %}
@aaliyan111
aaliyan111 / zip-validation.js
Created September 11, 2020 13:09 — forked from artisanalcode/zip-validation.js
A method for jQuery Validation Plugin (http://jqueryvalidation.org/). It checks if a ZIP code entered contains one of a number of prefixes specified in an array. It can also check if a ZIP code is within a certain range or if it contains a specific format (e.g. USA, Canada, etc.). Client work.
/*
Version: 1.0
File: zip-validation.js
Author: Juan Garcia
Email: dev [at] soleilnoirmedia [dot] com
Description: zipValidation.js contains a method for jQuery Validation Plugin (http://jqueryvalidation.org/).
It checks if a ZIP code entered contains one of a number of prefixes specified in an array (A requirement from a client).
It can also check if a ZIP code is within a certain range or if it contains a specific format (e.g. USA, Canada, etc.).
Ideal to validate addresses for local deliveries.
*/
@aaliyan111
aaliyan111 / Much much simpler option selector for Shopify
Created May 29, 2020 07:46 — forked from zakhardage/Much much simpler option selector for Shopify
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}
@aaliyan111
aaliyan111 / filterArray.js
Created May 6, 2020 21:19 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
@aaliyan111
aaliyan111 / cart.js
Created April 30, 2020 21:57 — forked from DanWebb/cart.js
General functions for creating AJAX based Shopify Quick carts or cart pages
var Cart = (function($, Shopify) {
var list = '.sproducts';
var total = '.shoppingbag-total';
function updateTotal() {
Shopify.getCart(function(data) {
$(total).text(Shopify.formatMoney(data.total_price, '£\{\{amount}}'));
});
}
@aaliyan111
aaliyan111 / Dynamic_Load_On_Scroll_Jquery.html
Created April 24, 2020 13:11 — forked from sphingu/Dynamic_Load_On_Scroll_Jquery.html
Loading content on scroll to bottom on page using Jquery
<html>
<head>
<title>Scroll to bottom Detection</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var count=0;
$(document).ready(function(){
SetValues();
$(window).scroll(function(){
//Will check if the user has reached bottom of a PAGE
/*
* Ensure the http protocol is always used on the myshopify.com domains.
* Uses liquid to input the correct URL.
*/
if (window.location.href.match(/https:\/\/.*.myshopify.com/) && top === self) {
window.location.href = window.location.href.replace(/https:\/\/.*.myshopify.com/, 'http://{{ shop.domain }}');
}
@aaliyan111
aaliyan111 / Date-Select-Markup.html
Created April 22, 2020 10:36 — forked from aleksblago/Date-Select-Markup.html
Markup: Select options for Month, Day, and Year.
<span>
<select name="month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>