Skip to content

Instantly share code, notes, and snippets.

ui.createComponent('product', {
id: 1234567,
node: document.getElementById('my-product')
});
ui.createComponent('product', {
id: 1234567,
options: {
product: {
buttonDestination: 'modal'
},
cart: {
startOpen: true
}
}
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
.halloween-animation {
position: relative;
display: inline-block;
}
.halloween-animation::before,
.halloween-animation::after {
display: block;
content: '';
height: 20px;
.spider-web {
position: relative;
margin-bottom: 3.125em;
margin-top: 1em;
border: 0;
border-bottom: 2px solid #000000;
}
.spider-web::after {
content: '';
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",""))
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
# 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",),
),
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
# The campaign class.
class BuySetGetXOffCampaign
def initialize(selector, discount, partitioner)
@selector = selector
@discount = discount
@partitioner = partitioner
end
def run(cart)