Prevent order cycle validations on orders when feature toggled off.

This commit is contained in:
Andrew Spinks
2013-08-01 15:01:47 +10:00
parent 287bd57a4e
commit 46474ea4cc

View File

@@ -15,7 +15,11 @@ Spree::Order.class_eval do
def products_available_from_new_distribution
# Check that the line_items in the current order are available from a newly selected distribution
errors.add(:base, "Distributor or order cycle cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle)
if OpenFoodWeb::FeatureToggle.enabled? :order_cycles
errors.add(:base, "Distributor or order cycle cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle)
else
errors.add(:distributor_id, "cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distributor?(distributor)
end
end
def set_order_cycle!(order_cycle)