X-Purchase-Cart provides high performance API for shopping cart.
- Working with shopping cart;
- Auto evaluating taxes and prices;
- Multi-Laguage;
- Multi-Currency;
- Lazy resolving;
# | Endpoint | Arguments | Return |
---|---|---|---|
1 | cart | storeId cartName userId cultureName currencyCode cartType |
Shopping cart |
2 | carts | storeId cartName userId cultureName currencyCode cartType sort skip take |
Paginated shopping cart list |
{
cart (storeId: "Electronics"
cartName: "default"
userId: "d97ee2c7-e29d-440a-a43a-388eb5586087"
cultureName: "en-Us"
currencyCode: "USD"
cartType: "cart")
{
id
name
hasPhysicalProducts
status
storeId
isAnonymous
comment
taxPercentRate
taxType
addresses { countryName regionName city addressType }
dynamicProperties { name value valueType }
shipments { shipmentMethodCode shipmentMethodOption }
availableShippingMethods { code optionName optionDescription }
discounts { amount description }
currency { code symbol }
payments { paymentGatewayCode }
availablePaymentMethods { code paymentMethodType }
items { id sku }
coupons { code isAppliedSuccessfully }
itemsCount
itemsQuantity
type
}
}
Tip
See also CartType schema for better understanding of possible fields in request.
With this connection you can get all user's carts/whishlists.
{
carts (storeId: "Electronics"
userId: "d97ee2c7-e29d-440a-a43a-388eb5586087"
cultureName: "en-Us"
currencyCode: "USD"
cartType: "cart"
take: 5
skip: 0)
{
items
{
id
name
hasPhysicalProducts
status
storeId
isAnonymous
}
pageInfo
{
startCursor
endCursor
hasNextPage
hasPreviousPage
}
}
}
Field Cart.Addresses
in CartType
is a functional enabler. Currently it does not participate in any internal business logic and it is separated from Cart.Billing.Addresses
and Cart.Shipping.Addresses
. Feel free to add your own business logic to it.
Address type structure can be found here.
Every mutation contains base arguments for working with cart context:
storeId
- Id of current storecartName
- Cart nameuserId
- Id of current usercurrencyCode
- Currency code (e.g. "USD")cultureName
- Culture name of current language (e.g. "en-Us")cartType
- Type of cart ("cart" or "whishlist")
# | Endpoint | Arguments | Description |
---|---|---|---|
1 | addItem | !productId !quantity price comment |
Add item to cart. |
2 | clearCart | - | Remove items from cart. |
3 | changeComment | comment |
Update cart comment. |
4 | changeCartItemPrice | !productId !price |
Change cart item price. |
5 | changeCartItemQuantity | !lineItemId !quantity |
Change cart item quantity. |
6 | changeCartItemComment | !lineItemId comment |
Change cart item comment. |
7 | removeCartItem | !lineItemId |
Remove cart item from cart. |
8 | addCoupon | !couponCode |
Add coupon to cart. |
9 | removeCoupon | couponCode |
Remove coupon from cart. If coupon not passed clear all coupons from cart. |
10 | removeShipment | shipmentId |
Remove shipment from cart. |
11 | addOrUpdateCartShipment | !shipment (type) |
Add or update shipment for cart. |
12 | addOrUpdateCartPayment | !payment (type) |
Add or update payment for cart. |
13 | validateCoupon | !coupon |
Validate coupon, return result. |
14 | mergeCart | !secondCartId |
Merge two carts into one. |
15 | removeCart | !cartId |
Remove cart. |
16 | clearShipments | - | Clear cart shipments. |
17 | clearPayments | - | Clear cart payments. |
18 | updateCartDynamicProperties | !dynamicProperties |
Updates dynamic properties in cart. |
19 | updateCartItemDynamicProperties | !lineItemId !dynamicProperties |
Updates dynamic properties in cart items. |
20 | updateCartShipmentDynamicProperties | !shipmentId !dynamicProperties |
Updates dynamic properties in cart shipment. |
21 | updateCartPaymentDynamicProperties | !paymentId !dynamicProperties |
Updates dynamic properties in cart payment. |
22 | addCartAddress | !address (type) |
Add address for cart or update it by type |
23 | addWishlistBulkItem | !listIds !productId |
Add product to few wish lists. |
24 | refreshCart | Refresh the contents of a shopping cart without making any modifications to the items in it. |
Note
In arguments column we only show additional arguments. if they are marked with an exclamation mark, they are required.
This mutation validates item and add it to cart, recalculate promotion rewards and taxes then save cart.
mutation ($command:InputAddItemType!)
{
addItem(command: $command)
{
name
items
{
id
sku
}
itemsCount
itemsQuantity
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"productId": "9cbd8f316e254a679ba34a900fccb076",
"quantity": 1,
"dynamicProperties": [
{
"name": "ItemProperty",
"value": "test value"
}
]
}
}
This mutation loads the cart from its persistent storage, then immediately saves it back without any modifications. This effectively triggers any relevant price updates and clears any warnings that may have been present.
mutation ($command:RefreshCartType!)
{
refreshCart(command: $command)
{
itemsCount
itemsQuantity
}
}
{
"command": {
"storeId": "B2B-store",
"userId": "39e3f3c5-7dd3-40ce-b48b-99549c1cd702",
"cartId": "d77a2584-6b45-4b34-818a-9302ec15da5d"
}
}
This mutation removes all items from cart, reset promotion rewards based on amount of items and save cart.
mutation ($command:InputClearCartType!)
{
clearCart(command: $command)
{
name
items
{
id
sku
}
itemsCount
itemsQuantity
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart"
}
}
This mutation changes cart comment.
mutation ($command:InputChangeCommentType!)
{
сhangeComment(command: $command)
{
name
comment
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"comment": "Hi, Virto! :)"
}
}
This mutation changes cart item price.
mutation ($command:InputChangeCartItemPriceType!)
{
changeCartItemPrice(command: $command)
{
id
items
{
sku
productId
listPrice
listPriceWithTax
salePrice
salePriceWithTax
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"productId": "9cbd8f316e254a679ba34a900fccb076",
"price": 777
}
}
This mutation changes cart item quantity.
mutation ($command:InputChangeCartItemQuantityType!)
{
changeCartItemQuantity(command: $command)
{
id
items
{
sku
productId
quantity
}
itemsCount
itemsQuantity
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"lineItemId": "9cbd8f316e254a679ba34a900fccb076",
"quantity": 7
}
}
This mutation changes cart item comment.
mutation ($command:InputChangeCartItemCommentType!)
{
changeCartItemComment(command: $command)
{
id
items
{
sku
productId
comment
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"lineItemId": "9cbd8f316e254a679ba34a900fccb076",
"comment": "nice product"
}
}
This mutation removes item from cart.
mutation ($command:InputRemoveItemType!)
{
removeCartItem(command: $command)
{
id
items
{
sku
productId
}
itemsCount
itemsQuantity
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"lineItemId": "9cbd8f316e254a679ba34a900fccb076",
}
}
This mutation checks and adds coupon to cart.
mutation ($command:InputAddCouponType!)
{
addCoupon(command: $command)
{
name
coupons
{
code
isAppliedSuccessfully
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"couponCode": "freeItemsCouponCode",
}
}
This mutation removes coupon from cart.
mutation ($command:InputRemoveCouponType!)
{
removeCoupon(command: $command)
{
name
coupons
{
code
isAppliedSuccessfully
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"couponCode": "freeItemsCouponCode",
}
}
This mutation removes shipment from cart.
mutation ($command:InputRemoveShipmentType!)
{
removeShipment(command: $command)
{
name
availableShippingMethods
{
code
optionName
optionDescription
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"shipmentId": "7777-7777-7777-7777",
}
}
This mutation adds or updates shipment of cart. This mutation supports partial update, all fields in command.shipment
and command.shipment.deliveryAddress
are optional.
mutation ($command:InputAddOrUpdateCartShipmentType!)
{
addOrUpdateCartShipment(command: $command)
{
name
availableShippingMethods
{
code
optionName
optionDescription
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"shipment": {
"fulfillmentCenterId": "7777-7777-7777-7777",
"height": 7,
"shipmentMethodCode": "code",
"currency": "USD",
"price": 98,
"dynamicProperties": [
{
"name": "ShipmentProperty",
"value": "test value"
}
]
},
}
}
Tip
To see all possible parametrs for shipment object look here...
This mutation adds or updates payment of cart. This mutation supports partial update, all fields in command.payment
and command.payment.billingAddress
are optional.
mutation ($command:InputAddOrUpdateCartPaymentType!)
{
addOrUpdateCartPayment(command: $command)
{
name
availablePaymentMethods
{
code
name
paymentMethodType
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"payment": {
"outerId": "7777-7777-7777-7777",
"paymentGatewayCode": "code",
"currency": "USD",
"price": 98,
"amount": 55,
"dynamicProperties": [
{
"name": "PaymentProperty",
"value": "test value"
}
]
},
}
}
Tip
To see all possible parametrs for payment object look here...
This mutation validates coupon.
mutation ($command:InputValidateCouponType!)
{
validateCoupon(command: $command)
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"coupon": "freeItemsCouponCode"
}
}
This mutation merges two carts. You can use it to merge anonymous cart with user cart after authorization.
mutation ($command:InputMergeCartType!)
{
mergeCart(command: $command)
{
id
isAnonymous
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"secondCartId": "7777-7777-7777-7777",
}
}
This mutation removes cart.
mutation ($command:InputRemoveCartType!)
{
removeCart(command: $command)
}
{
"command": {
"cartId": "7777-7777-7777-7777"
}
}
This mutation removes all shipments from cart.
mutation ($command:InputClearShipmentsType!)
{
clearShipments(command: $command)
{
name
availableShippingMethods
{
code
optionName
optionDescription
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart"
}
}
This mutation removes all payments from cart.
mutation ($command:InputClearPaymentsType!)
{
clearPayments(command: $command)
{
name
availablePaymentMethods
{
code
name
paymentMethodType
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart"
}
}
This mutation updates dynamic properties in cart
mutation ($command: InputUpdateCartDynamicPropertiesType!)
{
updateCartDynamicProperties(command: $command)
{
dynamicProperties
{
name
value
valueType
dictionaryItem
{
label
name
id
}
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"dynamicProperties": [
{
"name": "Example string property",
"value": "12345678"
},
{
"name": "Example multilanguage property",
"locale":"de-DE",
"value": "hallo welt"
},
{
"name": "Example dictionary property",
"value": "578fadeb1d2a40b3b08b1daf8db09463"
}
]
}
}
}
This mutation updates dynamic properties in cart item
mutation ($command: InputUpdateCartItemDynamicPropertiesType!)
{
updateCartItemDynamicProperties(command: $command)
{
items
{
id
dynamicProperties
{
name
value
valueType
dictionaryItem
{
label
name
id
}
}
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"lineItemId": "dab09410-aa1a-4daf-8a32-4e41abee77b8",
"dynamicProperties": [
{
"name": "Example string property",
"value": "12345678"
},
{
"name": "Example multilanguage property",
"locale":"de-DE",
"value": "hallo welt"
},
{
"name": "Example dictionary property",
"value": "578fadeb1d2a40b3b08b1daf8db09463"
}
]
}
}
}
This mutation updates dynamic properties in cart shipment
mutation ($command: InputUpdateCartItemDynamicPropertiesType!)
{
updateCartShipmentDynamicProperties(command: $command)
{
items
{
id
dynamicProperties
{
name
value
valueType
dictionaryItem
{
label
name
id
}
}
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"shipmentId": "79b8f095-9740-4353-998b-e1c4dd577ee6",
"dynamicProperties": [
{
"name": "Example string property",
"value": "12345678"
},
{
"name": "Example multilanguage property",
"locale":"de-DE",
"value": "hallo welt"
},
{
"name": "Example dictionary property",
"value": "578fadeb1d2a40b3b08b1daf8db09463"
}
]
}
}
}
This mutation updates dynamic properties in cart payment
mutation ($command: InputUpdateCartItemDynamicPropertiesType!)
{
updateCartPaymentDynamicProperties(command: $command)
{
items
{
id
dynamicProperties
{
name
value
valueType
dictionaryItem
{
label
name
id
}
}
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"paymentId": "0859f1e8-16e8-4924-808b-47e03560085d",
"dynamicProperties": [
{
"name": "Example string property",
"value": "12345678"
},
{
"name": "Example multilanguage property",
"locale":"de-DE",
"value": "hallo welt"
},
{
"name": "Example dictionary property",
"value": "578fadeb1d2a40b3b08b1daf8db09463"
}
]
}
}
}
This mutation adds a new address to cart or updates an existing one by addressType
. This mutation supports partial update, all fields in command.address
are optional.
mutation addOrUpdateCartAddress ($command: InputAddOrUpdateCartAddressType!) {
addOrUpdateCartAddress (command: $command) {
addresses {
addressType
city
countryCode
countryName
email
firstName
id
lastName
line1
line2
middleName
name
organization
phone
postalCode
regionId
regionName
zip
}
}
}
{
"command": {
"storeId": "Electronics",
"cartName": "default",
"userId": "b57d06db-1638-4d37-9734-fd01a9bc59aa",
"cultureName": "en-US",
"currencyCode": "USD",
"cartType": "cart",
"address": {
"city": "City name",
"countryCode": "CountryCode",
"countryName": "Country name",
"email": "example@email.com",
"firstName": "recipient name",
"middleName": "recipient name",
"lastName": "recipient name",
"line1": "example address line 1",
"line2": "example address line 1",
"organization": "Organizatoin name",
"phone": "77777-77777",
"postalCode": "12345",
"regionId": "RegionCode",
"regionName": "Region name",
"zip": "123",
"addressType": 3
}
}
}
This mutation adds a product to few wish lists.
mutation addWishlistBulkItem ($command: InputAddWishlistBulkItemType!) {
addWishlistBulkItem (command: $command) {
wishlists {
name
id
items {
id
quantity
product {
name
}
}
}
}
}
{
"command": {
"listIds": ["ce682f58-3bbd-42e5-a576-08c82a86ca11", "1b249c7a-5b7b-434d-a9b5-56a67ff993fe"],
"productId" : "92e671024a8648de97dedcd488f58455"
}
}