Skip to content

Instantly share code, notes, and snippets.

View dannyvargas23's full-sized avatar

Danny Vargas dannyvargas23

View GitHub Profile
@dannyvargas23
dannyvargas23 / line_item_property_discount.rb
Created November 11, 2022 23:01 — forked from CodeBrotha/line_item_property_discount.rb
Shopify Scripts - Line Item Properties Discount
Input.cart.line_items.each do |item|
# ================================================================
# LINE ITEM PROPERTY DISCOUNT
# ================================================================
# Set the line item property in Shopify theme When adding item to cart
#
# line item property is a key/value pair. Example: {"_someCoolPromo": "1"}
#
# In this example:
# "_someCoolPromo" is the key we look for here and must ALWAYS start with an underscore.
@dannyvargas23
dannyvargas23 / how-to-copy-aws-rds-to-local.md
Created October 3, 2022 19:04 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
FREEBIE_PRODUCT_ID = 31059890110524
CART_TOTAL_FOR_DISCOUNT_APPLIED = Money.new(cents: 4000)
DISCOUNT_MESSAGE = "Get a FREE gift for ordering $40 or more"
freebie_in_cart = false
cart_price_exceeds_discounted_freebie_amount = false
cost_of_freebie = Money.zero
# Test if the freebie is in the cart, also get its cost if it is so we can deduct from the cart total
Input.cart.line_items.select do |line_item|
@dannyvargas23
dannyvargas23 / shopify.datalayer.html
Created June 16, 2022 11:04 — forked from samba/shopify.datalayer.html
Shopify DataLayer Checkout
{% if first_time_accessed %}
<script>
(function(dataLayer){
var customer_type = ({{customer.orders_count}} > 1) ? 'repeatcustomer' : 'newcustomer';
var discounts = "{{ order.discounts | map: 'code' | join: ',' | upcase}}";
function strip(text){
return text.replace(/\s+/, ' ').replace(/^\s+/, '').replace(/\s+$/, '');
}
'use strict';
var AWS = require('aws-sdk');
var sqs = new AWS.SQS();
var crypto = require('crypto');
exports.handler = (event, context, callback) => {
var client_secret = event.client_secret;
delete event.client_secret;
//calculate the hash
@dannyvargas23
dannyvargas23 / gist:9500c220128a0a80b0b1094077efbb17
Created May 29, 2019 04:47 — forked from kyleaparker/gist:560a3847860bace1d680
[Shopify] Show multiple images per variant
<script>
jQuery(document).ready(function($){
var images = [];
{% for image in product.images %}
images.push({url: "{{ image | product_img_url: 'medium' }}", alt: "{{ image.alt }}"});
{% endfor %}
var thumbnails = $(".thumbs");