Question

How Can I add a custom checkout field(s) without using a plugin?

I know there is a premium plugin that can do this, but since I only need 1 field, I think buying a plugin might be an overkill.

The custom field that I need is just 1 checkbox. I want to be able to add the custom fields from my theme’s functions.php so that I don’t have to override the plugin code. What action hooks and functions do I need? Can anyone provide an example, please?

Answer

add_filter( 'jigoshop_shipping_fields', 'egmont_shipping_fields' );
add_filter( 'jigoshop_billing_fields', 'egmont_billing_fields' );

Look in the file jigoshop/classes/jigoshop_checkout.class.php and you can find the two functions:

function get_billing_fields()
function get_shipping_fields()

copy and paste them into your functions.php, rename them, use the filters I listed initially with the new function names … and alter the functions to provide the fields you want.

Easy peasy.

Be advised, the field names have changed in the newly released 1.10 so I use something like this for each field:

return array(
		array(
			'name'          => jigoshop::jigoshop_version() < '1.10' ? 'billing-first_name' : 'billing_first_name',
			'label'         => __('First Name', 'jigoshop'),
			'placeholder'   => __('First Name', 'jigoshop'),
			'required'      => true,
			'class'         => array('form-row-first') ),

This tests for jigoshop version and uses different field names to match version. Most all the field names have changed, so do it for each.

 
Jigoshop