This file contains 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
customer = Input.cart.customer | |
discount = 0 | |
message = "" | |
if customer | |
if customer.accepts_marketing? #determines if the customer accepts marketing | |
discount = 1000 #number of Dollars to discount in cents | |
message = "Accepts Marketing Discount" #message to customer when they get the discount | |
end | |
end | |
puts discount |
This file contains 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
customer = Input.cart.customer | |
discount = 0 | |
message = "" | |
if customer | |
if customer.orders_count < 1 | |
discount = 1000 #discount amount in cents | |
message = "New Customer - $10 off" | |
end | |
end | |
puts discount |
This file contains 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 = 1522083265 | |
products_needed = [592406273, 4283854977, 4284984897] | |
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 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
discount = Money.new(cents: 100) * 5 | |
discounted_product = 1522083265 | |
products_needed = [592406273, 4283854977, 4284984897] | |
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 |
This file contains 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
min_discount_order_amount = Money.new(cents:100) * 30 #minimum amount needed to have in cart to get discount | |
total = Input.cart.subtotal_price_was | |
discount = if total > min_discount_order_amount | |
500 #discount amount you are offering in cents | |
else | |
0 | |
end | |
message = "Here's $5 off" #discount message shown to customer | |
Input.cart.line_items.each do |line_item| |
This file contains 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
total = Input.cart.subtotal_price_was | |
discount = 0.2 #discount percent in decimal format | |
message = "20% off Sitewide" #message to show when discount is applied | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
next if product.gift_card? | |
line_item.change_line_price(line_item.line_price * (1-discount), message: message) unless discount == 0 | |
end |
This file contains 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(){ | |
// when I click on the add to cart button | |
$('.add_to_cart').on('click', function(e){ | |
var variantId = 12275195905; | |
jQuery.getJSON('/cart.js', function(data){ | |
var items = data.items; | |
console.log(items); | |
var currentVarId; |
This file contains 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
{% if cart.item_count == 0 %} | |
<div class="sixteen columns"> | |
<div class="section clearfix"> | |
<div class="six columns offset-by-five"> | |
<p class="quote">{{ 'cart.general.continue_browsing_html' | t }}</p> | |
<a href="{% if cart.items.first.product.collections != blank %}{{ cart.items.first.product.collections.last.url }}{% else %}/collections/all{% endif %}" class="action_button continue-button add_to_cart">{{ 'cart.general.continue_shopping_link_html' | t }}</a> | |
</div> | |
<br class="clear" /> | |
</div> | |
</div> |
This file contains 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 = 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| |
This file contains 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" class="action_button add_to_cart {% if product.handle contains 'oil-pulling-pack' %}free_item{% endif %}" data-label={{ add_to_cart_label | json }}> |