Skip to content

Instantly share code, notes, and snippets.

discounted_product = 12275195905
products_needed = [592406273]
products_seen = []
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
products_seen << product.id if products_needed.include?(product.id)
end
Input.cart.line_items.each do |line_item|
@cbourdage
cbourdage / po-box-validation.js
Last active August 2, 2024 13:17
PO BOX js Regex validation
/**
1.1 Checkout
- Gorilla will add custom client side validation to the shipping method address field to test if the string contains a pattern of characters that would denote that the string contains the words PO Box.
- If the validation fails the user will be displayed a message stating that the shipping address cannot be a PO Box.
? P.O. Box
? PO. Box
? PO Box
? POBox
? P O Box
@zakhardage
zakhardage / Much much simpler option selector for Shopify
Last active July 13, 2024 21:36
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}