From 6d0c2f61db56c061dad13066d2abfb2056ba0bff Mon Sep 17 00:00:00 2001
From: raftaar1191
Date: Fri, 16 Mar 2018 02:14:32 +0530
Subject: [PATCH 01/67] feat(admin-setting): Add company name fields setting
#2453
---
.../admin/settings/class-settings-display.php | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/includes/admin/settings/class-settings-display.php b/includes/admin/settings/class-settings-display.php
index 1f466beeea..894574abef 100644
--- a/includes/admin/settings/class-settings-display.php
+++ b/includes/admin/settings/class-settings-display.php
@@ -286,6 +286,30 @@ public function get_settings() {
),
);
break;
+ case 'form-settings':
+ $settings = array(
+ array(
+ 'id' => 'give_title_display_settings_5',
+ 'type' => 'title',
+ ),
+ array(
+ 'name' => __( 'Company Donations', 'give' ),
+ 'desc' => __( 'Do you want a Company field to appear after First Name and Last Name?', 'give' ),
+ 'id' => 'company_donation',
+ 'type' => 'radio_inline',
+ 'default' => 'disabled',
+ 'options' => array(
+ 'disabled' => __( 'Disabled', 'give' ),
+ 'required' => __( 'Required', 'give' ),
+ 'optional' => __( 'Optional', 'give' ),
+ ),
+ ),
+ array(
+ 'id' => 'give_title_display_settings_5',
+ 'type' => 'sectionend',
+ ),
+ );
+ break;
}
/**
@@ -319,6 +343,7 @@ public function get_sections() {
'post-types' => __( 'Post Types', 'give' ),
'taxonomies' => __( 'Taxonomies', 'give' ),
'term-and-conditions' => __( 'Terms and Conditions', 'give' ),
+ 'form-settings' => __( 'Forms', 'give' ),
);
return apply_filters( 'give_get_sections_' . $this->id, $sections );
From c38025ae0846d5ee64a668c6fe75e09ee6481ef2 Mon Sep 17 00:00:00 2001
From: raftaar1191
Date: Fri, 16 Mar 2018 03:00:50 +0530
Subject: [PATCH 02/67] feat(admin-donation): Add company name fields setting
in donation page #2453
---
includes/admin/forms/class-metabox-form-data.php | 14 ++++++++++++++
includes/admin/settings/class-settings-display.php | 6 +++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/includes/admin/forms/class-metabox-form-data.php b/includes/admin/forms/class-metabox-form-data.php
index d891cc906d..49df805f2f 100644
--- a/includes/admin/forms/class-metabox-form-data.php
+++ b/includes/admin/forms/class-metabox-form-data.php
@@ -274,6 +274,20 @@ function get_settings() {
'id' => $prefix . 'default_gateway',
'type' => 'default_gateway',
),
+ array(
+ 'name' => __( 'Company Donations', 'give' ),
+ 'desc' => __( 'Do you want a Company field to appear after First Name and Last Name?', 'give' ),
+ 'id' => $prefix . 'company_field',
+ 'type' => 'radio_inline',
+ 'default' => 'global',
+ 'options' => array(
+ 'global' => __( 'Global Option', 'give' ),
+ 'required' => __( 'Required', 'give' ),
+ 'optional' => __( 'Optional', 'give' ),
+ 'disabled' => __( 'Disabled', 'give' ),
+
+ ),
+ ),
array(
'name' => __( 'Guest Donations', 'give' ),
'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ),
diff --git a/includes/admin/settings/class-settings-display.php b/includes/admin/settings/class-settings-display.php
index 894574abef..33a67b5b07 100644
--- a/includes/admin/settings/class-settings-display.php
+++ b/includes/admin/settings/class-settings-display.php
@@ -286,7 +286,7 @@ public function get_settings() {
),
);
break;
- case 'form-settings':
+ case 'form-display':
$settings = array(
array(
'id' => 'give_title_display_settings_5',
@@ -295,7 +295,7 @@ public function get_settings() {
array(
'name' => __( 'Company Donations', 'give' ),
'desc' => __( 'Do you want a Company field to appear after First Name and Last Name?', 'give' ),
- 'id' => 'company_donation',
+ 'id' => 'company_field',
'type' => 'radio_inline',
'default' => 'disabled',
'options' => array(
@@ -343,7 +343,7 @@ public function get_sections() {
'post-types' => __( 'Post Types', 'give' ),
'taxonomies' => __( 'Taxonomies', 'give' ),
'term-and-conditions' => __( 'Terms and Conditions', 'give' ),
- 'form-settings' => __( 'Forms', 'give' ),
+ 'form-display' => __( 'Form Display', 'give' ),
);
return apply_filters( 'give_get_sections_' . $this->id, $sections );
From c4dca2d64d583143418b4ba9793e04f4342f909d Mon Sep 17 00:00:00 2001
From: raftaar1191
Date: Fri, 16 Mar 2018 04:48:00 +0530
Subject: [PATCH 03/67] feat(donation): Add company name fields in donation
page #2453
---
includes/forms/functions.php | 37 ++++++++++++++++++++++++
includes/misc-functions.php | 54 +++++++++++++++++++++++++++++++++--
includes/process-donation.php | 7 +++++
3 files changed, 96 insertions(+), 2 deletions(-)
diff --git a/includes/forms/functions.php b/includes/forms/functions.php
index 1f6b71d377..3bd7198e90 100644
--- a/includes/forms/functions.php
+++ b/includes/forms/functions.php
@@ -1037,3 +1037,40 @@ function _give_get_prefill_form_field_values( $form_id ) {
// Output.
return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
}
+
+/**
+ * Add Company Name fileds in Donation Form.
+ *
+ * @since 2.0.7
+ *
+ * @param int $form_id Donation Form ID.
+ */
+function give_donation_form_company_fields( $form_id ) {
+ if ( give_is_company_donation_show( $form_id ) ) {
+ $give_company = give_field_is_required( 'give_company', $form_id );
+ ?>
+
+
+
+
+ />
+
+
+ 'invalid_company',
+ 'error_message' => __( 'Please enter Company Name.', 'give' ),
+ );
+ }
+
/**
* Filters the donation form required field.
*
From 1c5d41faea860b1c4e914019f039f1e50a2542cc Mon Sep 17 00:00:00 2001
From: raftaar1191
Date: Fri, 16 Mar 2018 05:38:39 +0530
Subject: [PATCH 04/67] feat(donation): Save company name fields at the time of
processing #2453
---
includes/actions.php | 26 ++++++++++++++++++++++++++
includes/forms/functions.php | 2 +-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/includes/actions.php b/includes/actions.php
index 1bc1632bbc..03e94e73bb 100644
--- a/includes/actions.php
+++ b/includes/actions.php
@@ -334,4 +334,30 @@ function give_update_log_form_id( $args ) {
add_action( 'give_update_log_form_id', 'give_update_log_form_id' );
+/**
+ * Add meta in payment that store Company Name.
+ *
+ * Will add/update when user add click on the checkout page.
+ * The status of the donation doest not matter as it get change when user had made the payment successfully.
+ *
+ * @since 2.0.7
+ *
+ * @param int $payment_id Payment id for which the meta value should be updated.
+ */
+function give_donation_save_company_name( $payment_id ) {
+ $give_company = ( ! empty( $_REQUEST['give_company'] ) ? give_clean( $_REQUEST['give_company'] ) : false );
+
+ // Check $page_url is not empty.
+ if ( $give_company ) {
+ give_update_meta( $payment_id, '_give_donation_company', $give_company );
+
+ $donor_id = (int) give_get_meta( $payment_id, '_give_payment_donor_id', true );
+ if ( ! empty( $donor_id ) ) {
+ $donor = new Give_Donor( $donor_id );
+ $donor->update_meta( '_give_donor_company', $give_company );
+ }
+ }
+}
+// Fire when payment is save.
+add_action( 'give_insert_payment', 'give_donation_save_company_name' );
\ No newline at end of file
diff --git a/includes/forms/functions.php b/includes/forms/functions.php
index 3bd7198e90..2a5d42a161 100644
--- a/includes/forms/functions.php
+++ b/includes/forms/functions.php
@@ -1073,4 +1073,4 @@ class="give-input required"
}
}
-add_action( 'give_donation_form_before_email', 'give_donation_form_company_fields', 10, 1 );
\ No newline at end of file
+add_action( 'give_donation_form_before_email', 'give_donation_form_company_fields', 0, 1 );
\ No newline at end of file
From dee1143bdb1a3a6681eebb4d0800965c6430cce7 Mon Sep 17 00:00:00 2001
From: raftaar1191
Date: Fri, 16 Mar 2018 06:10:25 +0530
Subject: [PATCH 05/67] feat(donor): Show save donor company details #2453
---
includes/admin/donors/donors.php | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/includes/admin/donors/donors.php b/includes/admin/donors/donors.php
index 4c15c7fcd9..8fe4c6035e 100644
--- a/includes/admin/donors/donors.php
+++ b/includes/admin/donors/donors.php
@@ -427,6 +427,25 @@ class="button info-item editable donor-edit-link">
+
+ get_meta( '_give_donor_company', true );
+
+ if ( ! empty( $donor_company ) ) {
+ ?>
+
+
+
+ |
+
+
+ |
+
+
From 6c4a5474274faf1d12caf64b6bda371c5e28e3c2 Mon Sep 17 00:00:00 2001
From: raftaar1191
Date: Fri, 16 Mar 2018 06:20:57 +0530
Subject: [PATCH 06/67] feat(shortcode): Show Company name on donation receipt
page #2453
---
templates/shortcode-profile-editor.php | 17 ++++++++++++++++-
templates/shortcode-receipt.php | 18 ++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/templates/shortcode-profile-editor.php b/templates/shortcode-profile-editor.php
index b1ef3beb78..9bdcedb3bb 100644
--- a/templates/shortcode-profile-editor.php
+++ b/templates/shortcode-profile-editor.php
@@ -10,12 +10,16 @@
$current_user = wp_get_current_user();
if ( is_user_logged_in() ) :
- $user_id = get_current_user_id();
+ $user_id = get_current_user_id();
$first_name = get_user_meta( $user_id, 'first_name', true );
$last_name = get_user_meta( $user_id, 'last_name', true );
+ $last_name = get_user_meta( $user_id, 'last_name', true );
$display_name = $current_user->display_name;
$address = give_get_donor_address( $user_id, array( 'address_type' => 'personal' ) );
+ $donor = new Give_Donor( $user_id, true );
+ $company_name = $donor->get_meta( '_give_donor_company', true );
+
if ( isset( $_GET['updated'] ) && 'true' === $_GET['updated'] && ! give_get_errors() ) :
if ( isset( $_GET['update_code'] ) ) :?>
"/>
+
+
+
+
+
+
+