Skip to content

Instantly share code, notes, and snippets.

View JDutil's full-sized avatar
🍁

Jeff Dutil JDutil

🍁
View GitHub Profile
1 module Spree
ItemAdjustments.class_eval do
2
3 # Picks one (and only one) promotion to be eligible for this order
4 # This promotion provides the most discount, and if two promotions
5 # have the same amount, then it will pick the latest one.
6 def choose_best_promotion_adjustment
7 raise "#{adjustment}"
8 if best_promotion_adjustment
9 other_promotions = self.adjustments.promotion.where.not(id: best_promotion_adjustment.id)