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

Have Spree::Product#prices return master prices #969

Merged
merged 1 commit into from Mar 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Have Spree::Product#prices return master prices
All other associations are `:through variants_including_master`, this
one strangely is not.
mamhoff committed Mar 10, 2016
commit cf39aa6e298143ee605d80dc556838711736ebf3
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Solidus 1.3.0 (unreleased)

* Make Spree::Product#prices association return all prices

Previously, only non-master variant prices would have been returned here.
Now, we get all the prices, including those from the master variant.

https://github.com/solidusio/solidus/pull/969

* Changes to Spree::Stock::Estimator

* The package passed to Spree::Stock::Estimator#shipping_rates must have its
2 changes: 1 addition & 1 deletion core/app/models/spree/product.rb
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ class Product < Spree::Base
class_name: 'Spree::Variant',
dependent: :destroy

has_many :prices, -> { order(Spree::Variant.arel_table[:position].asc, Spree::Variant.arel_table[:id].asc, :currency) }, through: :variants
has_many :prices, -> { order(Spree::Variant.arel_table[:position].asc, Spree::Variant.arel_table[:id].asc, :currency) }, through: :variants_including_master

has_many :stock_items, through: :variants_including_master