Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Empty cart creation added #124

Merged
merged 14 commits into from Sep 11, 2018
Merged

Conversation

rogyar
Copy link
Contributor

@rogyar rogyar commented Jul 17, 2018

Description

Implementation of mutation for empty cart creation by the guest/customer user.
createEmptyCart mutation is declared which accepts no arguments. It returns a hashed cart ID for guest customers and the real hashed quote ID for logged in customers. The customer status (logged in/guest) is performed by checking authorization headers of the request.

Fixed Issues (if relevant)

  1. [Cart Operations] Create Empty Cart #118 : [Mutations] Cart Operations > Create Empty Cart

Manual testing scenarios

Use the following query to create an empty shopping cart:

mutation {
  createEmptyCart
}

To test with logged in customer, obtain the customer token and provide it in the request headers.

naydav
naydav previously requested changes Jul 19, 2018
Copy link
Contributor

@naydav naydav left a comment

Choose a reason for hiding this comment

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

Looks like we need to add new module to
composer.json (and regenerate composer.lock)

@paliarush
Copy link
Contributor

@rogyar I have modified requirements slightly. We need to return cart ID hash for registered customers as well. Please let me know if you could do that change in current task, otherwise we will create a separate one.

Sorry for the change, but this decision was made after the task was created.

@paliarush paliarush dismissed naydav’s stale review August 6, 2018 14:30

composer.json and composer.json added. Review is dismissed to unblock merge

*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value
{
$customerId = $context->getUserId();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid working with global $context object, it is possible to inject UserContextInterface via constructor instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my previous approach. But I saw that we already have UserContextInterface within a scope of $context and it doesn't make sense to inject it once again.
Thank you for the tip, I will roll back the changes

@rogyar rogyar mentioned this pull request Aug 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants