Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Mailchimp list field only provides coarse access to the subscription details: a setter and getter for the field value directly, but the subscription data actual contains structured data: a "subscription" boolean and an array of interest group preferences. The field should provide direct setters and getters for these as well.
Comment | File | Size | Author |
---|---|---|---|
#9 | provide_subscription_field_setters_getters-2578697-9.patch | 1.09 KB | wxactly |
#2 | provide_deep_field_setters_getters-2578697.patch | 4.16 KB | gcb |
Comments
Comment #2
gcbInitial work on a patch attached: this needs work.
Comment #3
wxactly CreditAttribution: wxactly at ThinkShout commentedHere's a patch that provides sub-property getters and setters for "subscribed" and "interest groups" without going any deeper into the nested MailChimp API structure for the groups. This enables property access, like:
Comment #4
wxactly CreditAttribution: wxactly at ThinkShout commentedUpdated patch. MailChimp's data structure was failing validation for the "list" type, so changed to "struct".
Comment #5
nlarow CreditAttribution: nlarow as a volunteer commentedWxactly,
I've applied your more recent patch (I've tried and reverted all 3 in this topic to be honest..) and I was able to see the new token:variables exposed in "help/tokens".. but I'm running into a real problem actually using the new token for "field:interest_groups" in an email template as I cannot get it to output anything other than the word "Property".
Note that "field:subscribe" works and returns a true/false value... it's just the "field:interest_groups" that appear to not work..
Any input? Much appreciated.
Regards,
Nicholaus
Comment #6
nlarow CreditAttribution: nlarow as a volunteer commentedComment #7
wxactly CreditAttribution: wxactly at ThinkShout commented@nlarow - The data structure for interest groups is a complex multi-dimensional array. Unfortunately the simple patch I added here isn't going to help you very much for using interest groups in tokens. You'll need something more like what @gcb started in his first patch... though, as he noted, it needs some serious work. If someone wants to jump in and give it another shot, I think the first patch here is a decent starting point. I actually tried to jump in and add full nested support for the multi-dimensional data structure myself, but it was just getting too complicated so I scrapped it and went the simpler route instead.
Comment #8
ruscoe CreditAttribution: ruscoe at ThinkShout for Mailchimp commentedWe're going to be ending support for the 7.x-3.x branch due to the upcoming deprecation of the v2.0 MailChimp API. If you're still interested in this feature, please feel free to reopen for the 7.x-4.x branch.
Comment #9
wxactly CreditAttribution: wxactly at ThinkShout commented#4 is still relevant, so I re-rolled this patch. This is an easy win which adds sub-property getters and setters for "subscribed" boolean and "interest groups" struct:
Comment #10
wxactly CreditAttribution: wxactly at ThinkShout commentedComment #11
samuel.mortensonWe’re in maintenance-mode for the Drupal 7 releases of Mailchimp, so only bug fixes can be committed going forward. Any new features should be developed for the Drupal 8 releases of Mailchimp. Thanks!