This file contains hidden or 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
{% for tag in customer.tags %} | |
{% if customer.tags contains 'Wholesale' %} | |
<div class="cart-item__original-price"><del>{{ item.original_line_price | money }}</del></div> | |
{% endif %} | |
{% endfor %} | |
<div> | |
{{ item.line_price | money }} | |
</div> |
This file contains hidden or 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
Input.cart.line_items.each do |line_item| | |
customer = Input.cart.customer | |
product = line_item.variant.product | |
if customer.tags.include?("Wholesale") | |
line_item.change_line_price(line_item.line_price * 0.90, message: "Wholesale Customer") | |
end | |
end | |
Output.cart = Input.cart |
This file contains hidden or 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
PAID_ITEM_COUNT = 1 | |
DISCOUNTED_ITEM_COUNT = 1 | |
def discounted_items_to_find(total_items_seen, discounted_items_seen) | |
Integer(total_items_seen / (PAID_ITEM_COUNT + DISCOUNTED_ITEM_COUNT) * DISCOUNTED_ITEM_COUNT) - discounted_items_seen | |
end | |
def partition(cart, line_items) | |
sorted_items = line_items.sort_by{|line_item| line_item.variant.price}.reverse | |
This file contains hidden or 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
DISCOUNTS_BY_QUANTITY = { | |
100 => 20, | |
50 => 15, | |
25 => 10, | |
10 => 5, | |
} | |
Input.cart.line_items.each do |line_item| | |
next if line_item.variant.product.gift_card? |
This file contains hidden or 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
item = 0 | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
if product.product_type == "Underwear" | |
item+=line_item.quantity | |
elsif product.product_type == "Socks" | |
item+=line_item.quantity | |
end | |
end |
This file contains hidden or 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
discounted_product = FREE GIFT PRODUCT.ID | |
products_needed = [NEEDED PRODUCT.ID] | |
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| |
This file contains hidden or 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
discounted_product = FREE GIFT ID | |
products_needed = [PRODUCT THAT NEEDS TO BE ADDED FOR FREE GIFT] | |
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| | |
product = line_item.variant.product |
This file contains hidden or 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(){ | |
$('.add_to_cart').on('click', function(e){ | |
var variantId = VARIANTID GOES HERE; | |
jQuery.getJSON('/cart.js', function(data){ | |
var items = data.items; | |
console.log(items); | |
var currentVarId; | |
var quantity; |
This file contains hidden or 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
<button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %} {% if product.handle contains 'free-gift' %}free_item{% endif %}"> |
This file contains hidden or 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
@percent = Decimal.new(20) / 100.0 | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
next if product.gift_card? | |
next unless product.vendor.include?('Nike') | |
line_discount = line_item.line_price * @percent | |
line_item.change_line_price(line_item.line_price - line_discount, message: "20% off all Nike products!") | |
end | |
Output.cart = Input.cart |