How to use mailchimp_woocommerce_newsletter_field?
-
I saw this: https://github.com/mailchimp/mc-woocommerce/wiki/Filter-on-newsletter-field
The documentation there for that filter was very limited. There was no sample code, it did not indicate what parameters were expected, and what the response from the function should be. So it’s pretty unclear as to how to use the filter.
First thing I tried:
add_filter('mailchimp_woocommerce_newsletter_field', 'rephrase_mcfield'); function rephrase_mcfield ($checkbox, $status, $label) { $label = 'This is a test'; return $label; }
But nothing happened. So I checked the source code and saw that it was doing a getOption for
label
, so I tried this:add_filter('mailchimp_woocommerce_newsletter_field', 'rephrase_mcfield'); function rephrase_mcfield ($options) { //$checkbox, $status, $label $options['label'] = 'This is a test'; return $options; }
That didn’t work either. I figured it might expect only html returned from the function, so I tried this:
add_filter('mailchimp_woocommerce_newsletter_field', 'rephrase_mcfield'); function rephrase_mcfield () { $checkbox = '<input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="mailchimp_woocommerce_is_subscribed_checkbox" id="mailchimp_woocommerce_is_subscribed" checked="">This is a test change'; return $checkbox; }
Nothing happened as a result of that code. So I’m at a loss as to how exactly that filter should be used. Is there any additional information on how the filter should be used?
Basically my goal here is to change the label for the newsletter subscription checkbox. I don’t need to modify the HTML, just the label is fine.
- The topic ‘How to use mailchimp_woocommerce_newsletter_field?’ is closed to new replies.