Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A change was made recently to spree for multi-currency. #40

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions app/models/spree/line_item_decorator.rb
Expand Up @@ -3,25 +3,25 @@

# the idea here is compatibility with spree_sale_products
# trying to create a 'calculation stack' wherein the best valid price is
# chosen for the product. This is mainly for compatibility with spree_volume_pricing

# chosen for the product. This is mainly for compatibility with spree_sale_products
#
# Assumption here is that the volume price currency is the same as the product currency
old_copy_price = instance_method(:copy_price)
define_method(:copy_price) do
new_price = old_copy_price.bind(self).call
old_copy_price.bind(self).call

if variant and changed? and changes.keys.include? 'quantity'
vprice = self.variant.volume_price(self.quantity)
if variant
if changed? && changes.keys.include?('quantity')
vprice = self.variant.volume_price(self.quantity)

if (!new_price.nil? and vprice <= new_price) or vprice <= self.price
return self.price = vprice
if self.price.present? && vprice <= self.variant.price
self.price = vprice and return
end
end
end

if new_price.nil?
self.price = self.variant.price
else
self.price = new_price
if self.price.nil?
self.price = self.variant.price
end
end
end
end