Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
Merge pull request #8 from shioyama/remove_one_promotion_per_product_…
Browse files Browse the repository at this point in the history
…rule

Remove one promotion per product rule limitation.
  • Loading branch information
shioyama committed Oct 7, 2015
2 parents bcae1fd + cbcbd4f commit a3202fd
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions promo/app/models/spree/promotion/rules/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Promotion
module Rules
class Product < PromotionRule
has_and_belongs_to_many :products, :class_name => '::Spree::Product', :join_table => 'spree_products_promotion_rules', :foreign_key => 'promotion_rule_id'
validate :only_one_promotion_per_product

MATCH_POLICIES = %w(any all)
preference :match_policy, :string, :default => MATCH_POLICIES.first
Expand All @@ -32,14 +31,6 @@ def product_ids_string
def product_ids_string=(s)
self.product_ids = s.to_s.split(',').map(&:strip)
end

private

def only_one_promotion_per_product
if Spree::Promotion::Rules::Product.all.map(&:products).flatten.uniq!
errors[:base] << "You can't create two promotions for the same product"
end
end
end
end
end
Expand Down

0 comments on commit a3202fd

Please sign in to comment.