From 6fbc63116a1e306da7047b1193f440b3a56c4559 Mon Sep 17 00:00:00 2001 From: Chris Wise Date: Wed, 11 Apr 2012 11:17:19 -0400 Subject: [PATCH] fixed the opts and items hashes that are sent to PayPal to only show eligible promotions and to use existing Order methods for tax and shipping --- app/controllers/spree/checkout_controller_decorator.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index ad3d68f..8e78ef4 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -243,7 +243,7 @@ module Spree :depth => item.variant.weight } end - credits = order.adjustments.map do |credit| + credits = order.adjustments.eligible.map do |credit| if credit.amount < 0.00 { :name => credit.label, :description => credit.label, @@ -266,13 +266,10 @@ module Spree :custom => order.number, :items => items, :subtotal => ((order.item_total * 100) + credits_total).to_i, - :tax => ((order.adjustments.map { |a| a.amount if ( a.source_type == 'Spree::Order' && a.label == 'Tax') }.compact.sum) * 100 ).to_i, - :shipping => ((order.adjustments.map { |a| a.amount if a.source_type == 'Spree::Shipment' }.compact.sum) * 100 ).to_i, + :tax => (order.tax_total*100).to_i, + :shipping => (order.ship_total*100).to_i, :money => (order.total * 100 ).to_i } - # add correct tax amount by subtracting subtotal and shipping otherwise tax = 0 -> need to check adjustments.map - opts[:tax] = (order.total*100).to_i - opts.slice(:subtotal, :shipping).values.sum - if stage == "checkout" opts[:handling] = 0