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 = 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 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
| 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 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
| customer = Input.cart.customer | |
| discount = 0 | |
| message = "" | |
| if customer | |
| if customer.orders_count > 2 #number of orders placed to get the deal | |
| discount = 1000 #discount amount in cents | |
| message = "VIP Customer - $10 off" | |
| end | |
| end | |
| puts discount |
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
| customer = Input.cart.customer | |
| discount = 0 | |
| message = "" | |
| if customer | |
| if customer.orders_count > 2 #number of orders needed to get discount | |
| discount = 0.2 #percent discount in decimal form | |
| message = "VIP Customer" | |
| end | |
| end | |
| puts discount |
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
| customer = Input.cart.customer | |
| discount = 0 | |
| message = "" | |
| if customer | |
| if customer.orders_count == 0 | |
| discount = 0.1 #change the discount given here | |
| message = "Thanks for placing your first order" #change the message shown here | |
| end | |
| puts discount |
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
| 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 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
| min_discount_order_amount = Money.new(cents:100) * 30 #number of dollars needed in cart to get the discount | |
| total = Input.cart.subtotal_price_was | |
| discount = if total > min_discount_order_amount | |
| 0.2 #discount percentage in decimal form | |
| else | |
| 0 | |
| end | |
| message = "My message" | |
| 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
| 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 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(25) / 100.0 | |
| Input.cart.line_items.each do |line_item| | |
| product = line_item.variant.product | |
| next if product.gift_card? | |
| next unless product.tags.include?('myTag') | |
| line_discount = line_item.line_price * @percent | |
| line_item.change_line_price(line_item.line_price - line_discount, message: "25% Off") | |
| 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
| DISCOUNTS_BY_QUANTITY = { | |
| 10_000 => 20, | |
| 1_000 => 15, | |
| 100 => 10, | |
| 10 => 5, | |
| } | |
| Input.cart.line_items.each do |line_item| | |
| next if line_item.variant.product.gift_card? |