Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

optional max_quantity_failsafe configuration setting

  • Loading branch information...
commit 582bed87c96890408675d910d9fa784c4952027e 1 parent 191d4fa
Bill Lipa authored September 21, 2011

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  app/models/amazon_fulfillment.rb
7  app/models/amazon_fulfillment.rb
@@ -85,6 +85,11 @@ def address
85 85
     }
86 86
   end
87 87
   
  88
+  def max_quantity_failsafe(n)
  89
+    return n unless Fulfillment.config[:max_quantity_failsafe]
  90
+    [Fulfillment.config[:max_quantity_failsafe], n].min
  91
+  end
  92
+  
88 93
   def line_items
89 94
     skus = @shipment.inventory_units.map do |io|
90 95
       sku = io.variant.sku
@@ -93,7 +98,7 @@ def line_items
93 98
     end.uniq
94 99
     skus.map do |sku|
95 100
       num = @shipment.inventory_units.select{|io| io.variant.sku == sku}.size
96  
-      { :sku => sku, :quantity => num }
  101
+      { :sku => sku, :quantity => max_quantity_failsafe(num) }
97 102
     end
98 103
   end
99 104
   

0 notes on commit 582bed8

Please sign in to comment.
Something went wrong with that request. Please try again.