• Resolved zududavid

    (@zududavid)


    I’m trying to add and remove customer tags based on certain conditions using the following provided on the plugin github page: https://github.com/mailchimp/mc-woocommerce/wiki/Editing-Member-Tags

    I can add tags no problem, but I cant remove tags that were previously added. I have followed the examples provided on the page linked to no avail. Can this be actually done? The page linked above suggests you can, however it’s worded in a way that it might .just be the array of new tags that you can edit, not the existing tags on the customers entry on mailchimp.

    Use case: using the “mailchimp_user_tags” filter, when the list is synced, I add a tag if the user has purchased a certain product within the last 6 months (this works), if the user has not purchased something in the last 6 months, remove that tag if it exists. (this part doesn’t work)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author ryanhungate

    (@ryanhungate)

    @zududavid I think what you’re going to have to do is set up a scheduled action in the future to do something like this. The only way it would be removed, is if there was an event on the user that would run this function again.

    This is actually a really good idea but I wonder if it would be better suited for the “customer journey” builder that Mailchimp has. Let us get back to you tomorrow with some feedback to see if something like this is possible. I have a few ideas, but this might require some custom code to do.

    We will be in touch asap.

    Thread Starter zududavid

    (@zududavid)

    Hi Ryan – Thanks for your reply.

    I don’t have any scheduled event, but the plan was to tell the client to click the big “RECYNC NOW” button before jumping onto Mailchimp to make sure it was up to date for the tags. However, my issue was that with the code, in the current documentation mentioned above, I am unable to remove existing tags. Can you confirm this is correct? Or am I able to do this with what is available?

    Glad you liked the idea. Look forward to hearing.

    Cheers.

    Plugin Author ryanhungate

    (@ryanhungate)

    @zududavid

    All you would need to do is run an action on the user’s email address in any hook that your plugins or site provides to update the member tags properly. This function will trigger the mailchimp_user_tags filter automatically – which you are using.

    mailchimp_get_api()->updateMemberTags(mailchimp_get_list_id(), '[email protected]');

    Please note this small snippet ^^ above ^^ would be custom code you could insert into any hook that has access to the user’s email address, and must be implemented by a developer. We always recommend using a staging environment before pushing to production to assure code quality.

    In order to remove the tags please follow this guide and you’ll notice that there’s an option to remove the tag by passing in an inactive status to the tag.

    After thinking about this for a while, I think we at the plugin team would want to push this action on the store owner to implement their own custom code to determine when and how these functions are run. We’re here to help with some ideas getting you started, but this won’t be something that the plugin does out of the gates without a custom action on your end.

    Thread Starter zududavid

    (@zududavid)

    Hello Ryan – Sorry if I’ve not been clear; I am a developer, and my issue is that I’ve been using the guide you linked, but the code example provided is not working. It IS adding tags no problem, but it is not removing them. Even using the exact example with the tag included does not seem to work.

    function my_tags($tags) {
            foreach ($tags as $tag) {
            if ($tag['name'] == 'customer'){
                $tag['status'] = 'inactive';
            }    
        }
        return $tags;
    }
    
    add_filter('mailchimp_user_tags', 'my_tags', 10, 1);

    The above should remove the tag “customer” from each woocommerce user in mailchimp after syncing, correct? This is unfortunately not working. Is there something I’m missing?

    Thread Starter zududavid

    (@zududavid)

    Hello Ryan – Sorry to bump this, it has been set as resolved but my issue is not. Please see my previous message.

    Plugin Support Jordan Rich

    (@builtbyjordan)

    The function should remove tag customer if they’re subscribed on an user update.
    For instance the order update should trigger this just as one would expect. However, to help us troubleshoot a little more could you log the function to make sure its firing when expected?

    mailchimp_log('debug', "my log message", array('key' => 'value to trace'));

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Removing existing customer tags’ is closed to new replies.