Skip to content

Instantly share code, notes, and snippets.

@atomgiant
atomgiant / _shopify_fullpage_redirect.html.erb
Last active March 27, 2023 14:32
Shopify embedded app fullpage redirect
<script type='text/javascript'>
if (window.top == window.self) {
window.top.location.href = "<%= url %>";
} else {
message = JSON.stringify({
message: "Shopify.API.remoteRedirect",
data: { location: "<%= url %>" }
});
window.parent.postMessage(message, "https://<%= shopify_domain %>");
}
@atomgiant
atomgiant / full-stack-developer.md
Last active September 9, 2021 12:55
Full Stack Rails Developer at Brainy Atom

Full Stack Rails Developer at Brainy Atom

About the Job

As a full-stack developer at Brainy Atom, you'll be working on Shopify apps used by thousands of Shopify merchants. Brainy Atom is currently a one-person company, so your work will have a big impact. You'll be working directly with the founder to build new features for our existing apps, launching new apps, and helping customers get up and running. You'll also have plenty of opportunity to learn the ins and outs of running a software company.

  • $100/hour
  • A minimum of 20 hours/week ongoing, with more hours possible
  • Fully remote with lots of autonomy
  • 1099 Contract to start, with the option to convert to salary and bonuses
module Liquid
class ProductMock
attr_accessor :id, :collections, :variants, :created_at, :tags
def initialize(id: 123, collections: [], variants:[], created_at: Date.yesterday, tags:[])
@collections = []
@variants = variants
@created_at = created_at
@tags = tags
end
@atomgiant
atomgiant / shopify_client.rb
Created May 7, 2020 16:56
Shopify REST Client based on Excon
class ShopifyClient
# Initialize the Shopify api client
def initialize(shopify_domain:, shopify_token:, api_version: '2020-01')
@shopify_domain = shopify_domain
@shopify_token = shopify_token
@api_version = api_version
end
# ********** APPLICATION CHARGES **********
------------------
For products
------------------
1. Edit sections/product-template.liquid
2. Search for a line similar to:
<h1 itemprop="name">{{ product.title }} </h1>
3. Add the Flair include after it like this:
1. For product pages
Edit sections/product-template.liquid
And insert Flair here:
<h1 itemprop="name" class="product-single__title">{{ product.title }}</h1>
{% include 'flair-product-badges' %}
2. For collections
1. For product pages
Edit each of these:
sections/product-template.liquid
sections/product-details-template.liquid
sections/product-description-bottom-template.liquid
And insert Flair here:
1. For product pages, edit sections/product-template.liquid
<h1 class="title">{{ product.title }}</h1>
{% include 'flair-product-badges' %}
2. For the main collection snippet, edit snippets/product-block.liquid
<div class="title">{{ product.title }}</div>
<div class="dash">-</div>
{% include 'flair-product-badges' %}
# For a given Metafield, this is how
# you access the serialized JSON data
mf = {"id"=>10030144453,
"namespace"=>"product",
"key"=>"custom_attrs",
"value"=>"{\"width\":11.2,\"height\":35.7}",
"value_type"=>"string",
"description"=>nil,
"owner_id"=>1234567890,
"created_at"=>"2015-11-20T16:48:03-05:00",
def Shopify.set_product_metafield_map(id, namespace, key, map)
# convert the map to JSON so it fits in one metafield
data = {
"metafield" => {
"namespace" => namespace,
"key" => key,
"value" => map.to_json,
"value_type" => "string"
}
}