Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailchimp Batch bulk update tags not working with PUT method #312

Open
ashwindas77 opened this issue May 15, 2021 · 1 comment
Open

Mailchimp Batch bulk update tags not working with PUT method #312

ashwindas77 opened this issue May 15, 2021 · 1 comment

Comments

@ashwindas77
Copy link

Hi,

I tried to bulk update mailchimp tags using batch method. I used put method to do the same. But it is not working.

Attaching my code snippet. Please help me out,

$Batch = $MailChimp->new_batch();

    $list_id = "listID";
    $tagsSelected = ['tagFromAPI 99','tagFromAPI 00'];

    $Batch->put("op1", "lists/$list_id/members", [
        'email_address' => 'abcde@example.com',
        'status_if_new'        => 'subscribed',
        'tags'          => $tagsSelected,
        'merge_fields' => [
                         'FNAME' => 'Jish3' ?: '',
                         'LNAME' => 'win' ?: '',
        ]
    ]);

    $Batch->put("op2", "lists/$list_id/members", [
                'email_address' => 'efge@example.com',
                'status_if_new'        => 'subscribed',
                'tags'          => $tagsSelected,
                'merge_fields' => [
                    'FNAME' => 'Lax2' ?: '',
                    'LNAME' => 'Sav' ?: '',
   ]
            ]);

    $Batch->put("op3", "lists/$list_id/members", [
                'email_address' => 'hije@example.com',
                'status_if_new'        => 'subscribed',
                'tags'          => $tagsSelected,
                'merge_fields' => [
                    'FNAME' => 'Lenity1' ?: '',
                    'LNAME' => 'Lancer' ?: '',
   ]
            ]);
    
    
    $result = $Batch->execute();
    $MailChimp->new_batch($batch_id);
    $result = $Batch->check_status();
    echo '<pre>';print_r($result);
@tuxfamily
Copy link

tuxfamily commented Sep 7, 2023

According to the doc, here, the tags field should look like this:

{"tags": [{"name": "Influencer", "status": "active"}]}

So your $tagsSelected array should be something like this:

$tagsSelected = [
    ['name' => 'tagFromAPI 99', 'status' => 'active'],
    ['name' => 'tagFromAPI 00', 'status' => 'active']
]

(not tested)

This said, on update, don't forget to untag with inactive also.

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

No branches or pull requests

2 participants