mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Extract params parsing into single method
This commit is contained in:
@@ -11,8 +11,7 @@ Spree::OrderPopulator.class_eval do
|
||||
|
||||
if valid?
|
||||
@order.with_lock do
|
||||
variants = read_products_hash(from_hash) +
|
||||
read_variants_hash(from_hash)
|
||||
variants = read_variants from_hash
|
||||
|
||||
variants.each do |v|
|
||||
if varies_from_cart(v)
|
||||
@@ -31,6 +30,11 @@ Spree::OrderPopulator.class_eval do
|
||||
valid?
|
||||
end
|
||||
|
||||
def read_variants(data)
|
||||
read_products_hash(data) +
|
||||
read_variants_hash(data)
|
||||
end
|
||||
|
||||
def read_products_hash(data)
|
||||
(data[:products] || []).map do |product_id, variant_id|
|
||||
{variant_id: variant_id, quantity: data[:quantity]}
|
||||
|
||||
Reference in New Issue
Block a user