Hi Kashif,
It won’t be possible to add a “Sign-up to our newsletter” checkbox to the “My Account” page without adding some custom code to your theme.
It introduces several complexities over the checkout version because we then need to keep track of whether someone is (still) subscribed so we can reflect the correct value (checked or unchecked) on the checkbox.
Our plugin does not provide such a feature, but it does provide you with the tools to get there. Here’s a (very quick) example that gets you underway.
add_action( 'woocommerce_after_edit_address_form_billing', function() {
?><label><input type="checkbox" name="mc4wp-woocommerce-subscribe" value="1" /> Subscribe to our newsletter?</label><?php
});
add_action( 'woocommerce_customer_save_address', function( $user_id ) {
// was checkbox checked?
if( ! isset( $_POST['mc4wp-woocommerce-subscribe'] ) ) {
return;
}
// collect data
$user = get_userdata( $user_id );
$mailchimp_list_id = 'mailchimp-list-id'; // change this to your MailChimp list ID
$email = $user->user_email;
$merge_vars = array(
'FNAME' => $user->user_firstname,
'LNAME' => $user->user_lastname,
);
// subscribe to MailChimp
$api = mc4wp_get_api();
$api->subscribe( $mailchimp_list_id, $email, $merge_vars );
});
I hope that at least helps you in the right direction. We realise this is perhaps a little technical, but that’s because we do not officially support this functionality yet. We may start offering it in future version of the plugin, but for now it has to be manually coded using the helper tools we provide.
Hope that helps. If not, let me know!