Skip to content

Instantly share code, notes, and snippets.

View alexflorisca's full-sized avatar

Alex Florisca alexflorisca

View GitHub Profile
@alexflorisca
alexflorisca / index.php
Last active February 28, 2025 20:34
Change order totals based on payment method
add_filter( 'woocommerce_calculated_total', 'modify_cart_total_by_payment_method', 10, 2 );
function modify_cart_total_by_payment_method( $total, $cart ) {
$chosen_payment_method = WC()->session->get( 'chosen_payment_method' );
switch ( $chosen_payment_method ) {
case 'bacs':
$total += 2;
break;
@alexflorisca
alexflorisca / index.html
Last active December 11, 2020 11:41
Showcase Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Showcase Demo</title>
<style>
body,
html {
padding: 0;
@alexflorisca
alexflorisca / config.yml
Last active July 14, 2020 20:42
Shopify Workflow
development:
password: your-password-from-the-private-app-on-dev-store
theme_id: "1111111111"
store: dev-store.myshopify.com
ignore_files:
- config/settings_data.json
// Super simple throttle function.
// Works in most cases, but doesn't work if need to capture the last call
// Assume f already has the right context attached. E.g. throttle(f.bind(context), 500)
function throttle(f, t) {
let inThrottle;
return function(args) {
if(!inThrottle) {
f(args);
inThrottle = true;
setTimeout(() => inThrottle = false, t)
@alexflorisca
alexflorisca / cloudinary.liquid
Last active June 10, 2020 16:51
Shopify Section: Hero Unit with Cloudinary Integration
{%if settings.enableCloudinary and settings.cloudinaryUrl != blank %}
{% assign baseUrl = settings.cloudinaryUrl %}
{%if img contains "?" %}
{% assign imgUrl = img | split: "?" %}
{% assign fetchQuery = "?" | append: imgUrl.last | url_encode %}
{% assign fetchUrl = imgUrl.first | append: fetchQuery %}
{% else %}
{% assign fetchUrl = img %}
{% endif %}
{%if transformation and transformation !=blank %}
@alexflorisca
alexflorisca / sessionStorageOk.js
Created June 4, 2020 10:00
Check for sessionStorage
function sessionStorageOk() {
const test = "test";
try {
sessionStorage.setItem(test, test);
sessionStorage.removeItem(test);
return true;
} catch (e) {
return false;
}
}
@alexflorisca
alexflorisca / throttle.js
Last active September 5, 2017 16:16
Throttle
function throttle(func, wait) {
let last, timer;
return function() {
const now = +new Date;
const args = arguments;
const context = this;
if(last && now < last + wait) {
clearTimeout(timer);
@alexflorisca
alexflorisca / debounce.js
Last active September 5, 2017 16:12
Debounce
function debounce(func, wait) {
let timer = null;
return function() {
let context = this;
let args = arguments;
clearTimeout(timer);
timer = setTimeout(function() {
func.apply(context, args);
}, wait);
@alexflorisca
alexflorisca / SassMeister-input.scss
Created February 11, 2016 15:01
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
// In variables.scss
// Only place where colours need to be managed
$colors: (
green: #37AC47,
red: #EB3C3C,
yellow: #F3B241,
{
"name": "NPM Build example",
"description": "Based on this article: http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/",
"version": "0.0.1",
"private": true,
"scripts": {
"test": "node_modules/karma/bin/karma start",
"test-once": "node_modules/karma/bin/karma start --single-run",
"lint": "jsxhint js",
"clean": "rm -r static/* && mkdirp static/js && mkdirp static/css",