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
This commit is contained in:
parent
c1f8854e15
commit
6fbc63116a
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue