Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit b750512

Browse files
committed
#7366: GraphQl. subscribeEmailToNewsletter. Mutation for subscribe feature.
1 parent de38ab9 commit b750512

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

src/_data/toc/graphql.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ pages:
219219
- label: sendEmailToFriend mutation
220220
url: /graphql/mutations/send-email-to-friend.html
221221

222+
- label: subscribeEmailToNewsletter mutation
223+
url: /graphql/mutations/subscribe-email-to-newsletter.html
224+
exclude_versions: ["2.3"]
225+
222226
- label: setBillingAddressesOnCart mutation
223227
url: /graphql/mutations/set-billing-address.html
224228

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
group: graphql
3+
title: subscribeEmailToNewsletter mutation
4+
contributor_name: Atwix
5+
contributor_link: https://www.atwix.com/
6+
---
7+
8+
The `subscribeEmailToNewsletter` mutation allows subscription for guests and registered customers.
9+
10+
## Syntax
11+
12+
`mutation: {subscribeEmailToNewsletter(email: String!): SubscribeEmailToNewsletterOutput}`
13+
14+
## Example usage
15+
16+
The following call adds an email into a newsletter subscription.
17+
18+
**Request:**
19+
20+
```graphql
21+
mutation {
22+
subscribeEmailToNewsletter(
23+
email: "email@example.com"
24+
) {
25+
status
26+
}
27+
}
28+
```
29+
30+
**Response:**
31+
32+
```json
33+
{
34+
"data": {
35+
"subscribeEmailToNewsletter": {
36+
"status": "SUBSCRIBED"
37+
}
38+
}
39+
}
40+
```
41+
42+
## Input arguments
43+
44+
Mutation contains a required `email` argument specified an email address which should be added into a newsletter subscription.
45+
46+
## Output attributes
47+
48+
The `SubscribeEmailToNewsletterOutput` object contains the following attributes:
49+
50+
Attribute | Data Type | Description
51+
--- | --- | ---
52+
`status` | SubscriptionStatusesEnum | Contains a subscription status of specified `email` address.
53+
54+
### SubscriptionStatusesEnum object
55+
56+
In general, the `SubscriptionStatusesEnum` object can return one of the following values:
57+
58+
Value | Description
59+
--- | ---
60+
`NOT_ACTIVE` | Subscription requires a confirmation. Confirmation email has been sent to specified email address to confirm the subscription.
61+
`SUBSCRIBED` | Email address is subscribed.
62+
`UNSUBSCRIBED` | Email address is unsubscribed.
63+
`UNCONFIRMED` | Specified email ties to customer which did not confirm a required customer registration.
64+
65+
For the `subscribeEmailToNewsletter` mutation the `SubscriptionStatusesEnum` object may return only 2 of them:
66+
67+
- `NOT_ACTIVE`
68+
- `SUBSCRIBED`
69+
70+
## Errors
71+
72+
Error | Description
73+
--- | ---
74+
`Cannot create a newsletter subscription.` | General error message which appears on some internal system errors. The original error is logged and can be found in Magento logs.
75+
`Enter a valid email address.` | The value provided in the `email` argument has an invalid format.
76+
`Guests can not subscribe to the newsletter. You must create an account to subscribe.` | Guest subscription is disabled. Go to **Stores** > **Configuration** > **Customers** > **Newsletter** > **Subscription Options** > **Allow Guest Subscription** in the Admin to adjust the setting.
77+
`The account sign-in was incorrect or your account is disabled temporarily.` | The email address provided in the `email` argument ties to customer account pending confirmation.
78+
`This email address is already subscribed.` | The email address provided in the `email` argument is already subscribed.
79+
`You must specify an email address to subscribe to a newsletter.`| The empty value is provided in the `email` argument.

0 commit comments

Comments
 (0)