Offering Free Products on Your WooCommerce Store

Reading Time: 2 minutes

Did you know that offering free products or downloads can be a great way to increase your growing business? It might seem counter intuitive at first, but a great free offering can help get your name out there. It creates an opportunity for new customers to get to know you, and sing your praises, and then tell others about your products.

If I offer free products on my store, how do I remove unnecessary fields to make the checkout easier for those customers?

It’s not unusual for store owners to use tiered offerings, starting with no-cost, high value options, and then building on those options with premium products.  Maybe you provide PDF instructional content,  patterns and blueprints, or eBooks. It is ideal for customers to still check out through your cart for a few reasons:

  • It’s a great way to gather customer information
  • You can keep track of what free products are most popular
  • A customer could sign up for a newsletter during this step

Even checking out with free content should be fast and easy for your customers. You want to know who they are and where they’re located, but you don’t need credit card information.

By adding a little bit of code, or a snippet, to your theme’s function.php, it’s easy to remove fields that you don’t need filled out.

Using the Code Snippets plugin

On our Managed WordPress and Managed WooCommerce Hosting platforms our team recommends using the Code Snippets plugin. This plugin provides an easy and direct way to add code snippets to your site.

WordPress Code Warning:
This article features code changes, or snippets, that you can make in your active themes function.php file. If you are unfamiliar with this task, or want to brush up, we have an article on Managing code snippets in WooCommerce. The technique provided can be used for both WordPress and WooCommerce sites.

You can use the supplied code snippet below to make checkout less complicated.

<?php // only copy if needed

/**
 * Removes coupon form, order notes, and several billing fields if the checkout doesn't require payment.
 *
 * REQUIRES PHP 5.3+
 *
 * Tutorial: http://skyver.ge/c
 */
function sv_free_checkout_fields() {

	// first, bail if WC isn't active since we're hooked into a general WP hook
	if ( ! function_exists( 'WC' ) ) {
		return;	
	}

	// bail if the cart needs payment, we don't want to do anything
	if ( WC()->cart && WC()->cart->needs_payment() ) {
		return;
	}

	// now continue only if we're at checkout
	// is_checkout() was broken as of WC 3.2 in ajax context, double-check for is_ajax
	// I would check WOOCOMMERCE_CHECKOUT but testing shows it's not set reliably
	if ( function_exists( 'is_checkout' ) && ( is_checkout() || is_ajax() ) ) {

		// remove coupon forms since why would you want a coupon for a free cart??
		remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );

		// Remove the "Additional Info" order notes
		add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );

		// Unset the fields we don't want in a free checkout
		add_filter( 'woocommerce_checkout_fields', function( $fields ) {

			// add or remove billing fields you do not want
			// fields: http://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-2
			$billing_keys = array(
				'billing_company',
				'billing_phone',
				'billing_address_1',
				'billing_address_2',
				'billing_city',
				'billing_postcode',
				'billing_country',
				'billing_state',
			);

			// unset each of those unwanted fields
			foreach( $billing_keys as $key ) {
				unset( $fields['billing'][ $key ] );
			}

			return $fields;
		} );
	}

}
add_action( 'wp', 'sv_free_checkout_fields' );

This code does come with a caveat; some users have experienced issues when using it. Please see the comments here.

Refer a friend and get a $50 hosting credit!