Checkout

WooCommerce Subscribe To Emails Checkbox On Checkout

WooCommerce subscribe to emails checkbox on checkout form

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

Asking users to subscribe to your emails on the checkout page is the perfect place to begin remarketing your store and products to advocates. A paying customer doesn’t need as much convincing to buy a product if they’ve already done it before, so by contacting them by email, your chances of turning them into another sale are far greater. This quick guide shows you how you can get users to opt-in to emails on the checkout page without an intrusive popup which we see far too often. If a user does subscribe and checkout, you’ll see in the order editor that the meta will be updated to show whether they have subscribed (checked the box) or not.

/**
* Snippet Name: Add a custom email subscription checkbox field to the WooCommerce checkout form.
* Snippet Author: ecommercehints.com
*/

add_action( 'woocommerce_after_order_notes', 'ecommercehints_custom_email_subscription_checkbox_field' );
add_action( 'woocommerce_checkout_update_order_meta', 'ecommercehints_save_subscription_input' );

function ecommercehints_custom_email_subscription_checkbox_field( $checkout ) {
woocommerce_form_field( 'subscribed', array(
'type' => 'checkbox',
'class' => array('form-row-wide'),
'label' => 'Subscribe To Emails?',
), $checkout->get_value( 'subscribed' ) );
}

function ecommercehints_save_subscription_input( $order_id ){
if( !empty( $_POST['subscribed'] ) && $_POST['subscribed'] == 1 ) {
update_post_meta( $order_id, 'subscribed', Yes );
} else {
update_post_meta( $order_id, 'subscribed', No );
}
}

How To See If A Customer Subscribed?

Simply head to the order editor in the dasboard and scroll down to where the order meta is shown, as displayed in this image:

null

Snippet Benefits

  • Capture whether users opt-in for emails at the checkout.
  • Increase the size of your email audience by capturing consent at the last stage of the sales funnel.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER