Find variant overrides for some hubs

This commit is contained in:
Rohan Mitchell
2014-11-26 13:07:18 +11:00
parent 91b386003a
commit ff28da345d
2 changed files with 16 additions and 0 deletions

View File

@@ -2,6 +2,10 @@ class VariantOverride < ActiveRecord::Base
belongs_to :variant, class_name: 'Spree::Variant'
belongs_to :hub, class_name: 'Enterprise'
scope :for_hubs, lambda { |hubs|
where(hub_id: hubs)
}
def self.price_for(variant, hub)
VariantOverride.where(variant_id: variant, hub_id: hub).first.andand.price
end