From 698ae27da18782b09ea05d7c115d521a60785ae0 Mon Sep 17 00:00:00 2001 From: Massimiliano Tavanti Date: Sun, 10 Nov 2013 15:33:16 +0100 Subject: [PATCH 1/2] fix nil cost_price + operator bug --- app/models/spree/line_item_decorator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/spree/line_item_decorator.rb b/app/models/spree/line_item_decorator.rb index ace9380..a945146 100644 --- a/app/models/spree/line_item_decorator.rb +++ b/app/models/spree/line_item_decorator.rb @@ -34,7 +34,8 @@ def options_text end def cost_price - variant.cost_price + ad_hoc_option_values.map(&:cost_price).inject(0, :+) + #due to the fact that cost_price can be nil we must convert it into bigdecimal (to_f will make nil->0 without losing precision in case of value) + variant.cost_price.to_f.to_d + ad_hoc_option_values.map(&:cost_price).inject(0, :+) end def cost_money From 9aec142e1d07ae762e7db64d5659dbe475d243fa Mon Sep 17 00:00:00 2001 From: Massimiliano Tavanti Date: Sun, 10 Nov 2013 16:14:54 +0100 Subject: [PATCH 2/2] fix a bug on merge! function... it now accept as second argument user even if not used + added add label to locale file en --- app/models/spree/order_decorator.rb | 2 +- config/locales/en.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb index 8d86490..b90ece4 100644 --- a/app/models/spree/order_decorator.rb +++ b/app/models/spree/order_decorator.rb @@ -37,7 +37,7 @@ def contains?(variant, ad_hoc_option_value_ids, product_customizations) end end - def merge!(order) + def merge!(order, user) order.line_items.each do |line_item| self.add_variant(line_item.variant, line_item.quantity, line_item.ad_hoc_option_value_ids, line_item.product_customizations) end diff --git a/config/locales/en.yml b/config/locales/en.yml index 6bfdbcc..f0ae563 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,6 @@ --- en: + add: "Add" required: "Required?" price_modifier: "Price Adjustment" price_modifier_type: "What price modifier strategy does this option type use?" @@ -46,4 +47,4 @@ en: customize: 'Customize' reset: 'Reset' position_within_product: 'Display order relative to other Ad Hoc Options (low numbers are displayed first)' - selected_by_default: 'Selected by default?' \ No newline at end of file + selected_by_default: 'Selected by default?'