Created
April 16, 2014 00:05
-
-
Save shioyama/10791298 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
Spree::OrderPopulator.class_eval do | |
def populate_with_options(from_hash) | |
binding.pry | |
if variants_with_options = from_hash[:variants].select { |variant, quantity| quantity.is_a?(Hash) } | |
variants_with_options.each do |variant_id, options| | |
quantity = options.delete(:quantity) || 1 | |
attempt_cart_add(variant_id, quantity) | |
if (line_item = order.line_items.where(variant_id: variant_id).first) | |
line_item.assign_options!(options) | |
end | |
from_hash[:variants].delete(variant_id) | |
end | |
end | |
populate_without_options(from_hash) | |
end | |
alias_method_chain :populate, :options | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment