Permalink
Browse files

optional max_quantity_failsafe configuration setting

  • Loading branch information...
1 parent 191d4fa commit 582bed87c96890408675d910d9fa784c4952027e @wlipa wlipa committed Sep 21, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 app/models/amazon_fulfillment.rb
@@ -85,6 +85,11 @@ def address
}
end
+ def max_quantity_failsafe(n)
+ return n unless Fulfillment.config[:max_quantity_failsafe]
+ [Fulfillment.config[:max_quantity_failsafe], n].min
+ end
+
def line_items
skus = @shipment.inventory_units.map do |io|
sku = io.variant.sku
@@ -93,7 +98,7 @@ def line_items
end.uniq
skus.map do |sku|
num = @shipment.inventory_units.select{|io| io.variant.sku == sku}.size
- { :sku => sku, :quantity => num }
+ { :sku => sku, :quantity => max_quantity_failsafe(num) }
end
end

0 comments on commit 582bed8

Please sign in to comment.