GithubHelp home page GithubHelp logo

robertsbriedis / quote-graphql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scandipwa/quote-graphql

0.0 0.0 0.0 108 KB

Quote GraphQL endpoints

License: Open Software License 3.0

PHP 100.00%

quote-graphql's Introduction

ScandiPWA_QuoteGraphQl

QuoteGraphQl provides basic types and resolvers for Checkout steps.

Endpoint description

All endpoints here should accept the same data as the API does. For an api reference, please follow this link

IMPORTANT NOTE: every following mutation and query work without specifying the quote_id param (or quoteId). If none quote id is specified the resolver will attempt to load the quote id from Auth header, where auth token should be present. If quoteId is passed, it will treat it as a guest request, so the quote_id should be encoded.

IMPORTANT NOTE: this endpoint is an alternative for Magento 2 GraphQL Quote endpoint that is storing quote_id for authorized customer on server (using state-full approach).

getCartForCustomer

This endpoint allows to get full cart data (items + totals).

query GetCartForCustomer ($_guestCartId_0: String) {
    getCartForCustomer(guestCartId: $_guestCartId_0) {
        id
        tax_amount
        subtotal
        discount_amount
        subtotal_with_discount
        grand_total
        items {
            item_id
            qty
            product {
                price {
                    maximalPrice {
                        amount {
                            value
                            currency
                        }
                        adjustments {
                            code
                            amount {
                                value
                                currency
                            }
                        }
                    }
                }
            }
        }
    }
}
{
  "_guestCartId_0":"xIXmScRLWb5ntIEsYe2ymzrVXYraivGx"
}

saveCartItem

type cartItem now implements sub-type of CartItemId, that allows to reference by one of many: item_id or product SKU. This will become non-nullable in the future releases, when "sku" and "item_id" will be dropped.

This endpoint allows to submit items to cart following the default API payload schema. In beneath example is a simple product option addition to cart.

mutation SaveCartItem ($_cartItem_0: CartItemInput!, $_guestCartId_0: String) {
    saveCartItem(cartItem: $_cartItem_0, guestCartId: $_guestCartId_0) {
        getCartForCustomer(guestCartId: $_guestCartId_0) {
            id
            tax_amount
            subtotal
            discount_amount
            subtotal_with_discount
            grand_total
            items {
                item_id
                qty
                product {
                    price {
                        maximalPrice {
                            amount {
                                value
                                currency
                            }
                            adjustments {
                                code
                                amount {
                                    value
                                    currency
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
{
  "_cartItem_0":{
    "sku":"Test simple product",
    "product_type":"simple",
    "qty":1,
    "product_option": {
        "extension_attributes":{}
    }
  },
  "_guestCartId_0":"xIXmScRLWb5ntIEsYe2ymzrVXYraivGx"
}

removeCartItem

mutation RemoveCartItem($item_id: Int!, $_guestCartId_0: String) {
    removeCartItem(item_id: $item_id, guestCartId: $_guestCartId_0) {
        getCartForCustomer(guestCartId: $_guestCartId_0) {
            id
            tax_amount
            subtotal
            discount_amount
            subtotal_with_discount
            grand_total
            items {
                item_id
                qty
                product {
                    price {
                        maximalPrice {
                            amount {
                                value
                                currency
                            }
                            adjustments {
                                code
                                amount {
                                    value
                                    currency
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
{
   "item_id": 1,
   "quoteId": "s44Xcnya8dmbysAeNTOozFsZCh8tyCH9"
}

estimateShippingCosts

mutation EstimateShippingCosts(
    $guestCartId: String!
    $address: EstimateShippingCostsAddress!
) {
    estimateShippingCosts(address: $address, guestCartId: $guestCartId) {
        carrier_code
        method_code
        carrier_title
        method_title
        error_message
        amount
        base_amount
        price_excl_tax
        price_incl_tax
        available
    }
}
{
  "guestCartId": "s44Xcnya8dmbysAeNTOozFsZCh8tyCH9",
  "address": {
      "region": "New York",
      "region_id": 43,
      "region_code": "NY",
      "country_id": "US",
      "street": [
      	"123 Oak Ave"
      ],
      "postcode": "10577",
      "city": "Purchase",
      "firstname": "Jane",
      "lastname": "Doe",
      "customer_id": 4,
      "email": "[email protected]",
      "telephone": "(512) 555-1111",
      "same_as_billing": 1
  }
}

saveAddressInformation

mutation SaveAddressInformation(
  	$addressInformation: SaveAddressInformation!
  	$guestCartId: String
) {
	saveAddressInformation(
		addressInformation: $addressInformation,
    	guestCartId: $guestCartId
  	) {
  		payment_methods {
    		code
    		title
  		}
    	totals {
			grand_total
      		items {
        		name
        		qty
      		}
    	}
	}
}
{
   "guestCartId": "s44Xcnya8dmbysAeNTOozFsZCh8tyCH9",
   "addressInformation":{
      "shipping_address":{
         "region":"New York",
         "region_id":43,
         "region_code":"NY",
         "country_id":"US",
         "street":[
            "123 Oak Ave"
         ],
         "postcode":"10577",
         "city":"Purchase",
         "firstname":"Jane",
         "lastname":"Doe",
         "email":"[email protected]",
         "telephone":"512-555-1111"
      },
      "billing_address":{
         "region":"New York",
         "region_id":43,
         "region_code":"NY",
         "country_id":"US",
         "street":[
            "123 Oak Ave"
         ],
         "postcode":"10577",
         "city":"Purchase",
         "firstname":"Jane",
         "lastname":"Doe",
         "email":"[email protected]",
         "telephone":"512-555-1111"
      },
      "shipping_carrier_code":"flatrate",
      "shipping_method_code":"flatrate"
   }
}

savePaymentInformationAndPlaceOrder

mutation SavePaymentInformationAndPlaceOrder(
  $paymentInformation: PaymentInformation!,
  $guestCartId: String,
) {
  	savePaymentInformationAndPlaceOrder(
  		paymentInformation: $paymentInformation,
    	guestCartId: $guestCartId
  ) {
  	orderID
  }
}
{
  "guestCartId": "s44Xcnya8dmbysAeNTOozFsZCh8tyCH9",
  "paymentInformation": {
    "paymentMethod": {
        "method": "checkmo"
    },
    "billing_address":{
       "region":"New York",
       "region_id":43,
       "region_code":"NY",
       "country_id":"US",
       "street":[
          "123 Oak Ave"
       ],
       "postcode":"10577",
       "city":"Purchase",
       "firstname":"Jane",
       "lastname":"Doe",
       "email":"[email protected]",
       "telephone":"512-555-1111"
    }
  }
}

quote-graphql's People

Contributors

alfredsgenkins avatar atravkovs avatar ainarssondors avatar yeegor avatar mihailspopovs4 avatar xapiksw avatar nikskozlovs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.