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

Product with no master price in currency of user crashes "offers" with NoMethodError in Spree::Taxons#show #2602

Closed
mntmn opened this issue Feb 26, 2018 · 2 comments
Assignees

Comments

@mntmn
Copy link

mntmn commented Feb 26, 2018

Steps to reproduce

  1. Make taxons like Hardware -> SpecialHardware
  2. Make a product with just USD master price of $1
  3. Assign only taxon "SpecialHardware" to this product
  4. As an EUR customer, go to http://localhost:3000/t/hardware (the parent taxon!)

Expected behavior

Expect to see no products.

Actual behavior

Shop crashes with NoMethodError in Spree::Taxons#show

Showing /var/lib/gems/2.3.0/gems/solidus_frontend-2.5.0.beta2/app/views/spree/shared/_products.html.erb where line #35 raised:

undefined method `to_d' for nil:NilClass

The line is:
<span class="price selling" itemprop="price" content="<%= product.price_for(current_pricing_options).to_d %>">

The crash occurs because product.price_for(current_pricing_options) is nil in that moment.

System configuration

Solidus Version:

gem 'solidus', '2.5.0.beta2'
gem 'deface'
gem 'solidus_auth_devise', '2.1.0'

Extensions in use:
gem 'solidus_paypal_braintree', github: 'solidusio/solidus_paypal_braintree', branch: :master

@mntmn
Copy link
Author

mntmn commented Feb 26, 2018

@jhawthorn jhawthorn self-assigned this Feb 27, 2018
@jhawthorn
Copy link
Contributor

Thanks for the detailed report. Also, hi! I follow you on twitter and am a fan of your work.

The issue seems to be that taxon_preview doesn't use the Searcher (everywhere else displaying Products does) and therefore doesn't filter out products which don't match the current pricing options. Tomorrow I'll take a look at either filtering the products in this taxon by the current pricing options or using the searcher here.

A second bug here is I don't think _products.html.erb should have errored. We have a show_products_without_price Config setting, so we should allow rendering this view with a product lacking a price. I'll also look at this tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants