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

[2.x] Disable checkout button and add notice if not in stock #627

Merged
merged 18 commits into from
Nov 20, 2024

Conversation

BobWez98
Copy link
Collaborator

@BobWez98 BobWez98 commented Nov 4, 2024

Whenever a product in cart is out of stock, there will be a notice with the product that notifies the user of the product being out of stock. This functionality also disables the "proceed to checkout" button.

V3: #628

Internally there's a story to have some extra frontend added for this.

@royduin
Copy link
Member

royduin commented Nov 5, 2024

There should be an is_available field for this: https://developer.adobe.com/commerce/webapi/graphql-api/index.html#definition-CartItemInterface, does that work?

@BobWez98
Copy link
Collaborator Author

BobWez98 commented Nov 5, 2024

It will work in the next release of magento, right now it doesn't and always returns false: magento/magento2@2a406ec#diff-fdd1cac7f74cd87aececd50e3dee357414ab901e8ceaa27c4c2cf3d529f19e55R50

@royduin
Copy link
Member

royduin commented Nov 5, 2024

@indykoning, what do you think?

Comment on lines 115 to 121
canOrderCartItem(item) {
if ('stock_item' in item.product && 'in_stock' in item.product.stock_item && item.product.stock_item.in_stock !== null) {
return item.product.stock_item.in_stock
}

return true
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cart Store may be a more logical place for this.
We're already adding additional data to items here

value.items = value.items.map((cartItem) => {

Maybe we could do it in a way to polyfill the currently broken is_available so once we drop support for Magento versions that do have it in it's broken state we can remove this code without breaking changes to the frontend

@BobWez98 BobWez98 requested a review from indykoning November 14, 2024 10:34
indykoning
indykoning previously approved these changes Nov 15, 2024
@royduin royduin merged commit 9cc8bc9 into 2.x Nov 20, 2024
15 checks passed
@royduin royduin deleted the feature/cart-not-in-stock branch November 20, 2024 16:16
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

Successfully merging this pull request may close these issues.

3 participants