-
Notifications
You must be signed in to change notification settings - Fork 112
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
[Woo POS] [Variable Products] Show variation name based on variation and variable product attributes #14807
Conversation
…om WooCommerce to Yosemite and use `ProductVariationFormatter` to generate variation name in POS with `allAttributes` in `POSParentProductType.variable` associated type.
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
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.
Works as expected, thanks!
One suggestion inline to improve encapsulation of allAttributes
.
One thought for future improvement: the names the existing code generates might not be ideal for POS. If that would stop you reusing the code, perhaps it would be better not to merge this one with the move and reuse, and instead add a new name generator. Or we improve the names in both places.
The issue is that the names are primarily made up of the value of the attribute, and don't include attribute names.
With a single simple attribute like Colour, it's pretty clear, but what if a product had two colour attributes making up it's variation – e.g. a printed t-shirt with fabric colour, and printing colour. That might be called White - Black - S
, for a white T-shirt with Black printing in size S... but it might be called Black - White - M
for a black T with white printing. The merchant would need to use the image (if supplied for every variation) or remember the order.
This is probably also something we should improve in the main app, as when fulfilling web orders it'd be bad to pick the wrong variation. In POS we currently have lots of space for the name, so it looks particularly silly to leave attribute names off. See this screenshot – there's context for the Yes/No bit from the Any Logo variant, but most stores shouldn't use Any variations anyway.
public enum POSParentProductType: Equatable, Hashable { | ||
case variable(allAttributes: [ProductAttribute]) |
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.
I don't think we ever use the associated value outside of Yosemite, right?
What do you think about having a specific POSVariableParentProduct
type, instead of using a type enum here? If we did that, attributes
could be an internal property, and only used inside Yosemite. It might prove easier to handle than an enum with associated types, too.
It would mean having a different display approach for POSGroupedProduct
or POSCategory
, but it's reasonably likely that we'll want to display those differently in the grid anyway.
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.
I don't think we ever use the associated value outside of Yosemite, right?
Correct, allAttributes is only used in Yosemite.
What do you think about having a specific
POSVariableParentProduct
type, instead of using a type enum here? If we did that,attributes
could be an internal property, and only used inside Yosemite. It might prove easier to handle than an enum with associated types, too.It would mean having a different display approach for
POSGroupedProduct
orPOSCategory
, but it's reasonably likely that we'll want to display those differently in the grid anyway.
Good point on making allAttributes an internal property in Yosemite. I tried it first by renaming POSParentProductType
to POSVariableParentProduct
, but it means views like ChildItemList
and ParentProductCardView
start depending on a "variable parent product" instead of a general parent product. It requires some refactoring, I will merge this first and show the changes in a separate PR.
As a medium approach to keep allAttributes internal, I updated the associated type of allAttributes to a struct POSVariableParentProduct
in 7c365a3.
…th allAttributes as an internal property.
Thanks for raising this, I was following the Android approach (example pffQ75-XG-p2#comment-762) which reuses the variation name in other parts of the app. I posted a question in p1736303462081769-slack-C070SJRA8DP for discussion to have a consistent variation name display across platforms. Ideally, we can improve it for other parts of the app as well. I'm merging this PR first and will open a PR to follow up on #14807 (comment). |
Closes: #14702
Please review #14793 first.
Description
The PR adds support to show the name for variations in the POS item selector the same way as in the products tab. The key changes involve updating the
POSParentProductType
to include attributes from a variable product, moving and modifying theProductVariationFormatter
andVariationAttributeViewModel
classes, and generating variation name in thePointOfSaleItemService
.Changes to Product Variations and Attributes Handling:
POSParentProductType
now includes attributes, which allows for generating the name of product variations to show attributes in the expected order including "any" attributes. (Yosemite/Yosemite/PointOfSale/POSParentProduct.swift
)PointOfSaleItemService
. (Yosemite/Yosemite/PointOfSale/PointOfSaleItemService.swift
) [1] [2]providePointOfSaleVariationItems
method to useProductVariationFormatter
for generating variation names. (Yosemite/Yosemite/PointOfSale/PointOfSaleItemService.swift
)Code Refactoring and File Management:
ProductVariationFormatter
from WooCommerce to Yosemite and made it public. (Yosemite/Yosemite/Tools/ProductVariations/ProductVariationFormatter.swift
) [1] [2]VariationAttributeViewModel
to Yosemite project files to support variation attribute handling. (Yosemite/Yosemite.xcodeproj/project.pbxproj
) [1] [2]Miscellaneous Changes:
Hashable
forProductAttribute
to support hashing. (Networking/Networking/Model/Product/ProductAttribute.swift
)WooCommerce/Classes/POS/Controllers/PointOfSaleItemsController.swift
)PointOfSaleItemService
that generates the variation name based on attributes. (WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift
,WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift
,WooCommerce/Classes/POS/Presentation/ParentProductCardView.swift
,WooCommerce/Classes/POS/Utils/PreviewHelpers.swift
) [1] [2] [3] [4]Steps to reproduce
🗒️ As the variable products support requires WC version 9.6+ which is not publicly released at the time of writing, I'd recommend commenting out L214 in ProductsRemote to include all product types.
Testing information
Screenshots
Simulator.Screen.Recording.-.iPad.Pro.11-inch.M4.-.2025-01-07.at.13.19.13.mp4
RELEASE-NOTES.txt
if necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: