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
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
{% 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
{% 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
{% for tag in customer.tags %} | |
{% if customer.tags contains 'Wholesale' %} | |
<h4>Wholesale Customer</h4> | |
{% endif %} | |
{% endfor %} |
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 product.tags.include?('discount') | |
if customer.tags.include?("Industry") | |
line_item.change_line_price(line_item.line_price * 0.40, message: "Industry Customer") | |
elsif customer.tags.include?("Pro") | |
line_item.change_line_price(line_item.line_price * 0.50, message: "Pro Customer") | |
elsif customer.tags.include?("Tier2") | |
line_item.change_line_price(line_item.line_price * 0.70, message: "Tier2 Customer") |
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
// original | |
<span id="ProductPrice-{{ section.id }}">{{ current_variant.price | money }}</span> | |
//script changes | |
{% if product.id == (example)123456789 %} //check if right product to discount | |
//linethrough original price if wholesale customer | |
{% if customer.tags contains 'Industry' or customer.tags contains 'Pro' or customer.tags contains 'Tier2' or customer.tags contains 'Tier3'%} | |
<del><span id="ProductPrice-{{ section.id }}">{{ product.price | money }}</span></del> | |
{% 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
{% for tag in customer.tags %} | |
{% if customer.tags contains 'Industry' %} | |
<h4>Industry Customer</h4> | |
{% elsif customer.tags contains 'Pro' %} | |
<h4>Pro Customer</h4> | |
{% elsif customer.tags contains 'Tier2' %} | |
<h4>Tier2 Customer</h4> | |
{% elsif customer.tags contains 'Tier3' %} | |
<h4>Tier3 Customer</h4> | |
{% 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
{% for discount in item.discounts %} //checks for items discounted in script | |
//original price | |
{% if customer.tags contains 'Industry' or customer.tags contains 'Pro' or customer.tags contains 'Tier2' or customer.tags contains 'Tier1'%} | |
<div class="cart-item__original-price"><del>{{ item.original_line_price | money }}</del></div> | |
{% endif %} | |
{% endfor %} | |
//new price after script runs | |
<div> | |
{{ item.line_price | money }} |