Skip to content

Instantly share code, notes, and snippets.

View ihorduchenko's full-sized avatar
💭
Working

Ihor Duchenko ihorduchenko

💭
Working
View GitHub Profile
@ihorduchenko
ihorduchenko / close-dropdown-on-click-outside.html
Created August 4, 2023 20:00
Close dropdown on clicking outside
<fieldset class="filtersDropdown">
<div class="filtersDropdownTrigger">
Dropdown trigger
<div class="caret pointer-events-none">
<svg class="pointer-events-none"><use xlink:href="#icon-angle-down"></use></svg>
</div>
</div>
<div class="dropdown-body"></div>
</fieldset>
@ihorduchenko
ihorduchenko / thank-you-page-detector.liquid
Created July 18, 2023 13:09
Detect order status page (Thank you page) in Shopify checkout
{%- assign is_thank_you_page = false -%}
{%- if checkout_html_classes contains 'page--thank-you' -%}
{%- assign is_thank_you_page = true -%}
{%- endif -%}
@ihorduchenko
ihorduchenko / ablyft-helper-classes.js
Created July 13, 2023 08:18
Add helper classes by ABlyft to detect whether script has been loaded
ablyftTools.domLoaded(function(){
document.documentElement.classList.add('ablyft-loaded');
document.documentElement.classList.remove('no-ablyft');
});
@ihorduchenko
ihorduchenko / prevent-double-event-listener.js
Last active July 6, 2023 15:57
Prevent 'change' event from being triggered twice (especially on radio buttons)
el.addEventListener('change', (e) => {
e.stopImmediatePropagation();
});
@ihorduchenko
ihorduchenko / metafields-filters.liquid
Created July 3, 2023 08:19
Useful Shopify metafields filters
{{ richtext | metafield_tag }} - displays richtext metafield tag
<video>
<source
src="{{ video | file_url }}"
type="video/mp4">
</video> - displays file metafield, video in this case
@ihorduchenko
ihorduchenko / section-sample.liquid
Created June 1, 2023 21:02
How to limit section using for specific on specific templates only
{% schema %}
{
"name": "Section name",
"templates": ["product"],
"settings": [],
"presets": [
{
"category": "Text",
"name": "Section name",
"settings": {}
@ihorduchenko
ihorduchenko / main-product.liquid
Created June 1, 2023 10:06
Cookie-based discount of products before cart and checkout using shareable link (Impact theme)
{% comment %}Necessary HTML elements{% endcomment %}
{%- if settings.discount_code_topbanner != blank -%}
<div class="dCodePDPTopBanner d-none">
Dein Rabattcode <strong class="dCodeName">testAmount_20</strong> wurde aktiviert. Du sparst <strong class="dCodePercent">20</strong>% auf deinen Einkauf!
</div>
{%- endif -%}
<span class="savingsBadge"
data-raw-price="{{ variant.price }}"
data-raw-comp-price="{{ variant.compare_at_price }}">
@ihorduchenko
ihorduchenko / pdp-upsells-with-async-atc.liquid
Last active May 18, 2023 21:41
Product upsells with async Add to cart functionality
<div class="pdp-upsells--panel-row">
{%- for prod in metafield -%}
{%- assign first_variant = prod.variants[0] -%}
{%- assign visibility_class = '' -%}
<div class="pdp-upsells--cell">
<div class="pdp-upsells--item">
<div class="pdp-upsells--item-image img-contain">
{%- if prod.featured_image != blank -%}
<img
loading="lazy"
@ihorduchenko
ihorduchenko / metaobject-hierarchical-list.liquid
Created April 22, 2023 00:27
How to fetch the value of metaobject containing the list of other metaobjects from anywhere in Shopify
{% assign entries = shop.metaobjects.pdp_buybox_advantages['pdp-buybox-advantages']['advantages'].value %}
{%- for item in entries -%}
{%- assign image = item.image.value -%}
{%- assign text = item.text.value -%}
{%- endfor -%}
@ihorduchenko
ihorduchenko / countdown-timer.html
Last active April 4, 2023 23:23
Vanilla JS countdown timer to specific date
<div class="countTimer" data-date="01 Jan 2030 00:00:00 GMT">
<div class="countdown-wrapper">
<div class="countdown-cell">
<span class="timer-number tDays">00</span>
<div class="timer-caption">Days</div>
</div>
<div class="countdown-cell">·</div>
<div class="countdown-cell">
<span class="timer-number tHours">00</span>
<div class="timer-caption">hours</div>