Skip to content

Instantly share code, notes, and snippets.

View CodeBrotha's full-sized avatar

Tineyi CodeBrotha

  • United States
View GitHub Profile
@CodeBrotha
CodeBrotha / line_item_combined_script.rb
Last active March 20, 2023 22:35
Shopify Scripts - Combined Line Item Script
# ================================================================
# ================================================================
# LINE ITEM COMBO SCRIPT
#
# This script runs multiple line item scripts.
#
# Currently contains:
#
# 1: PRODUCT QUANTITY LIMITS
# (Limits line item quantities per order)
@CodeBrotha
CodeBrotha / check-product-tags.liquid
Created August 12, 2022 00:23
Shopify Liquid - Check if product contains any of a given list of tags
{% assign excludedTags = "some-tag,some-other-tag,another-tag,yet-another-tag" | split :',' %}
{% assign hasExcludedTag = false %}
{% for tag in excludedTags %}
{% if product.tags contains tag %}
{% assign hasExcludedTag = true %}
{% break %}
{% endif %}
{% endfor %}
@CodeBrotha
CodeBrotha / line_item_property_discount.rb
Created November 11, 2021 00:34
Shopify Scripts - Line Item Properties Discount
Input.cart.line_items.each do |item|
# ================================================================
# LINE ITEM PROPERTY DISCOUNT
# ================================================================
# Set the line item property in Shopify theme When adding item to cart
#
# line item property is a key/value pair. Example: {"_someCoolPromo": "1"}
#
# In this example:
# "_someCoolPromo" is the key we look for here and must ALWAYS start with an underscore.
# Insomnia Configuration
## Run the test query
{
shop {
id
name
}
}
# Query Structure Examples
@CodeBrotha
CodeBrotha / Add SSH key to Keychain (macOS).md
Created May 20, 2021 16:02
Add SSH key to Keychain (macOS)
touch ~/.ssh/config

Open it and modify the file.

Host *
    AddKeysToAgent yes
    UseKeyChain yes
@CodeBrotha
CodeBrotha / Download Assets From Shopify Store Files.md
Last active June 3, 2021 00:03
Download Assets From Shopify Store Files
@CodeBrotha
CodeBrotha / Download a Shopify store's assets used in your theme.md
Created April 16, 2021 16:42 — forked from ridem/README.md
Download a Shopify store's assets used in your theme

It's hard to migrate section themes that rely heavily on images. This bit of code helps you download all the CDN assets of your theme.

  1. Create a cdn_assets folder
  2. Create the download_assets.js file at the root of your project
  3. Edit the download_assets.js file to match the path to your settings_data.json (line 3)
  4. Edit the download_assets.js file to set the "CDN code" of your store. Each file that you upload from /admin/settings/files gets uploaded with the following format: https://cdn.shopify.com/s/files/1/YOUR_CDN_CODE/files/YOURFILE. The format of the code is /\d{4}\/\d{4}/ (four digits, a forward slash, and four digits)
@CodeBrotha
CodeBrotha / Using Git With Multiple Emails.md
Last active May 2, 2022 21:25
Using Git With Multiple Emails

Git 2.13 introduced conditional configuration includes. For now, the only supported condition is matching the filesystem path of the repository, but that’s exactly what we need in this case.

You can configure your conditional includes by adding them to the bottom of your home directory’s ~/.gitconfig file:

[includeIf "gitdir:~/work/"]
  path = ~/.gitconfig-work
[includeIf "gitdir:~/specific-project/"]
  path = ~/.gitconfig-specific-project
@CodeBrotha
CodeBrotha / Heroku Staging & Production Remotes Setup.md
Last active June 15, 2022 04:01
Heroku Staging & Production Remotes Setup

List current remotes:

git remote -v

Add Heroku product & staging remotes:

Using Heroku-CLI:

heroku git:remote -a staging-app-name -r staging
# Use an array to keep track of the discount campaigns desired.
CAMPAIGNS = [
# $5 off all items with the "sale" tag
ItemCampaign.new(
AndSelector.new(
TagSelector.new("sale"),
ExcludeGiftCardSelector.new,
),
MoneyDiscount.new(5_00, "5$ off all items on sale",),
),