statamic-rad-pack / mailchimp

Mailchimp integration for Statamic
https://statamic.com/addons/rad-pack/mailchimp
MIT License
18 stars 12 forks source link

Mailchimp Config errors #35

Closed ellimondo closed 3 years ago

ellimondo commented 3 years ago

If I paste the suggested code from the Readme file into the mailchimp.php file I get the following error in Statamic:

ParseError
syntax error, unexpected end of file, expecting ']' 

/config/mailchimp.php61

I think there's a missing], in the example.

If I repair this and fill out the config I still get errors:

ErrorException
Illegal string offset 'form'

vendor/edalzell/mailchimp/src/ServiceProvider.php:50

Please excuse my ignorance if I have missed something glaring here as this is the first time I've used Statamic. It's also unclear in the instructions what the handle is for a form. Is it the name of the YAML file in resources/forms?

Statamic – 3.0.38 PHP – 7.4.7

edalzell commented 3 years ago

Please excuse my ignorance if I have missed something glaring here as this is the first time I've used Statamic. It's also unclear in the instructions what the handle is for a form. Is it the name of the YAML file in resources/forms?

Yes, name of the YAML. Sorry for the confusion, I'll update the instructions.

Closed in https://github.com/edalzell/statamic-mailchimp/commit/62a9d5a35534db7bed63f5b308b6907b58bab11e

ellimondo commented 3 years ago

Thanks for the updates. All work great. However, I am still getting the error from the function addFormsToNewsletterConfig listed above. The settings inside the config file are being viewed as Illegal String Offset and highlight this line in the CP.

return [$form['form'] => ['id'=> $form['audience_id']]];

edalzell commented 3 years ago

@ellimondo let's see your config file

ellimondo commented 3 years ago

Here you go. The settings are just for testing.

Even if I only enter the form setting in a freshly generated mailchimp.php file the error is thrown as soon as the array is called in line 50. I've run a composer update statamic/cms to see if anything is missing but it's all tickety boo.

<?php
return [
    'add_new_users' => false,
    'forms' => [
        'audience_id' => '2d64ff86d3',
        'check_consent' => false,
        'consent_field' => 'consent',
        'form' => 'contact',
        'merge_fields' => [
            [
                'tag'=> 'EMAIL',
                'field_name' => 'email'
            ],
            [
                'tag'=> 'FNAME',
                'field_name' => 'first_name'
            ],
            [
                'tag'=> 'LNAME',
                'field_name' => 'surname'
            ]
        ],
        'disable_opt_in' => true,
    ],
];
edalzell commented 3 years ago

Bad example config file, sorry, try this:

<?php
return [
    'add_new_users' => false,
    'forms' => [[
        'audience_id' => '2d64ff86d3',
        'check_consent' => false,
        'consent_field' => 'consent',
        'form' => 'contact',
        'merge_fields' => [
            [
                'tag'=> 'EMAIL',
                'field_name' => 'email'
            ],
            [
                'tag'=> 'FNAME',
                'field_name' => 'first_name'
            ],
            [
                'tag'=> 'LNAME',
                'field_name' => 'surname'
            ]
        ],
        'disable_opt_in' => true,
   ]],
];