CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • TIP: How to copy address to Profile using JavaScript "Same as billing address"
Pages: 1 [2] 3

Author Topic: TIP: How to copy address to Profile using JavaScript "Same as billing address"  (Read 17483 times)

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
January 25, 2011, 01:48:58 pm
Currently that issue is scheduled for 4.1. A patch would probably make it happen sooner :-)
Protect your investment in CiviCRM by  becoming a Member!

annaleevk

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 3
  • Carpe Noctem!
    • Women in Development, New York
  • CiviCRM version: 3.4.5
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.48
  • PHP version: 5.2.14
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
January 25, 2011, 05:38:34 pm
Hmmm....not 3.4?  I thought the original intent was to put it into 3.3?  What pieces are missing to make this happen?  I am not a programmer but my brother's been helping me out so if it's straightforward could we see this in 3.4?

- Annalee

Annalee Van Kleeck
Lyric Systems, LLC
201 951.8711
annalee@lyricsystems.com

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
January 26, 2011, 09:45:58 am
Mostly a matter of generalizing the solution posted earlier in this thread so that it handles variations in the profile fields that are present (since that is configurable by the site admins) - i.e. it only offers the checkbox when there's a profile that was the expected address fields to COPY TO. Also, the checkbox should only "shows up on the form" when the contribution page / event registration page uses a payment processor that collects billing address info on the civi form (as opposed to PayPal Std, Google Chkout etc which collect that on their site).
Protect your investment in CiviCRM by  becoming a Member!

annaleevk

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 3
  • Carpe Noctem!
    • Women in Development, New York
  • CiviCRM version: 3.4.5
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.48
  • PHP version: 5.2.14
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
May 02, 2011, 01:24:19 pm
Hi!  I'm implementing a 3.4 site right now and I'd like to use this posting to implement the billing address copy for my client.  http://wiki.civicrm.org/confluence/display/CRMDOC32/Add+%27Same+as+billing+address%27+button+for+convenience

Quick question for those of us who are not programmers.  The instructions refers to 2 files:
   
CRM/Contribute/Form/Contribution/Main.tpl
CRM/Event/Form/Registration/Register.tpl

I find 2 files ending in .php not .tpl and I also don't see the following reference mentioned: 

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)

Just wondering if these instructions need to be updated for 3.4 or if I'm missing something more obvious here?  It's my first endeavor into custom templates so any help with this would be most appreciated.

Thank you,
Annalee



Annalee Van Kleeck
Lyric Systems, LLC
201 951.8711
annalee@lyricsystems.com

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
May 02, 2011, 01:25:37 pm
There is a folder CRM @ the top level, there is also one called templates & within it there is another CRM folder - which is where you should start looking from
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

annaleevk

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 3
  • Carpe Noctem!
    • Women in Development, New York
  • CiviCRM version: 3.4.5
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.48
  • PHP version: 5.2.14
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
May 02, 2011, 08:50:26 pm
Ah-ha!  Thank you so much!  Now at least I'm looking at the right files...:-)
Annalee Van Kleeck
Lyric Systems, LLC
201 951.8711
annalee@lyricsystems.com

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
October 21, 2011, 10:30:27 am
Updated patch for 3.4:

Quote
Index: templates/CRM/Contribute/Form/Contribution/Main.tpl                                                                                                                                                                                 
===================================================================
--- templates/CRM/Contribute/Form/Contribution/Main.tpl (revision 36074)                                                                                                                                                                   
+++ templates/CRM/Contribute/Form/Contribution/Main.tpl (working copy)                                                                                                                                                                     
@@ -243,6 +243,7 @@
     {/if}                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                           
     {if $is_monetary}                                                                                                                                                                                                                     
+        <input type="checkbox" id="billingcheckbox"> {ts}Billing Address is same as above{/ts}                                                                                                                                           
         {include file='CRM/Core/BillingBlock.tpl'}                                                                                                                                                                                       
     {/if}                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                           
@@ -310,6 +311,34 @@
 {/if}                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                           
 <script type="text/javascript">                                                                                                                                                                                                           
+{literal}                                                                                                                                                                                                                                 
+cj( function( ) {                                                                                                                                                                                                                         
+    cj('#billingcheckbox').click( function( ) {                                                                                                                                                                                           
+        sameAddress( this.checked );                                                                                                                                                                                                     
+        });                                                                                                                                                                                                                               
+    });                                                                                                                                                                                                                                   
+                                                                                                                                                                                                                                         
+function sameAddress( setValue ) {                                                                                                                                                                                                       
+    var locationTypeInProfile = 1;                                                                                                                                                                                                       
+    var orgID = field = fieldName = null;                                                                                                                                                                                                 
+    cj('.billing_name_address-section input').each( function( i ){                                                                                                                                                                       
+            orgID = cj(this).attr('id');                                                                                                                                                                                                 
+            field = orgID.split('-');                                                                                                                                                                                                     
+            fieldName = field[0].replace('billing_', '');                                                                                                                                                                                 
+            if ( field[1] ) {                                                                                                                                                                                                             
+            fieldName = fieldName.replace('_id', '');                                                                                                                                                                                     
+            fieldName =  fieldName + '-' + locationTypeInProfile;                                                                                                                                                                         
+            }                                                                                                                                                                                                                             
+            if ( setValue ) {                                                                                                                                                                                                             
+            cj(this).val( cj('#' + fieldName ).val() );                                                                                                                                                                                   
+            } else {                                                                                                                                                                                                                     
+            cj('#' + fieldName ).val('');                                                                                                                                                                                                 
+            }                                                                                                                                                                                                                             
+            });                                                                                                                                                                                                                           
+}                                                                                                                                                                                                                                         
+{/literal}                                                                                                                                                                                                                               
+                                                                                                                                                                                                                                         
+                                                                                                                                                                                                                                         
 {if $pcp}pcpAnonymous();{/if}                                                                                                                                                                                                             
 {literal}                                                                                                                                                                                                                                 
 var is_monetary = {/literal}{$is_monetary}{literal}
Found this reply helpful? Support CiviCRM

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
February 01, 2012, 06:47:43 pm
I have committed to http://issues.civicrm.org/jira/browse/CRM-5869 for 4.2 - please check there for latest on this
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

annaleevk

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 3
  • Carpe Noctem!
    • Women in Development, New York
  • CiviCRM version: 3.4.5
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.48
  • PHP version: 5.2.14
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
February 02, 2012, 06:04:55 am
FYI -  Hershel wrote a Drupal  module for this a year or so ago.  It's here if you want to see it.  http://forum.civicrm.org/index.php?topic=19830.0
Annalee Van Kleeck
Lyric Systems, LLC
201 951.8711
annalee@lyricsystems.com

AliB

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: D7
  • MySQL version: latest
  • PHP version: 5.3
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
March 25, 2012, 06:40:55 pm
I created my own javascript a while ago for this purpose based on what OP did. I recently wrote a blog post about it.

http://alibakir.com/blog/civicrm-copy-personal-address-to-billing-address-on-a-contribution-page/

I didn't even know that this was a nearly complete feature. Anyway hope it helps someone.

ryeradio

  • I post frequently
  • ***
  • Posts: 185
  • Karma: 1
  • CiviCRM version: 4.2.1
  • CMS version: Drupal
  • MySQL version: MySQL5
  • PHP version: PHP5
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
July 20, 2012, 01:58:14 pm
I am using this code from the civi documentation

http://wiki.civicrm.org/confluence/display/CRMDOC41/Add+'Same+as+billing+address'+button+for+convenience

and everything works great, except for the state is not populating. Does anyone know why the state would not be populating?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
July 26, 2012, 01:18:09 am
Quote
Does anyone know why the state would not be populating?

"State" select options are loaded via ajax, i.e. it is loaded based on selected "Country" field. Hence you need to set the country first and then set the state.
As mentioned by Eileen this is already part of 4.2 release.

This patch might give you rough idea about the changes: https://fisheye2.atlassian.com/changelog/CiviCRM?cs=41098

HTh
Kurund
Found this reply helpful? Support CiviCRM

tso2085

  • I post occasionally
  • **
  • Posts: 75
  • Karma: 0
  • CiviCRM version: 4.7.15
  • CMS version: Joomla 3.6.5
  • MySQL version: 5.5.37
  • PHP version: 5.5.30
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
August 02, 2012, 04:32:52 am
Seeking assistance....

I used this code:
http://wiki.civicrm.org/confluence/display/CRMDOC41/Add+'Same+as+billing+address'+button+for+convenience

to populate from onbehalf of organization during membership signup to an additonal profile for the primary contact, on the same signup page.

However, it is not working.  When I check the box to copy the address info, it does nothing.

For this scenario, the fields are a little different (onbehalf_organization_name, for instance) and am copying it to individual's work address fields (which end in "-2), but I think it should still work.

In my case, do I have more than one "form" on the page and need to distinguish that in the code perhaps?

Any assistance from you gurus would be greatly appreciated!

Craig

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
August 02, 2012, 01:10:08 pm
We have this working in our 4.1.5 deployment (the 6.x.1.x or 7.x.1.x branch here)

git://github.com/fuzionnz/civicrm.git

Note that in both cases the 'drupal' folder is a submodule so you'd need

git clone git://github.com/fuzionnz/civicrm.git
cd civicrm
git branch 6.x.1.x
git submodule update --init
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: TIP: How to copy address to Profile using JavaScript "Same as billing address"
August 02, 2012, 01:10:56 pm
Or better yet - grab the next 4.2 BETA & test using that (where it should be in core)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: 1 [2] 3
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • TIP: How to copy address to Profile using JavaScript "Same as billing address"

This forum was archived on 2017-11-26.