This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST /admin/application_credits.json HTTP/1.1 | |
Host: merchantshop.myshopify.com | |
Content-Type: application/json | |
X-Shopify-Access-Token: 35ee86casd97e9b8b10089afa4ccb654 | |
{ | |
"application_credit": { | |
"description": "Sorry you paid twice by mistake! Here is a $5 credit.", | |
"amount": 5.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.halloween-animation { | |
position: relative; | |
display: inline-block; | |
} | |
.halloween-animation::before, | |
.halloween-animation::after { | |
display: block; | |
content: ''; | |
height: 20px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.spider-web { | |
position: relative; | |
margin-bottom: 3.125em; | |
margin-top: 1em; | |
border: 0; | |
border-bottom: 2px solid #000000; | |
} | |
.spider-web::after { | |
content: ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < ApplicationController | |
include ShopifyApp::SessionsController | |
before_filter :check_allowed_shops, only: :new | |
private | |
# Checks that the shop attempting to login (starting OAuth flow) is allowed | |
def check_allowed_shops | |
if params[:shop].present? | |
if allowed_shops.include?(params[:shop].gsub(".myshopify.com","")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
next if product.gift_card? | |
next unless product.id == 6323295239 | |
line_item.change_line_price(line_item.line_price * 0.90, message: "My Sale") | |
end | |
Output.cart = Input.cart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use an array to keep track of the discount campaigns desired. | |
CAMPAIGNS = [ | |
# $5 off all items with the "sale" tag | |
ItemCampaign.new( | |
AndSelector.new( | |
TagSelector.new("sale"), | |
ExcludeGiftCardSelector.new, | |
), | |
MoneyDiscount.new(5_00, "5$ off all items on sale",), | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductSetPartitioner | |
def initialize(set_product_ids) | |
@set_product_ids = set_product_ids | |
end | |
def partition(cart, applicable_line_items) | |
# If all items in the product set are in the cart, then all applicable line | |
# items are eligible for the discount. Otherwise, none of them are. | |
cart_product_ids = cart.line_items.map { |line_item| line_item.variant.product.id }.uniq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The campaign class. | |
class BuySetGetXOffCampaign | |
def initialize(selector, discount, partitioner) | |
@selector = selector | |
@discount = discount | |
@partitioner = partitioner | |
end | |
def run(cart) |