Modifying the billing and shipping fields in Jigoshop

I recently discovered Jigoshop. A very nice, lightweight and well coded e-Commerce plugin for WordPress.

After some experimenting I found that the checkout and it’s fields for billing and shipping information where defined in the code and could not be modified in the settings.

It was a problem since they had set State as a required field, which most countries outside of US don’t have. In their forums there were many threads regarding this subject, and the answer the support staff gave was to modify the plugin files (!!) which you never should do.

So here’s an update safe to do it.

Create a plugin or add this to your theme’s functions.php


function jigo_mod_wp() {
 if ( class_exists( 'jigoshop_checkout' ) ) {
 $billing_fields = array(
 array( 'name'=>'billing-first_name', 'label' => __('First Name', 'jigoshop'), 'placeholder' => __('First Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
 array( 'name'=>'billing-last_name', 'label' => __('Last Name', 'jigoshop'), 'placeholder' => __('Last Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
 array( 'name'=>'billing-address', 'label' => __('Address', 'jigoshop'), 'placeholder' => __('Address', 'jigoshop'), 'required' => true ),
 array( 'name'=>'billing-city', 'label' => __('City', 'jigoshop'), 'placeholder' => __('City', 'jigoshop'), 'required' => true ),
 array( 'validate' => 'postcode', 'format' => 'postcode', 'name'=>'billing-postcode', 'label' => __('Postcode', 'jigoshop'), 'placeholder' => __('Postcode', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
 array( 'type'=> 'country', 'name'=>'billing-country', 'label' => __('Country', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
 array( 'name'=>'billing-email', 'validate' => 'email', 'label' => __('Email Address', 'jigoshop'), 'placeholder' => __('***@yourdomain.com', 'jigoshop'), 'required' => true )
 );
 jigoshop_checkout::instance()->billing_fields = $billing_fields;

 $shipping_fields = array(
 array( 'name'=>'shipping-first_name', 'label' => __('First Name', 'jigoshop'), 'placeholder' => __('First Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
 array( 'name'=>'shipping-last_name', 'label' => __('Last Name', 'jigoshop'), 'placeholder' => __('Last Name', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
 array( 'name'=>'shipping-address', 'label' => __('Address', 'jigoshop'), 'placeholder' => __('Address', 'jigoshop'), 'required' => true ),
 array( 'name'=>'shipping-city', 'label' => __('City', 'jigoshop'), 'placeholder' => __('City', 'jigoshop'), 'required' => true ),
 array( 'validate' => 'postcode', 'format' => 'postcode', 'name'=>'billing-postcode', 'label' => __('Postcode', 'jigoshop'), 'placeholder' => __('Postcode', 'jigoshop'), 'required' => true, 'class' => array('form-row-first') ),
 array( 'type'=> 'country', 'name'=>'shipping-country', 'label' => __('Country', 'jigoshop'), 'required' => true, 'class' => array('form-row-last') ),
 array( 'name'=>'shipping-email', 'validate' => 'email', 'label' => __('Email Address', 'jigoshop'), 'placeholder' => __('***@yourdomain.com', 'jigoshop'), 'required' => true )
 );
 jigoshop_checkout::instance()->shipping_fields = $shipping_fields;
 }
} add_action ( 'wp', 'jigo_mod_wp' );

Modify the array and add/remove the fields you want. Some of the items have an array item called required which controls whether a field is required or not.

Always fun to see great plugins that also are pluggable which is a MUST for it to be useful for developers.

Advertisements
About

Web Developer @ Oakwood Creative - www.oakwood.se

Tagged with: ,
Posted in Advanced
24 comments on “Modifying the billing and shipping fields in Jigoshop
  1. robsteele says:

    good info thx.

  2. Aurimas says:

    Thank you very very much!

  3. fotonarya says:

    set ‘required’ => false , it doesn’t work.
    It’s still a required field

  4. Ivan says:

    Hello

    If possible, can any one explain me how to exactly do this, please!
    I know something, not much but I altered everything I needed except this.

    Thank you very much!

  5. stardust says:

    Hi,

    i think this plugin solves this problem.

    http://jigoshop.com/extend/checkout-field-manager/

    But WTF is wrong with their pricing policy? 49 USD? That’s ridiculous… if not a plain rip off!

  6. stardust says:

    PS: You just saved me 60 USD for the plugin. Where can i donate?

  7. You can do so in functions.php in your theme

    function mt_billing_fields($args) {
    $billing_fields = array();
    return $billing_fields;
    }
    add_filter( ‘jigoshop_billing_fields’, ‘mt_billing_fields’,10,1 );

    function mt_shipping_fields($args) {
    $shipping_fields = array();
    return $shipping_fields;
    }
    add_filter( ‘jigoshop_shipping_fields’, ‘mt_shipping_fields’,10,1 );

  8. tiknius says:

    Hi, thanks a lot for this. It works fine but when I add billing-state and shipping-state (my goal is to only make postcode not a required field, having states is ok) I get this warning: Warning: Illegal offset type in isset or empty in /home/mantastikn/domains/pasikuiskim.lt/public_html/wp-content/plugins/jigoshop/classes/jigoshop_countries.class.php on line 900

    any idea what could be causing this?

    • Vincent says:

      Hi,

      I can’t swear that this solution works anymore. I believe Jigoshop has evolved quite a bit since this post was authored.

      Perhaps Mihail’s solution above works!

  9. Thanks – you are awesome. The jigoshop documentation is pretty terrible.

  10. stoatoffear says:

    I’ve copied the jigoshop_checkout class into my theme, renamed it, copied all functions that interact with it and renamed them, then I’ve entered my renamed shortcode into the page and amazingly, I can mess around deleting or renaming fields in my new class and it seems to be working! The Jigoshop plugin code remains untouched.

  11. Josh says:

    Brilliant, thank you very much for the help! Works perfectly in the latest version 1.6.2 of Jigoshop.

  12. Nicole says:

    Hi, this worked .. kind of, the fields worked but when i went to checkout it said “Phone (billing) is a required field.) which is the field that i took out.. so somewhere jigoshop still thinks that fields there and expecting it to be entered.. does anyone know where that is and how to change it?

    • Biohazard777 says:

      I know my reply comes a bit too late (8 months late)… but if you still need a solution add this line:
      array( ‘name’=>’billing-phone’, ‘validate’ => ‘phone’, ‘label’ => __(‘Phone’, ‘jigoshop’), ‘placeholder’ => __(‘Phone number’, ‘jigoshop’), ‘required’ => true )
      If you need more information check my full post bellow.

  13. Neil says:

    Looks like Nicole is right – I have the same issue. Fields are still required whether showing or not. Suggestions?

  14. Biohazard777 says:

    Thanks a lot. I’v been searching for a safe way to remove some fields.
    With a bit of modification this works with the latest versions:
    Jigoshop Version: 1.8.1 ; WordPress Version: 3.8.1

    You just need to add this line to make it work:
    array( ‘name’=>’billing-phone’, ‘validate’ => ‘phone’, ‘label’ => __(‘Phone’, ‘jigoshop’), ‘placeholder’ => __(‘Phone number’, ‘jigoshop’), ‘required’ => true )

    For people who don’t know where the line I mentioned should be put, here is the whole code, just copy and paste it:

    function jigo_mod_wp() {
    if ( class_exists( ‘jigoshop_checkout’ ) ) {
    $billing_fields = array(
    array( ‘name’=>’billing-first_name’, ‘label’ => __(‘First Name’, ‘jigoshop’), ‘placeholder’ => __(‘First Name’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-first’) ),
    array( ‘name’=>’billing-last_name’, ‘label’ => __(‘Last Name’, ‘jigoshop’), ‘placeholder’ => __(‘Last Name’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-last’) ),
    array( ‘name’=>’billing-address’, ‘label’ => __(‘Address’, ‘jigoshop’), ‘placeholder’ => __(‘Address’, ‘jigoshop’), ‘required’ => true ),
    array( ‘name’=>’billing-city’, ‘label’ => __(‘City’, ‘jigoshop’), ‘placeholder’ => __(‘City’, ‘jigoshop’), ‘required’ => true ),
    array( ‘validate’ => ‘postcode’, ‘format’ => ‘postcode’, ‘name’=>’billing-postcode’, ‘label’ => __(‘Postcode’, ‘jigoshop’), ‘placeholder’ => __(‘Postcode’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-first’) ),
    array( ‘type’=> ‘country’, ‘name’=>’billing-country’, ‘label’ => __(‘Country’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-last’) ),
    array( ‘name’=>’billing-email’, ‘validate’ => ’email’, ‘label’ => __(‘Email Address’, ‘jigoshop’), ‘placeholder’ => __(’email’, ‘jigoshop’), ‘required’ => true ),
    array( ‘name’=>’billing-phone’, ‘validate’ => ‘phone’, ‘label’ => __(‘Phone’, ‘jigoshop’), ‘placeholder’ => __(‘Phone number’, ‘jigoshop’), ‘required’ => true )
    );
    jigoshop_checkout::instance()->billing_fields = $billing_fields;

    $shipping_fields = array(
    array( ‘name’=>’shipping-first_name’, ‘label’ => __(‘First Name’, ‘jigoshop’), ‘placeholder’ => __(‘First Name’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-first’) ),
    array( ‘name’=>’shipping-last_name’, ‘label’ => __(‘Last Name’, ‘jigoshop’), ‘placeholder’ => __(‘Last Name’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-last’) ),
    array( ‘name’=>’shipping-address’, ‘label’ => __(‘Address’, ‘jigoshop’), ‘placeholder’ => __(‘Address’, ‘jigoshop’), ‘required’ => true ),
    array( ‘name’=>’shipping-city’, ‘label’ => __(‘City’, ‘jigoshop’), ‘placeholder’ => __(‘City’, ‘jigoshop’), ‘required’ => true ),
    array( ‘validate’ => ‘postcode’, ‘format’ => ‘postcode’, ‘name’=>’billing-postcode’, ‘label’ => __(‘Postcode’, ‘jigoshop’), ‘placeholder’ => __(‘Postcode’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-first’) ),
    array( ‘type’=> ‘country’, ‘name’=>’shipping-country’, ‘label’ => __(‘Country’, ‘jigoshop’), ‘required’ => true, ‘class’ => array(‘form-row-last’) ),
    array( ‘name’=>’shipping-email’, ‘validate’ => ’email’, ‘label’ => __(‘Email Address’, ‘jigoshop’), ‘placeholder’ => __(’email’, ‘jigoshop’), ‘required’ => true )
    );
    jigoshop_checkout::instance()->shipping_fields = $shipping_fields;
    }
    } add_action ( ‘wp’, ‘jigo_mod_wp’ );

    • Camilo says:

      Biohazard, where should we put this lines? function.php? thank you in advance

    • Henrik says:

      Hi, i get an error in the theme functions.php when i copy/paste your code in before the last closing php ?> tag, and try to save the file. (… Unexpected “Name” “T-string” … line 766…) . I use WP 3.9.2 and Jigoshop 1.11.1.

  15. Sherwin says:

    hello sir, Can I add a select option in this field?

  16. Phil Golden says:

    The current jigoshop ‘billing address’ and ‘shipping address’ display as: Custom Name then on the next line, address, city, state, zip – all on one line. My customer would like the address to print more traditionally as it is difficult for them to read. I know, I know…. But they also claim it makes it difficult to paste into a label maker program, which may be plausible. Anyway, they want the address to print:

    Customer Name
    Customer address
    Customer City, State, Zip.

    Could you help me determine the best way to handle this?
    Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About

WordPress Quick Tips is a blog supplying great tips about WordPress.

We hope to create a great knowledge resource for WordPress developers as well as serving a reminder for all the forgetful ones.

The blog is created and run by Vincent of Oakwood Creative

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 120 other followers

%d bloggers like this: