addWishlistItemsToCart mutation
The addWishlistItemsToCart
mutation moves items from the specified wish list to the customer’s cart.
This mutation requires a valid customer authentication token.
Syntax
1
2
3
4
5
6
7
8
mutation {
addWishlistItemsToCart (
wishlistId: ID!
wishlistItemIds: [ID!]
) {
AddWishlistItemsToCartOutput
}
}
Example usage
The following example moves two items from a wishlist to the cart.
Request:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
mutation {
addWishlistItemsToCart(
wishlistId: 1
wishlistItemIds: [2, 3])
{
status
add_wishlist_items_to_cart_user_errors {
code
message
}
wishlist {
id
items_v2 {
items {
id
product {
uid
sku
name
}
}
}
}
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
"data": {
"addWishlistItemsToCart": {
"status": true,
"add_wishlist_items_to_cart_user_errors": [],
"wishlist": {
"id": "1",
"items_v2": {
"items": [
{
"id": "1",
"product": {
"uid": "MTM=",
"sku": "24-WB07",
"name": "Overnight Duffle"
}
},
{
"id": "4",
"product": {
"uid": "MTEwMA==",
"sku": "WH04",
"name": "Miko Pullover Hoodie"
}
},
{
"id": "5",
"product": {
"uid": "MTIyOA==",
"sku": "WJ01",
"name": "Stellar Solar Jacket"
}
},
{
"id": "6",
"product": {
"uid": "MTcyNA==",
"sku": "WT03",
"name": "Nora Practice Tank"
}
},
{
"id": "7",
"product": {
"uid": "MTY5Mg==",
"sku": "WT01",
"name": "Bella Tank"
}
}
]
}
}
}
}
}
Input attributes
The addWishlistItemsToCart
mutation requires the following input.
Attribute | Data Type | Description |
---|---|---|
wishlistItemIds |
[ID!] | An array of IDs presenting products to be added to the cart. If no IDs are specified, all items in the wish list will be added to the cart |
wishlistId |
ID! | The unique ID of the wish list |
Output attributes
The addWishlistItemsToCart
mutation returns the status of the operation as well an array of any errors that occurred.
Attribute | Data Type | Description |
---|---|---|
add_wishlist_items_to_cart_user_errors |
[WishlistCartUserInputError!] | Indicates why the attempt to add items to the wish list was not successful |
status |
Boolean! | Indicates whether the attempt to add items to the cart was successful |
wishlist |
Wishlist! | The wish list after moving items to the cart |
Wishlist attributes
The Wishlist
object contains all the items in the customer’s wish list.
Attribute | Data type | Description |
---|---|---|
id |
ID | The unique ID of a Wishlist object |
items |
[WishlistItem] | Deprecated. Use items_v2 instead |
items_v2 |
[WishlistItemInterface] | An array of items in the customer’s wish list |
items_count |
Int | The number of items in the wish list |
name |
String | The wish list name. Applicable to Adobe Commerce only |
sharing_code |
String | An encrypted code that Magento uses to link to the wish list |
updated_at |
String | The time of the last modification to the wish list |
visibility |
WishlistVisibilityEnum! | An enum indicating whether the wish list is PUBLIC or PRIVATE. Applicable to Adobe Commerce only |
WishlistItem attributes
The WishlistItem
object can contain the following attributes.
Attribute | Data type | Description |
---|---|---|
added_at |
String | The time when the customer added the item to the wish list |
description |
String | The customer’s comment about this item |
id |
Int | The wish list item ID |
product |
ProductInterface | The ProductInterface contains attributes that are common to all types of products. Note that descriptions may not be available for custom and EAV attributes |
qty |
Float | The quantity of this wish list item |
WishlistCartUserInputError attributes
The WishlistCartUserInputError
type contains a list of errors that indicate why the attempt to add items to the cart was not successful.
Attribute | Data Type | Description |
---|---|---|
code |
WishlistCartUserInputErrorType! | An error code that describes the error encountered. |
message |
String! | A localized error message |
WishlistCartUserInputErrorType!
Type | Description |
---|---|
INSUFFICIENT_STOCK |
The requested quantity of a product is greater than the quantity available |
NOT_SALABLE |
A requested product is not available |
PRODUCT_NOT_FOUND |
A product with the specified ID does not exist. |
UNDEFINED |
The error message does not match any error code |