0

Can I create a cart and add the products to cart in same request? Maybe using something like variables to pass by the cartId.

asked Jul 30, 2020 at 14:49
1
  • describe some more detail, what you are looking for? Commented Aug 1, 2020 at 13:42

1 Answer 1

0

Yes, but you'd need to create your own graphql endpoint.

For your case, if you want to implement that type of custom graphql call, you'd need to take a look at vendor/magento/module-quote-graph-ql/etc/schema.graphqls

specifically both graphql calls:

 type Mutation {
 createEmptyCart(input: createEmptyCartInput): String @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CreateEmptyCart") @doc(description:"Creates an empty shopping cart for a guest or logged in user")
 addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")

then, the difficult part is to combine

\Magento\QuoteGraphQl\Model\Resolver\CreateEmptyCart with \Magento\QuoteGraphQl\Model\Resolver\AddSimpleProductsToCart into your own custom resolver.

it is doable but challenging. The customisation duplicates a lot of code out of these 2 resolvers and I do wonder whether that is worth the try

answered Aug 2, 2020 at 11:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.