Skip to content

Instantly share code, notes, and snippets.

@wytanj
wytanj / Shopify Script - Max discount based on cart value
Created April 15, 2021 08:49 — forked from fraser-0/Shopify Script - Max discount based on cart value
Shopify script for applying an upper limit on total discount amount based on cart value. Will spread the maximum discount amount proportionately across all cart products. Applies percentage discount to cart products under cart value threshold.
# In this campaign we wanted to have 50% of every product unless the cart value was 200 or more
# If the 200 or more, the maximum discount that could apply was 100
# Wanted to spread that the discount amount across all line items proporinate to its value in the cart
# Do/change following (if required):
# 1. Create a new coupon code in Shopify
# 2. Replace the coupon code evaluation value ('DISCOUNT_CODE') with the new code on line 13
# 3. Change the cart subtotal evaluation amount (Money.new(cents:20000)) on lines 16, 39
# 4. Change the max_discount value (100) on line 18
# 5. Change the discount amount (0.5) on line 41
@wytanj
wytanj / Shopify Script - Max discount based on cart value
Created April 15, 2021 08:49 — forked from fraser-0/Shopify Script - Max discount based on cart value
Shopify script for applying an upper limit on total discount amount based on cart value. Will spread the maximum discount amount proportionately across all cart products. Applies percentage discount to cart products under cart value threshold.
# In this campaign we wanted to have 50% of every product unless the cart value was 200 or more
# If the 200 or more, the maximum discount that could apply was 100
# Wanted to spread that the discount amount across all line items proporinate to its value in the cart
# Do/change following (if required):
# 1. Create a new coupon code in Shopify
# 2. Replace the coupon code evaluation value ('DISCOUNT_CODE') with the new code on line 13
# 3. Change the cart subtotal evaluation amount (Money.new(cents:20000)) on lines 16, 39
# 4. Change the max_discount value (100) on line 18
# 5. Change the discount amount (0.5) on line 41
@wytanj
wytanj / aws.upload-folder-to-s3.js
Created October 21, 2019 06:40 — forked from jlouros/aws.upload-folder-to-s3.js
Upload folder to S3 (Node.JS)
const AWS = require("aws-sdk"); // from AWS SDK
const fs = require("fs"); // from node.js
const path = require("path"); // from node.js
// configuration
const config = {
s3BucketName: 'your.s3.bucket.name',
folderPath: '../dist' // path relative script's location
};
@wytanj
wytanj / now.json
Created July 22, 2018 15:53
Configure static hosting on Zeit to have securityheaders.com’s recommended security headers
{
"name": "TODO-put-your-project-name-here",
"alias": [
"TODO-put-your-domain-here.com",
"www.TODO-put-your-domain-here.com"
],
"static": {
"headers": [
{
"source": "**/*.@(html)",
@wytanj
wytanj / fb-user-liked-page.js
Created April 2, 2018 09:16 — forked from tracend/fb-user-liked-page.js
Facebook JS-SDK: Check if the user has liked a page
FB.api({ method: 'pages.isFan', page_id: '{PAGE_ID}' }, function(response) {
if (response) {
alert("user has liked the page");
} else {
alert("user has not liked the page");
}
});
@wytanj
wytanj / server.conf
Created September 10, 2017 04:28 — forked from iliakan/server.conf
Nginx configuration for separated frontend and backend endpoints
upstream example-webpack {
server 127.0.0.1:8080;
}
upstream example-backend {
server 127.0.0.1:3000;
}
server {
listen 80;

Templating engines and React.js

I want to make a shopify theme using react.

How shopify theming works

You have a bunch of template files that have access to global server-side variables with liquid e.g. {{ product.title }}. Think wordpress or any other theme-based system.

 /theme
@wytanj
wytanj / nginxproxy.md
Created August 31, 2017 08:43 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@wytanj
wytanj / README.md
Created January 16, 2016 04:20 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@wytanj
wytanj / untitled
Created January 14, 2016 13:25
Dummy
new content