Skip to content

Instantly share code, notes, and snippets.

View ashukasma's full-sized avatar
🎯
Focusing

Ashish ashukasma

🎯
Focusing
View GitHub Profile
class OrderPage extends StatefulWidget {
@override
_OrderPageState createState() => _OrderPageState();
}
class _OrderPageState extends State<OrderPage> {
bool isShowing = true;
@override
Widget build(BuildContext context) {
return Column(children: [
@ashukasma
ashukasma / gist:3bfca843a7ee97ddbd4cf0aeabdf02e6
Created December 10, 2021 07:15
Simply Insurance - Hey Senior Side cart integration
<!-- simply-insurance -->
{%- assign sidecart = shop.metafields.SimplyInsurance.sidecart -%}
{%- assign sidecart = false -%}
<script>
window.simplyInsurance = window.simplyInsurance || {};
window.cn = function (o) { return "undefined" == typeof o || null == o || "" == o.toString().trim() };
simplyInsurance.insurancePlan = {{ shop.metafields.SimplyInsurance.InsurancePlan | json }};
simplyInsurance.insurancePlan = JSON.parse(simplyInsurance.insurancePlan);
simplyInsurance.money_format = "{{ shop.money_format }}";
simplyInsurance.cartJson = {{ cart | json }};
@ashukasma
ashukasma / checkout.liquid
Created August 26, 2021 07:27
Checkout - simplyinsurance
<!DOCTYPE html>
<html lang="{{ locale }}" dir="{{ direction }}" class="{{ checkout_html_classes }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, height=device-height, minimum-scale=1.0, user-scalable=0">
<meta name="referrer" content="origin">
<title>{{ page_title }}</title>
@ashukasma
ashukasma / Code for calling our functions
Last active November 11, 2023 16:39
Simply Insurance Code snippet
try{
if(simplyInsurance && typeof simplyInsurance !== "undefined" )
simplyInsurance.loadApp();
}catch(e){
console.log(e);
}
@ashukasma
ashukasma / add.js
Created February 8, 2021 10:12
Add item to cart in shopify using Fetch API JS
var VID = 0;
var addData = {
'id':VID,
'quantity':1
};
fetch('/cart/add.js', {
body: JSON.stringify(addData),
credentials: 'same-origin',
headers: {
@ashukasma
ashukasma / sorting
Created February 1, 2021 06:06
Shopify Sorting Logic
https://<>.myshopify.com/collections/all?sort_by=price-descending
*Available sorting*
manual
price-ascending
price-descending
title-ascending
title-descending
created-ascending
created-descending
DISCOUNTS_BY_QUANTITY = {
4 => 20,
3 => 15,
2 => 10
}
discunted_count = 0
Input.cart.line_items.each do |line_item|
if line_item.variant.product.tags.include?('DiscountTag')
{% if product.compare_at_price_max > product.price %}You save {{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}%{% endif %}
@ashukasma
ashukasma / Tired pricing
Last active August 10, 2017 02:48
Shopify scripts
qty_discount_mapping = {
40 => 20,
30 => 15,
20 => 10,
10 => 5,
}
percentoff = 1;
Input.cart.line_items.each do |line_item|
@ashukasma
ashukasma / imgURL.js
Created August 25, 2016 13:19 — forked from DanWebb/imgURL.js
Specify a size for a Shopify image asset url. Equivalent to the liquid image size filter: `{{ image | img_url: "medium" }}`
String.prototype.imgURL = function(size) {
// remove any current image size then add the new image size
return this
.replace(/_(pico|icon|thumb|small|compact|medium|large|grande|original|1024x1024|2048x2048|master)+\./g, '.')
.replace(/\.jpg|\.png|\.gif|\.jpeg/g, function(match) {
return '_'+size+match;
})
;
};