This file contains 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
// Build a custom products query using the unoptimized version of the SDK | |
const productsQuery = this.props.client.graphQLClient.query((root) => { | |
root.addConnection('products', {args: {first: 12}}, (product) => { | |
product.add('title'); | |
product.add('tags'); | |
product.addConnection('variants', {args: {first: 12}}, (product) => { | |
product.add('id') | |
product.add('price') | |
}) | |
}); |
This file contains 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
// Async Await version, although, i am not sure it's made things easier | |
(async () => { | |
// Change the domain name | |
try { | |
const fetchIt = await fetch(`${window.location.origin}/cart.js`) | |
const response = await fetchIt.json() | |
const data = response | |
const loopOver = data.items.map((d) => { | |
let handleURL = `${window.location.origin}/products/${d.handle}.js` |
This file contains 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
(function cartCheck() { | |
let fetchIt = fetch(`${window.location.origin}/cart.js`) | |
.then(response => response.json()) | |
.then((data) => { | |
const dataMap = data.items.map((d) => { | |
let handleURL = `${window.location.origin}/products/${d.handle}.js` | |
return handleURL | |
}) | |
for (let data of dataMap) { | |
fetch(data) |
This file contains 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
const colorSwatchChange = async (e) => { | |
e.preventDefault() | |
let title = document.querySelector('.product-single__title') | |
let description = document.querySelector('#descriptionFrames') | |
let productPrice = document.querySelector('.product__price') | |
let images = document.querySelectorAll('#mainProductImages') | |
let productThumbs = document.querySelectorAll('#productThumbs') | |
let intFrameWidth = window.innerWidth; | |
let target = e.currentTarget | |
let url = `${target.dataset.url}.js` |
This file contains 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
{% for variant in product.variants %} | |
<div class=""> | |
{% for color_option in product.options_by_name['Color'].values %} | |
{% assign productColor = color_option %} | |
{% endfor %} | |
</div> | |
{% for x in product.tags %} | |
{% if x != productColor %} | |
{% assign currentProductTags = x %} | |
{% endif %} |
This file contains 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 Cars | |
getter price : Int64 | |
getter condition : String | |
def initialize(@type : String, @price : Int64, @condition : String, @location : String, @color : String); end | |
end | |
johns_car = Cars.new "Holden", 10000, "Fair", "New York", "Red" | |
puts "Johns car is in #{johns_car.condition} condition, although, the price is cheap at only #{johns_car.price}" |
This file contains 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
struct Cars | |
getter price : Int64 | |
getter condition : String | |
def initialize(@type : String, @price : Int64, @condition : String, @location : String, @color : String)end | |
end | |
johns_car = Cars.new "Holden", 10000, "Fair", "New York", "Red" | |
puts "Johns car is in #{johns_car.condition} condition, although, the price is cheap at only #{johns_car.price}" |
This file contains 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
record Cars, type : String, price : Int64, condition : String, location : String, color : String do | |
def car_return | |
puts "Johns car is in #{condition} condition, although, the price is cheap at only $#{price}" | |
end | |
end | |
Johns_car = Cars.new "Ford", 10000, "Fair", "New York", "Red" | |
Johns_car.car_return |
This file contains 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 Cars { | |
constructor(type, price, condition, color, location) { | |
this.type = type | |
this.price = price | |
this.condition = condition | |
this.color = color | |
this.location = location | |
} | |
sellCar(n) { | |
console.log(n.type, 'has been sold.') |
This file contains 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
const readline = require('readline').createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
const run_questions = () => { | |
readline.question('Enter a number ', num1 => { | |
readline.question('Enter a second number ', num2 => { | |
const num2Parsed = Number.parseInt(num2) | |
const num1Parsed = Number.parseInt(num1) | |
const sumParsed = num1Parsed + num2Parsed |