How to Add Subscribe Option in WooCommerce Email Notifications?

Meaningfully you want to know How to Add Subscribe/Unsubscribe Option in WooCommerce Email Notifications? We will explain you through this guide.

If you want to keep your WooCommerce store’s customers interested? Send out Daily newsletter. No monthly, No weekly, No wait!

However, think about it. How many newspapers have you signed up for? Say in the past few months? Okay and assume that you’ve signed up for something.

Consequently, do you read every newsletter that comes in your way? Also, the customers are interested in promotional offers, such as sales, or new products are being launched. And, these offers can sometimes be sent as emails.

In case of any help related to WooCommerce Setup talk to our WordPress Experts, dial + 1 844 275 0975(Toll-Free).

email-newsletter-300x213

Email Notifications for WooCommerce

For your WooCommerce store, some plugins are available that you can use to send such emails. Also, you can use some standalone WordPress newsletter plugins, such as Integration plugins, or Mailpoet (that currently connected your website to an email marketing service provider) like as MailChimp.

However, most of these are not connected directly to your online store. And usually, add a subscription option on a registration form or checkout page only.

In this post, learn how to add another subtle option, such as button or form, by using that a customer can subscribe to your notification emails, using a custom plugin. Also, you can add these options to a newsletter plugin to send the custom email.

Add Subscribe/Unsubscribe Option under Customer Account

On a customer’s account page, a subscription option can be shown using a button. So, the customers can use this button to subscribe or (unsubscribe) to your email notifications. Let’s start.

Add Subscribe/Unsubscribe Option

Consequently, you can add a button by using your own plugin, on your WooCommerce account page, just say ‘My account below’. To show such a button you have to override the WooCommerce ‘my account.php’ template.

However, you could refer ‘How to override WooCommerce templates’, for learning how you can change the template in your plugin. And then add the following code to the template file:

<?php if(get_user_meta($current_user->id,’wdm_subscribe’,true) == ‘no’): ?>
<p><a href=”/my-account/?wdmsubs=true” value=”subscribe” name=”subscribe” id=”wdm_subscribe”>Subscribe</a></p>
<?php else: ?>
<p><a href=”/my-account/?wdmsubs=false” value=”subscribe” name=”subscribe” id=”wdm_subscribe”>Unsubscribe</a></p>
<?php endif; ?>

Therefore, check the above code the current user has subscribed to your newsletter if not, the button value is shown as ‘Subscribe’, and ‘Unsubscribe’.

However, by using the custom meta key to track, the user has subscribed or not. And using a parameter wdmsubs, the button click is tracked.

Display Acknowledgement Message

Once a user clicks on the button and subscribes, an acknowledgment message can be displayed using the code given below. And then add the following code to your plugin

add_action( ‘wp_head’, ‘wdm_woo_subscribe’ );
function wdm_woo_subscribe()
{
if(isset($_REQUEST[‘wdmsubs’]) && $_REQUEST[‘wdmsubs’] == true)
{
update_user_meta(get_current_user_id(),’_wdm_subscribe’,’yes’);
wc_add_notice( __( ‘Yayy! You have subscribed to our email notification.’, ‘woocommerce’ ) );
}
}

Add User to List

Although, on Subscriptions, you have to add the user to your email recipient list. Also, you can use the above function to add a user to your list or maintained the list using the Newsletter plugin.

However, to add this to a newsletter plugin, you need to find a filter or hook by using that you could add a user to the subscription list. For instance, if you use MailPoet, you can use refer how to add subscribers by using your plugin, to add the user to a MailPoet subscription list.

Unsubscribe User from Default Emails

To unsubscribe the user, we have to remove from the list of email recipients. Also, to remove the user from the customer list, use the similar hook or filter.

However, the user to unsubscribe from the default WooCommerce Email
For example,

‘woocommerce_email_recipient_customer_processing_order’, you can use the following code shown as below:

add_filter(‘woocommerce_email_recipient_customer_processing_order’,’wdm_woo_unsubscribe_processing_order’);
function wdm_woo_unsubscribe_processing_order($recipients)
{
$recipients = explode(‘,’,$recipients);
$final_recipient = array();
foreach($recipients as $r)
{
$user = get_user_by_email( $r );
$user_id = $user -> ID;
/*Check user meta, to verify whether the user should be excluded from the recipient list or not. */
if( get_user_meta($user_id, ‘wdm_subscribe’, true) == ‘no’)
{
$final_recipient[] = $r;
}
}
$final_recipient = implode(‘,’,$final_recipient);
return $final_recipient;
}

Also, this function can be used to add a ‘unsubscribe’ link in the WooCommerce Email footer, through overriding ’email-footer.php’ template.

Conclusion

However, your newsletters or notifications can be used in the market for your products and offers. This simple notification option can be used with your own email notification plugin or for the default WooCommerce email under the user’s page.

Read carefully above steps and Add Email notification option in WooCommerce easily.

If you think it is a good option? So, tell me your thoughts in comments section below.

Get help from our WordPress Technical Support team in case of any issue related to WordPress. We are having a team of well-qualified professional who will resolve your problem instantly. So dial our number + 1 844 275 0975(Toll-Free).

Read More:



Leave a Reply

Call Now