Created
April 29, 2013 21:48
-
-
Save rterbush/5485079 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fixup order | |
a40.each_key do |k| | |
pair = k.split('|') | |
oid = pair[0] | |
sku = pair[1] | |
next unless oid == id | |
puts format("sku: %s ordered: %s filled: %s\n", sku, a40[k][0].to_i, a40[k][1].to_i) | |
ordered = a40[k][0].to_i | |
filled = a40[k][1].to_i | |
next if ordered == filled | |
# fixup order | |
puts format("change quantity for sku: %s from %s to %s", sku, ordered, filled) | |
order.each do |item| | |
variant = Spree::Variant.find_by_sku(sku) | |
li = item.line_items.find_by_id(variant.id) | |
next if li.blank? | |
puts "update line item" | |
li.update!(:quantity => filled) | |
end | |
end | |
order.each do |box| | |
box.shipment.confirm! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment