I hereby claim:
- I am ninigi on github.
- I am fabianz (https://keybase.io/fabianz) on keybase.
- I have a public key ASA-8HonGp7KrJPhHF1PNEyx1r0pH-Mf_GKKrNQpmU3h9wo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
function toggleCountryPayment() { | |
var isPayPal = function(el) { | |
return el.querySelectorAll(".radio__label__primary")[0] && el.querySelectorAll(".radio__label__primary")[0].textContent.trim() === "PayPal"; | |
} | |
var shipToElement = document.querySelector("address.address") && document.querySelector("address.address").firstChild; | |
if (shipToElement && shipToElement.data.indexOf("Malaysia") > -1) { | |
var els = document.querySelectorAll(".section--payment-method .radio-wrapper.content-box__row"), | |
radioButtons = []; |
defmodule Useless.Plugs.EmbeddedAppPlug do | |
@moduledoc """ | |
Loads the shop from database, puts a private shop field in conn and sets x-frame-options. | |
Will halt if no shop found | |
""" | |
alias Plug.Conn | |
alias Useless.ShopifyApp |
defmodule UselessWeb.ShopController do | |
# ... | |
def new(conn, %{"hmac" => _, "shop" => shopify_domain}) do | |
shop = ShopifyApp.find_shop_by(%{shopify_domain: shopify_domain}) | |
conn | |
|> put_layout({UselessWeb.EmbeddedAppView, "layout.html"}) | |
|> render("show.html", shop: shop) | |
end |
defmodule UselessWeb.ShopController do | |
# ... | |
def new(conn, %{"shop" => shop_name}) when is_bitstring(shop_name), | |
do: signup(conn, %{"shop" => %{"shopify_domain" => shop_name}}) | |
def new(conn, _params) do | |
changeset = ShopifyApp.change_shop(%Shop{}) | |
render(conn, "new.html", changeset: changeset) | |
end |
@doc """ | |
Creates a new shop if no shop with the given shopify_domain exists, or updates | |
the existing shop | |
## Examples | |
iex> create_or_update_shop(%{shopify_domain: "shop@my_shopify.com", shopify_token: "a-token"}) | |
{:ok, %Shop{}} | |
iex> create_or_update_shop(%{shopify_domain: nil, shopify_token: "a-token"}) |
test "create_or_update_shop/1 creates a shop if it doesn't already exist" do | |
assert {:ok, %Shop{} = shop} = ShopifyApp.create_or_update_shop(@valid_attrs) | |
assert shop.shopify_domain == @valid_attrs.shopify_domain | |
assert shop.shopify_token == @valid_attrs.shopify_token | |
end | |
test "create_or_update_shop/1 updates a shop's token if it already exists" do | |
shop_fixture() | |
params = %{ | |
shopify_domain: @valid_attrs.shopify_domain, |
defmodule UselessWeb.AuthController do | |
use UselessWeb, :controller | |
alias Useless.ShopifyApp | |
alias Useless.ShopifyApp.Shop | |
def shopify(conn, %{"shop" => shopify_domain, "code" => shopify_token}) do | |
session = shopify_domain |> Shopify.session() | |
with {:ok, %{data: oauth}} <- Shopify.OAuth.request_token(session, shopify_token), |
defmodule UselessWeb.ShopController do | |
use UselessWeb, :controller | |
alias Useless.ShopifyApp | |
alias Useless.ShopifyApp.Shop | |
def new(conn, _params) do | |
changeset = ShopifyApp.change_shop(%Shop{}) | |
render(conn, "new.html", changeset: changeset) | |
end |
var preferedShipping = "EMS"; // This has to be the exact name of the shipping method you want to be preselected | |
function waitForFetch(tries, callback) { | |
if (tries > 40000) {return} // stop waiting after ~ 40 seconds | |
if (document.querySelector(".blank-slate")) { | |
setTimeout(function() { waitForFetch(tries + 1, callback) }, 10); | |
} else { | |
callback(); | |
} |