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
customer = Input.cart.customer | |
puts(customer) | |
if customer | |
if customer.tags.include? 'TEST' | |
Output.payment_gateways = Input.payment_gateways | |
else | |
Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway| | |
payment_gateway.name == 'Pay on pickup' | |
end | |
end |
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 ScrollTo(name) { | |
//init thread | |
ScrollToResolver(document.getElementById(name)); | |
} | |
function ScrollToResolver(elem) { | |
var jump = parseInt(elem.getBoundingClientRect().top * .2) - 30; | |
document.body.scrollTop += jump; | |
document.documentElement.scrollTop += jump; | |
//lastjump detects anchor unreachable, also manual scrolling to cancel animation if scroll > jump |
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
// Add query string to URL | |
const newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?step=1'; | |
window.history.pushState({path:newurl},'',newurl); | |
// Fire event everytime state changes | |
window.addEventListener('popstate', function (event) { | |
console.log(event) | |
}); |
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
var date = new Date("2021-09-01T03:00:00.000Z"); | |
var options = { weekday: 'long', month: 'long', day: '2-digit', year: "numeric" }; | |
console.log(date.toLocaleDateString('en-CA', options).replace(', ',' - ')); | |
/* OUTPUT */ | |
// Wednesday - September 01, 2021 |
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 function getDetails (handle) { | |
const response = await window.fetch(`/products/${handle}.js`) | |
const data = await response.json() | |
console.log(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
async function productRecommentation(id, limit) { | |
const response = await window.fetch(`/recommendations/products.json?product_id=${id}&limit=${limit}`) | |
const data = await response.json() | |
console.log(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
function decamelize(str, separator){ | |
separator = typeof separator === 'undefined' ? '_' : separator; | |
return str | |
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') | |
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') | |
.toLowerCase(); | |
} |
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
<link rel="preconnect" href="https://cdn.shopify.com" crossorigin> | |
<link rel="preconnect" href="https://fonts.shopify.com" crossorigin> | |
<link rel="preconnect" href="https://monorail-edge.shopifysvc.com" crossorigin> | |
<link rel="preload" href="{{ 'lazysizes.js' | asset_url }}" as="script"> | |
<link rel="preload" href="{{ 'vendor.js' | asset_url }}" as="script"> | |
<link rel="preload" href="{{ 'theme.js' | asset_url }}" as="script"> | |
<link rel="preload" href="{{ 'theme.css' | asset_url }}" as="style"> |
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
{% if cart.attributes.yourCartAttribute %} | |
<script> | |
Shopify.updateCartAttributes([{ | |
key: 'yourCartAttribute', | |
value: '' | |
}], function(onError) {}); | |
</script> | |
{% endif %} |