This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

Add 'Same as billing address' button for convenience

Skip to end of metadata
Go to start of metadata

This page refers to outdated version of CiviCRM. Check current version of documentation.


Documentation Search


CiviCRM 3.2 Documentation

Support and Participation

Developer Resources


CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

On your site you may have Donate (CiviContribute) page as well as Registration (CiviEvent) pages and with one or more pages you may want to add a Profile called "Mailing Address" (or the like) at the bottom of the page. Maybe the mailing address the person wants to use is different than the credit card billing address for their payment, or maybe it's not!  Why type it twice then, right?

Here are two pages where I'm using the code example below to make a convenient click button to copy the billing address to the mailing (other) address:

This page gives you step by step instructions on how to this. These instructions were used with 2.2.2 codebase.

1) Create a profile called "Mailing Address" in CiviCRM to include whatever fields make sense to you, but most likely it will be the standard First Name, Last Name, Street, City, ZIP etc
2) Include your "Mailing Address" Profile in the CiviEvent/CiviContribute configuration screen for each Contribution page and/or Registration page you want to have this Profile
3) Create a custom template (.tpl) directory in Administer > Configure > Global Settings > Directories if you have not done so already ... More info on this procedure here: http://wiki.civicrm.org/confluence/display/CRMDOC/Directories or here http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in%2C+Profile%2C+Contribution+and+Event+Registration+Screens
4) Copy the two .tpl (listed below) into the appropriate folder paths within your custom template folder

  • CRM/Contribute/Form/Contribution/Main.tpl
  • CRM/Event/Form/Registration/Register.tpl

5) In each .tpl file, add the following Javascript+HTML after the ending </fieldset> of the "Billing Name and Address" somewhere around line 140 (give or take a few lines)

Now, I don't claim to be any kind of Javascript expert and therefore it's probably not the most efficient or graceful code but it works and it's very easy to read and understand what the script is doing. If you use fields that are different you can add more fields to the code. The Javascript code has checking so it doesn't try to change fields that don't exist and generate errors.  Hope this helps!

Labels
  • None

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.