statamic-rad-pack / mailchimp

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

Error when editing maichimp config in CPanel #89

Closed maxi032 closed 1 year ago

maxi032 commented 1 year ago

When I access mysite.test/cpanel/mailchimp/config/edit I get an error:

Statamic\Fields\Fields::addValues(): Argument #1 ($values) must be of type array, string given, called in /usr/share/nginx/html/vendor/statamic/cms/src/Fieldtypes/Grid.php on line 103

Environment:

Laravel Version: 9.51.0 PHP Version: 8.2.1 Composer Version: 2.5.1 Environment: local Debug Mode: ENABLED URL: mysite.test Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: log Cache: statamic Database: mysql Logs: stack / daily Mail: smtp Queue: sync Session: file

Statamic Addons: 5 Antlers: runtime Stache Watcher: Disabled Static Caching: Disabled Version: 3.4.3 PRO

Statamic Addons edalzell/forma: 1.2.1 silentz/mailchimp: 2.10 spatie/statamic-responsive-images: 2.15.2 statamic/eloquent-driver: 1.2.0 withcandour/aardvark-seo: 2.0.30

robdekort commented 1 year ago

Hey this seems related to #87. Erin is having a hard time replicating this issue. If you could list the steps to take to reproduce this maybe he can figure it out.

In the meantime if you configure the addon via the php config file you should be able to get it working.

maxi032 commented 1 year ago

I reinstalled the package and now everything works fine.

maxi032 commented 1 year ago

This morning the error is back. The error happends once I assign the form. I am using docker with WSL2 for local dev.

Here is my config:

return [

    'api_key' => env('MAILCHIMP_APIKEY'),

    /*
     * If you want to add to your mailchimp audience when a user registers, set this to `true`
     */
    'add_new_users' => false,

    'users' => [
        /*
        * A MailChimp audience id. Check the MailChimp docs if you don't know
        * how to get this value: https://mailchimp.com/help/find-audience-id/.
        */
        'audience_id' => null,

        /*
        * if you need consent before you can subscribe someone, set this to `true`
        */
        'check_consent' => true,

        /*
        * if you're checking for consent, which field is it? Defaults to `'consent'`
        */
        'consent_field' => 'consent',

        /*
        * To have single opt in only, which I don't recommend, set this to `true`.
        * See: https://mailchimp.com/help/single-opt-in-vs-double-opt-in/ for details
        */

        'disable_opt_in' => false,

        /*
        * if you'd like to add "interests" in a group, which field is collecting those ids? Defaults to 'interests'
        */
        'interests_field' => 'interests',

        /*
        * Which field are the marketing permissions in?
        */
        'marketing_permissions_field' => 'gdpr',

        /*
        * Which fields are the Mailchimp permission ids stored in?
        * Run `php please mailchimp:permissions <form-handle>` to get the ids.
        */
        'marketing_permissions_field_ids' => [
            [
                'field_name' => null,
                'id' => null,
            ],
        ],

        /*
        * See https://mailchimp.com/help/manage-audience-signup-form-fields/ for details on
        * Mailchimp merge fields
        */
        'merge_fields' => [
            [
                'id' => 'ZuiX6cXX',
            ],
        ],

        /*
        * Define the handle for the email field to be used. Defaults to 'email'.
        */
        'primary_email_field' => 'email',

        /*
        * Mailchimp Tag to assign to the contact.
        * NOTE: `tag_field` takes precendence over `tag`
        *
        * @see https://mailchimp.com/help/getting-started-tags/
        */
        'tag' => null,

        /*
        * Use this field in your user to indicate which Mailchimp Tag to use
        *
        * @see https://mailchimp.com/help/getting-started-tags/
        */
        'tag_field' => null,
        'id' => '2TEmmcXX',
    ],

    /*
     * The form submissions to add to your Mailchimp Audiences
     */
    'forms' => [
        [
            /*
            * handle of the form to listen for
            */
            'form' => null,

            /*
            * A MailChimp audience id. Check the MailChimp docs if you don't know
            * how to get this value: https://mailchimp.com/help/find-audience-id/.
            */
            'audience_id' => null,

            /*
            * if you need consent before you can subscribe someone, set this to `true`
            */
            'check_consent' => true,

            /*
            * if you're checking for consent, which field is it? Defaults to `'consent'`
            */
            'consent_field' => 'consent',

            /*
            * To have single opt in only, which I don't recommend, set this to `true`.
            * See: https://mailchimp.com/help/single-opt-in-vs-double-opt-in/ for details
            */

            'disable_opt_in' => false,

            /*
            * if you'd like to add "interests" in a group, which field is collecting those ids? Defaults to 'interests'
            */
            'interests_field' => 'interests',

            'marketing_permissions_field' => 'gdpr',

            // Mailchimp permission ids here. Run `php please mailchimp:permissions <form-handle>` to get them.
            'marketing_permissions_field_ids' => [
                [
                    'field_name' => '',
                    'id' => '',
                ],
            ],

            /*
            * See https://mailchimp.com/help/manage-audience-signup-form-fields/ for details on
            * Mailchimp merge fields
            */
            'merge_fields' => [
                [
                    /*
                    * The Mailchimp tag
                    */
                    'tag'=> null,

                    /*
                    * the blueprint field name to use for the merge field
                    */
                    'field_name' => null,
                ],
            ],

            /*
            * Define the handle for the email field to be used. Defaults to 'email'.
            */
            'primary_email_field' => 'email',

            /*
            * Mailchimp Tag to assign to the contact.
            * NOTE: `tag_field` takes precendence over `tag`
            *
            * @see https://mailchimp.com/help/getting-started-tags/
            */
            'tag' => null,

            /*
            * Use this field in your user to indicate which Mailchimp Tag to use
            *
            * @see https://mailchimp.com/help/getting-started-tags/
            */
            'tag_field' => null,

        ], 'id' => 'nZzZUoft', 'form' => 'subscribe_to_newsletter', 'audience_id' => '7cbd868xx', 'check_consent' => false, 'consent_field' => 'consent', 'disable_opt_in' => false, 'interests_field' => 'interests', 'marketing_permissions_field' => 'gdpr', 'marketing_permissions_field_ids' => [
            [
            ],
        ], 'merge_fields' => [
            [
                'id' => '6s4sglXX',
                'tag' => 'LANGUAGE',
                'field_name' => 'email',
            ],
        ], 'primary_email_field' => 'email',
    ],
];

The error goes away once I delete the config file and republish it again but this prevents me from assigning the form.

maxi032 commented 1 year ago

@robdekort Do you think that maybe you could share your config? From what I have seen you have more experience with it than me :) What I want is to be able to subcribe users. I have 'disable_opt_in' => true, and marketing permisions are not set. merge_fields are also not set. Subscriptions are not reaching the Audience

robdekort commented 1 year ago

Yeah this is mine.

<?php

return [

    'api_key' => env('MAILCHIMP_APIKEY'),

    /*
     * If you want to add to your mailchimp audience when a user registers, set this to `true`
     */
    'add_new_users' => false,

    'users' => [
        'id' => 'N7nO2Y4X',
        'check_consent' => true,
        'consent_field' => 'consent',
        'disable_opt_in' => false,
        'interests_field' => 'interests',
        'marketing_permissions_field' => 'gdpr',
        'marketing_permissions_field_ids' => [
            [
                'field_name' => null,
                'id' => null,
            ],
        ],
        'merge_fields' => [
            [
                'id' => 'F7dsYCaa',
            ],
        ],
        'primary_email_field' => 'email',
    ],

    /*
     * The form submissions to add to your Mailchimp Audiences
     */
    'forms' => [
        [
            'id' => 'AtdVzs5H',
            'form' => 'contact',
            'check_consent' => true,
            'consent_field' => 'newsletter',
            'disable_opt_in' => false,
            'marketing_permissions_field_ids' => [
                [
                ],
            ],
            'merge_fields' => [
                [
                    'id' => 'aHm9yh5l',
                    'field_name' => 'first_name',
                    'tag' => 'FNAME',
                ],
                [
                    'id' => 'ld8yk7ai',
                    'field_name' => 'last_name',
                    'tag' => 'LNAME',
                ],
                [
                    'id' => 'ld8yk7or',
                    'field_name' => 'company',
                    'tag' => 'COMPANY',
                ],
            ],
            'primary_email_field' => 'email',
            'audience_id' => '$$$$',
        ],
    ],
];

I've hid the audience id's.

robdekort commented 1 year ago

Def. a duplicate of #87

edalzell commented 1 year ago

Dupe of #87