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

[Cart Operations] Add simple product to Cart #141

Closed
misha-kotov opened this issue Aug 3, 2018 · 4 comments
Closed

[Cart Operations] Add simple product to Cart #141

misha-kotov opened this issue Aug 3, 2018 · 4 comments
Assignees
Labels

Comments

@misha-kotov
Copy link

misha-kotov commented Aug 3, 2018

As a Magento developer, I need to manipulate the shopping cart via GraphQL so that I can build basic ecommerce experiences for shoppers on the front-end using only GraphQL.

GraphQL needs to provide sufficient mutations (ways to create/update/delete data) for a developer to build out the storefront checkout experience for a shopper.

Use cases:

  • Both guest and registered shoppers can add simple products to cart

Acceptance criteria:

  • Cart operations should be useable in both standard Cart and mini-cart
  • GraphQL provides the following mutations:
    • addCartItems
  • All product types are supported in a modular way (e.g. configurable-related schema and resolvers must be declared in ConfigurableProductGraphQl module and the rest of the system should still work if this module is disabled)
  • Depending on token in Authorization header (if any), customer or guest service contract should be used
  • Changes are covered with web API functional tests. See \Magento\GraphQl\TestModule\GraphQlMutationTest::testMutation as an example.

Proposed schema

Example of typeResolver:

interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description: "The ProductInterface contains attributes that are common to all types of products. Note that descriptions may not be available for custom and EAV attributes.") {

My Account area impacted:

  • Cart
  • Minicart
@roma-glushko roma-glushko self-assigned this Aug 8, 2018
roma-glushko pushed a commit that referenced this issue Sep 2, 2018
@paliarush paliarush added large and removed small labels Sep 4, 2018
roma-glushko pushed a commit that referenced this issue Sep 4, 2018
roma-glushko pushed a commit that referenced this issue Sep 5, 2018
roma-glushko pushed a commit that referenced this issue Sep 6, 2018
roma-glushko pushed a commit that referenced this issue Sep 6, 2018
roma-glushko pushed a commit that referenced this issue Sep 6, 2018
roma-glushko pushed a commit that referenced this issue Sep 7, 2018
roma-glushko pushed a commit that referenced this issue Sep 7, 2018
roma-glushko pushed a commit that referenced this issue Sep 7, 2018
roma-glushko pushed a commit that referenced this issue Sep 7, 2018
roma-glushko pushed a commit that referenced this issue Sep 19, 2018
roma-glushko pushed a commit that referenced this issue Sep 19, 2018
@roma-glushko
Copy link
Member

Hi @paliarush @naydav ,
can you please take a look at my changes? I had to decouple resolvers cause they were not passed Travis complexity checking. However, I afraid it might contain design solutions now you probably don't want to see merged.

Let me know if you any concerning about the current changes. I will change everything as soon as I can.
Thanks,
Roma.

@naydav
Copy link
Contributor

naydav commented Sep 26, 2018

Example of request:

mutation {
  addSimpleProductsToCart(
    input: {
      cart_id: "b96566a020b8797b7d806a948174275e", 
      cartItems: [
        {
          data: {
            sku: "product_dynamic_24494", 
            qty: 1
          }, 
          customizable_options: [
            {id: 5, value: "test"},
            {id: 6, value: "5"}
          ]
        }
      ]
    }
  ) {
    
    cart {
      items {
        id
        qty
        ... on SimpleCartItem {
          customizable_options {
            id
            label
            type
            is_required
            values {
              id
              label
              value
              price {
                type
                units
                value
              }
            }
          }
        }
        product {
          sku
          name
          image
          url_key
          categories {
            id
            name
          } 
          updated_at
          websites {
            name
          }
        }
      }
    }    
  }
}

magento-engcom-team added a commit that referenced this issue Oct 3, 2018
 - Merge Pull Request #170 from magento/graphql-ce:141-add-simple-product-to-cart
 - Merged commits:
   1. eea5cdd
   2. 50a928c
   3. 5105989
   4. 1734dfc
   5. 7e7e82c
   6. 01404a0
   7. 1064854
   8. 34e0106
   9. e8011a8
   10. 436dee7
   11. 4942c6f
   12. e901431
   13. 7990b83
   14. ada51dc
   15. 484c65c
   16. 6b7300a
   17. c21a016
   18. d39230e
   19. d43164b
   20. fa5940a
   21. c78b993
   22. 7e3c023
@naydav
Copy link
Contributor

naydav commented Oct 3, 2018

#170

@naydav naydav closed this as completed Oct 3, 2018
magento-engcom-team added a commit that referenced this issue Dec 6, 2018
 - Merge Pull Request magento-engcom/import-export-improvements#141 from maxalmonte14/import-export-improvements:improvement/supress_undefined_connection_property_error
 - Merged commits:
   1. ac90f7a
   2. 6789eb4
   3. 7f3808c
   4. 5ff88c0
@naydav naydav added this to the Release: 2.3.1 milestone Dec 7, 2018
@naydav naydav added the 2.3.1 label Dec 7, 2018
@naydav naydav changed the title [Mutations] Cart Operations > Add simple product to Cart [Cart Operations] Add simple product to Cart Dec 12, 2018
naydav pushed a commit that referenced this issue Jun 12, 2019
@prabhakaran777
Copy link

prabhakaran777 commented Dec 13, 2019

Screenshot from 2019-12-13 12-23-08

mutation {
  addSimpleProductsToCart(
    input: {
      cart_id: "XvbSgHh6RbXgElGAhLhGDeIFHu8rAXCZ"
      cart_items: [
        {
          data: {
            quantity: 1
            sku: "Product option values"
         
          }
          
          customizable_options:[
          {
            id:1
            value_string:"Second"	
            
          }
        ]
        }
      ]
    }
  ) {
    cart {
      items {
        id
        product {
          sku
          stock_status
        }
        ... on SimpleCartItem{
          id
        customizable_options{
        id
         values{
          value
          price{
            value
          }
        }
        }
                
        
         
      
        }
        quantity
      }
    }
  }
}

i had tried this way but error


{
  "errors": [
    {
      "message": "Could not add the product with SKU Product option values to the shopping cart: Some of the selected options are not currently available.",
      "category": "graphql-input",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "addSimpleProductsToCart"
      ]
    }
  ],
  "data": {
    "addSimpleProductsToCart": null
  }
}

any one could help me plz...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants