Skip to content

Instantly share code, notes, and snippets.

@davidgoldcode
Created September 14, 2022 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidgoldcode/d40bdcacb45741f714c5fba1b86198d6 to your computer and use it in GitHub Desktop.
Save davidgoldcode/d40bdcacb45741f714c5fba1b86198d6 to your computer and use it in GitHub Desktop.
diff --git a/app/commands/apply_individual_discounts.rb b/app/commands/apply_individual_discounts.rb
index e39a96cd8c..534d134020 100644
--- a/app/commands/apply_individual_discounts.rb
+++ b/app/commands/apply_individual_discounts.rb
@@ -3,7 +3,7 @@ class ApplyIndividualDiscounts
def perform(event_name, order)
return if event_name != "spree.cart.add" || order.blank?
- order.line_items_with_current_flash_sales.each do |line_item|
+ order.line_items_with_current_flash_sales.uniq.each do |line_item|
current_discount = line_item&.variant&.product&.current_discount
next if !current_discount || !current_discount[:is_individual_discount] || current_discount[:percent] == 0
percent = -0.01 * current_discount[:percent]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment