-
Notifications
You must be signed in to change notification settings - Fork 79
CIF-1317 - Support Virtual Products #241
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
Add the customer cart and the merge carts related queries Update the cart initialized to read the cart data.
Reset the cart cookie after signing out
The hook that triggered the cart merging had some unwanted dependencies (e.g. `cartId` ) that we don't really need so I removed those. Remove console statements.
… on cart as well.
- get rid of all the `useEffect` hooks that were making the code more readable (and less error-prone) - add a `useAwaitQuery` hook so that we can invoke graphql queries using asyn/await syntax - save the customer's cart id in the state (will be merged down in the CartContext if needed)
… context. Update unit tests Remove an old "cart initializer" script
…ate not to be updated properly
…tching the same cart in a sign-out / sign-in again scenario.
…e "Continue shopping" button is clicked.
- don't pass the `Authorizatio` header if the token is empty - `useReceipt`: call the `continueShopping` function directly instead of asynchronously - `useOverview`: update the state in a `finally` block.
…nents into issue/CIF-1317
cjelger
left a comment
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.
Looks good: the only open question is whether we want to support adding multiple products of different types at the same time, say for example a grouped product composed of one virtual product and one "normal" product. WDYT?
| @@ -1,5 +1,6 @@ | |||
| query cartDetails($cartId: String!) { | |||
| cart(cart_id: $cartId) { | |||
| is_virtual | |||
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.
Is this true only when all the cart products are virtual?
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.
Yes. As soon as one physical item is in the cart, this property is false.
| dispatch({ type: 'beginLoading' }); | ||
| return addItem({ | ||
|
|
||
| let addItemFunc = ev.detail.virtual ? addVirtualItem : addItem; |
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.
Hmmm, shouldn't we have that virtual attribute per item added to the cart? What if we have a grouped product composed of two virtual products and one normal product? Not sure if this is realistic, but it would be better to support that, WDYT?
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 will try if a grouped product can be composed of virtual and physical products.
We would need to split the query then however into addSimpleProductsToCart and addVirtualProductsToCart mutations.
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.
Not sure if this works OOTB in Magento, but I've seen countless of "Guitar, amp and 1yr subscription to online course" offers, so it's a valid business case.
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 created a follow up JIRA for this and will work on it after the release :)
| dispatch({ type: 'beginLoading' }); | ||
| return addItem({ | ||
|
|
||
| let addItemFunc = ev.detail.virtual ? addVirtualItem : addItem; |
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.
Not sure if this works OOTB in Magento, but I've seen countless of "Guitar, amp and 1yr subscription to online course" offers, so it's a valid business case.
Codecov Report
@@ Coverage Diff @@
## master #241 +/- ##
=======================================
Coverage 48.02% 48.02%
=======================================
Files 105 105
Lines 3096 3096
Branches 595 595
=======================================
Hits 1487 1487
Misses 1609 1609
Continue to review full report at Codecov.
|
Description
addVirtualProductsToCartmutation to add virtual products to cart.How Has This Been Tested?
Types of changes
Checklist: