spree-contrib / spree_multi_currency

Provides UI to allow configuring multiple currencies in Spree.
http://guides.spreecommerce.org
BSD 3-Clause "New" or "Revised" License
41 stars 117 forks source link

currency display does not work for variants #20

Open zyferdigital opened 10 years ago

zyferdigital commented 10 years ago

Issue:

If you have "display currency" on, and product variants, changing the currency does not update the price or the currency code on the product detail page. Instead it shows the default currency price and code. The currency code and price show correctly on all other pages.

How to Replicate:

  1. ensure you have a product with multiple variants and with the prices set for each currency
  2. Turn on "display currency" in the general configurations
  3. go to the product detail page and switch to the non-default currency
  4. the price and variant prices will show in the default currency. the currency code will be the default currency.

    Note:

adding the product to cart at this point will add the product at the right price for the selected currency. I've removed all non-essential extensions and the problem still exists so it's not a conflict issue.

Expected Result

Display the price and variant price(s) in the correct currency price with the correct currency code

Spree, Rails, Gems:

Spree 2.2-stable, Rails 4.0.3.

source 'https://rubygems.org'

gem 'rails', '4.0.3'
gem 'mysql2'

gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'

group :assets do
  gem 'therubyracer', '0.10.2', :platforms => :ruby
  gem 'libv8', '3.3.10.4'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'

group :doc do
  gem 'sdoc', require: false
end

gem 'rvm-capistrano'

gem 'spree', github: 'spree/spree', branch: '2-2-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-2-stable'
gem 'spree_active_shipping', :git => "git://github.com/spree/spree_active_shipping", :branch => "2-2-stable"
gem 'spree_paypal_express', :github => "radar/better_spree_paypal_express", :branch => "2-2-stable"
gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', :branch => '2-2-stable'
gem "spree_comments", github: 'spree/spree_comments', :branch => '2-2-stable'
gem 'spree_static_content', github: 'spree/spree_static_content', branch: '2-2-stable'
gem 'spree_print_invoice' , :git => 'git://github.com/spree/spree_print_invoice.git', branch: '2-2-stable'
gem 'spree_related_products', :git => 'git://github.com/spree/spree_related_products.git', branch: '2-2-stable'

gem 'spree_multi_currency', :github => "spree/spree_multi_currency", branch: '2-2-stable'
gem 'spree_abandoned_cart_email'
JDutil commented 10 years ago

The issue is probably related to the fragment caching needing to switch based on current currency, which I thought I had fixed. Are you overriding the view templates at all? It should cache on currency like: https://github.com/spree/spree/blob/master/frontend/app/views/spree/products/show.html.erb#L1

zyferdigital commented 10 years ago

I am defacing the _cart_form view (setting some css classes, as well as replacing the add_to_cart div), but I did a clean install with no overrides and the problem exists in the vanilla version too. This only happens if you have multiple variants. If you only have a master product it correctly changes.

tomaswitek commented 9 years ago

Hi I just ran into the same problems. And it seems that there was a bug in a Spree v 2.4. It was solved in this commit: https://github.com/spree/spree/commit/a86a20ea3c114a859e1e7628304ddf5dfaf60af7. So the solution for you is to update your deface override according to the commit. Use variant.price_in(current_currency).money.

aishmita-aggarwal commented 8 years ago

This issue does not exist in master.