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 / checkout.jsx
Last active April 7, 2025 11:36
Shopify App troubleshoot
import { useEffect, useState } from "react";
import {
useCartLineTarget,
Text,
reactExtension,
useApplyCartLinesChange,
} from "@shopify/ui-extensions-react/checkout";
// Entry point
export default reactExtension("purchase.checkout.cart-line-item.render-after", () => <App />);
@ihorduchenko
ihorduchenko / shopify-cart-change.liquid
Created December 6, 2024 23:32
Update cart line item using 'change' method and line items key
<script>
let productObject = {
id: itemInCart.key, // important to use key of type string
quantity: 1,
properties: {
'PropertyName': getCookie(PropertyName)
}
};
return fetch('{{ routes.cart_change_url }}.js', {
method: 'POST',
@ihorduchenko
ihorduchenko / section-block-repeatable-meta.liquid
Last active September 2, 2024 22:34
Access block's repeatable dynamic info (metafield of type metaobject list) connected from product metafields
{%- comment -%} Block.repeater is a key feature here {%- endcomment -%}
{{ block.repeater.metaobject_metafield_key.value }}
@ihorduchenko
ihorduchenko / dynamic-delivery-date.liquid
Created May 16, 2024 21:31
Calculate estimated shipping date based on predefined interval, excluding weekends and holidays
<script>
// Calculate the sequence number of the holidays here: https://miniwebtool.com/day-of-the-year-calculator/
// function to check leap year
function checkLeapYear(year) {
const isLeap = new Date(year, 1, 29).getDate() === 29;
return isLeap;
}
const currentYear = new Date().getFullYear();
if (checkLeapYear(currentYear)) {
@ihorduchenko
ihorduchenko / cart-line-items-properties-attributes.liquid
Created April 16, 2024 20:55
How to add line item properties and cart attributes in Shopify product form markup
{%- form 'product', product, id: form_id, class: 'product-single-form' -%}
<!-- Line item property -->
<input type="hidden" name="properties[Field]" value="Field value">
<!-- Cart attribute -->
<input type="hidden" name="attributes[Vendor]" value="Livom">
{%- endform -%}
@ihorduchenko
ihorduchenko / Shopify Script Discounting
Created January 21, 2024 16:09 — forked from jimmijazz/Shopify Script Discounting
Shopify Script Discounting example
# ================================ Customizable Settings ================================
# ================================================================
# Tiered Discounts by Quantity
#
# A list of discount tier offers where:
# - 'product_selector_match_type' determines whether we look for
# products that do or don't match the entered selectors. Can
# be:
# - ':include' to check if the product does match
# - ':exclude' to make sure the product doesn't match
@ihorduchenko
ihorduchenko / bulk-volume-pricing.rb
Created January 20, 2024 19:14
Shopify Scripts: Bulk volume pricing
# ================================ Customizable Settings ================================
# ================================================================
# Tiered Product Discount by Quantity
#
# If the total quantity of matching items is greater than (or
# equal to) an entered threshold, the associated discount is
# applied to each matching item.
#
# - 'product_selector_match_type' determines whether we look for
# products that do or don't match the entered selectors. Can
@ihorduchenko
ihorduchenko / add-to-cart-link.liquid
Created January 5, 2024 13:23
Shopify: link for automatically adding product to cart
@ihorduchenko
ihorduchenko / auto-applied-discount-url-example.txt
Created December 18, 2023 23:45
Shopify: example of a shareable link to apply the discount code in cart with redirection to the target page
https://westernrise.com/discount/GIFT22?redirect=%2Fcollections%2Fbottoms
@ihorduchenko
ihorduchenko / recommended-font-settings.css
Created October 11, 2023 06:52
Recommended setting for correct fonts displaying