-
Notifications
You must be signed in to change notification settings - Fork 117
[Woo POS] Initial mechanism to handle quantities and out of stock #12767
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
Conversation
|
products[index] = updatedProduct | ||
} | ||
|
||
func restoreInventory(_ product: POSProduct) { |
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.
This could simplified into an unique method for reducing/increasing, no strong reason to keep them separate at this point, just preference.
# Conflicts: # WooCommerce/Classes/POS/Presentation/CartView.swift # WooCommerce/Classes/POS/Presentation/ProductCardView.swift
// wp.me/p91TBi-bcW#comment-12123 | ||
product.stockQuantity <= 0 | ||
} | ||
|
||
var body: some View { |
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.
Maybe make the whole view a button so that tapping the entire view content adds the product to cart?
var body: some View {
Button(action: {
onProductCardTapped?()
}, label: {
VStack {
Text(product.name)
.foregroundStyle(Color.primaryBackground)
Text(outOfStock ? "Out of Stock" : product.price)
.foregroundStyle(Color.primaryBackground)
HStack(spacing: 8) {
QuantityBadgeView(product.stockQuantity)
.frame(width: 50, height: 50)
Spacer()
Button(action: {
onProductCardTapped?()
}, label: { })
.buttonStyle(POSPlusButtonStyle())
.frame(width: 56, height: 56)
}
}
.frame(maxWidth: .infinity)
.background(outOfStock ? Color.pink : Color.tertiaryBackground)
})
.buttonStyle(.plain)
}
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'll leave this change out for the moment, since we have a specific button for the +
and we do not know if tapping in the card itself should have a different behaviour (if any)
Thanks for the review!
Good catch! I've wrapped the product rows in a scroll view with 09c8216 , but future design iterations we may want to be more prominent about "there are more items down here!" |
Closes: #12750
Description
This PR adds an initial approach to handling quantities/available inventory between Product List and Cart:
Changes
stockQuantity
property to thePOSProduct
modelreduceInventory
or torestoreInventory
upon adding/removing products from cart.FilterView
andSearchView
in the dashboard. Both are non-functional and mostly un-styled.Testing instructions
Observe that:
0
threshold updates the product card color and text, as well as disallows adding further products.