-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add template variants scope #5866
Conversation
5530edf
to
cc441df
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5866 +/- ##
=======================================
Coverage 89.24% 89.24%
=======================================
Files 754 754
Lines 17533 17536 +3
=======================================
+ Hits 15647 15650 +3
Misses 1886 1886 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, just left some notes on the naming. Let's discuss!
cc441df
to
1938a53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We paired on this
1938a53
to
1b5507d
Compare
All products have variants, but not all variants can actually be sold. When a product has option types, the sellable variants are those that are assigned to option values, whereas the "master" variant is only there as a template for other variants to be created. I'm using the language "template variant" because "master variant" because it more closely matches what the `is_master` flag on the Spree::Variant actually does.
Currently, one can add template variants to one's cart, but that should not be possible. This commit makes sure that the variant search won't return template variants.
1b5507d
to
6b4d76d
Compare
Summary
This introduces logic that removes the ability to add template ("master") variants to admin carts.
When a product has option types and option values, it can have multiple variants. It will also have a variant with the
is_master
flag set totrue
, but that variant will not be sellable in the frontend. For a t-shirt that has the option types "Size" and "Color", for example, the master variant would not have a color and not have a size - thus it would be impossible to actually buy.However, for items that don't have option types - single-variant products - the variant with the
is_master
flag is actually what customers would add to their cart. The logic in this PR respects that.If your store uses
.where(is_master: false)
to find out whether something is sellable, you can now instead do.sellable
.Checklist
The following are mandatory for all PRs:
The following are not always needed: