@@ -34,7 +34,7 @@
-
+
$value ) {
if( in_array($value['name'], $fields ) ){ ?>
diff --git a/processors/line-item/class-line-item-processor.php b/processors/line-item/class-line-item-processor.php
index d6c9c44..047cd92 100644
--- a/processors/line-item/class-line-item-processor.php
+++ b/processors/line-item/class-line-item-processor.php
@@ -50,8 +50,8 @@ public function __construct($plugin) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Line Item', 'caldera-forms-civicrm' ),
- 'description' => __( 'Add Line Item for the Order Processor', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Line Item', 'cf-civicrm' ),
+ 'description' => __( 'Add Line Item for the Order Processor', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/line-item/line_item_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
@@ -80,7 +80,7 @@ public function processor( $config, $form, $processid ) {
$transient = $this->plugin->transient->get();
// price field value params aka 'line_item'
- $price_field_value = isset( $config['is_fixed_price_field'] ) ?
+ $price_field_value = isset( $config['is_fixed_price_field'] ) ?
$this->plugin->helper->get_price_field_value( $config['fixed_price_field_value'] ) :
$this->plugin->helper->get_price_field_value( Caldera_Forms::do_magic_tags( $config['price_field_value'] ) );
@@ -142,7 +142,7 @@ public function guess_entity_table( $price_field_value, $entity_table = false )
* Process Membership Line Item.
*
* @since 0.4.4
- *
+ *
* @param array $config Processor config
* @param array $form Form config
* @param object $transient Transient object
@@ -161,8 +161,8 @@ public function process_membership( $config, $form, $transient, $price_field_val
$entity_params = $transient->memberships->$processor_id->params;
- $entity_params['source'] = ! empty( $entity_params['source'] ) ?
- $entity_params['source'] :
+ $entity_params['source'] = ! empty( $entity_params['source'] ) ?
+ $entity_params['source'] :
$form['name'];
}
@@ -174,7 +174,7 @@ public function process_membership( $config, $form, $transient, $price_field_val
$transient->memberships->$processor_id->params = $entity_params;
- $line_item = [
+ $line_item = [
'processor_entity' => $processor_id,
'line_item' => $price_field_value,
'params' => $entity_params
@@ -188,9 +188,9 @@ public function process_membership( $config, $form, $transient, $price_field_val
/**
* Process Participant Line Item.
- *
+ *
* @since 1.0
- *
+ *
* @param array $config Processor config
* @param array $form Form config
* @param object $transient Transient object
@@ -223,8 +223,8 @@ public function process_participant( $config, $form, $transient, $price_field_va
$entity_params = $transient->participants->$processor_id->params;
- $entity_params['source'] = ! empty( $entity_params['source'] ) ?
- $entity_params['source'] :
+ $entity_params['source'] = ! empty( $entity_params['source'] ) ?
+ $entity_params['source'] :
$form['name'];
// need to set price set id, otherwise Participant.create from Order.create
@@ -243,7 +243,7 @@ public function process_participant( $config, $form, $transient, $price_field_va
$transient->participants->$processor_id->params = $entity_params;
- $line_item = [
+ $line_item = [
'processor_entity' => $processor_id,
'line_item' => $price_field_value,
'params' => $entity_params
@@ -257,9 +257,9 @@ public function process_participant( $config, $form, $transient, $price_field_va
/**
* Process Contribution Line Item.
- *
+ *
* @since 0.4.4
- *
+ *
* @param array $config Processor config
* @param array $form Form config
* @param object $transient Transient object
@@ -311,7 +311,7 @@ public function build_price_field_values_array( $price_field_value, $entity_tabl
$field_value['entity_table'] = $entity_table ? $entity_table : $this->guess_entity_table( $price_field_value );
- unset(
+ unset(
$field_value['id'],
$field_value['name'],
$field_value['amount'],
diff --git a/processors/line-item/line_item_config.php b/processors/line-item/line_item_config.php
index f7d1dc4..c5df947 100644
--- a/processors/line-item/line_item_config.php
+++ b/processors/line-item/line_item_config.php
@@ -1,9 +1,9 @@
__( 'CiviCRM Participant', 'caldera-forms-civicrm' ),
- 'civicrm_membership' => __( 'CiviCRM Membership', 'caldera-forms-civicrm' ),
- 'civicrm_contribution' => __( 'CiviCRM Contribution', 'caldera-forms-civicrm' ),
+ 'civicrm_participant' => __( 'CiviCRM Participant', 'cf-civicrm' ),
+ 'civicrm_membership' => __( 'CiviCRM Membership', 'cf-civicrm' ),
+ 'civicrm_contribution' => __( 'CiviCRM Contribution', 'cf-civicrm' ),
];
$membership_types = civicrm_api3( 'MembershipType', 'get', [
@@ -23,7 +23,7 @@
-
+
$entity_name ) { ?>
@@ -34,26 +34,26 @@
-
+
-
When \'Entity Table\' is set to CiviCRM Contribution, set the Participant processor magic tag if this is a Contribution Line Item associated to a particular Participant, like for example a Donation.', 'caldera-forms-civicrm') );?>
+
When \'Entity Table\' is set to CiviCRM Contribution, set the Participant processor magic tag if this is a Contribution Line Item associated to a particular Participant, like for example a Donation.', 'cf-civicrm') );?>
-
+
@@ -83,7 +83,7 @@
@@ -91,22 +91,22 @@
\ No newline at end of file
+ } );
+
diff --git a/processors/membership/class-membership-processor.php b/processors/membership/class-membership-processor.php
index 15b30f5..07940ba 100644
--- a/processors/membership/class-membership-processor.php
+++ b/processors/membership/class-membership-processor.php
@@ -15,10 +15,10 @@ class CiviCRM_Caldera_Forms_Membership_Processor {
* @var object $plugin The plugin instance
*/
public $plugin;
-
+
/**
* Contact link.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $contact_link The contact link
@@ -28,7 +28,7 @@ class CiviCRM_Caldera_Forms_Membership_Processor {
/**
* Current contact's memeberships.
*
- * @since 0.4.4
+ * @since 0.4.4
* @var array
*/
protected $has_memberships;
@@ -80,8 +80,8 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Membership', 'caldera-forms-civicrm' ),
- 'description' => __( 'Create/Renew CiviCRM Memberhips.', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Membership', 'cf-civicrm' ),
+ 'description' => __( 'Create/Renew CiviCRM Memberhips.', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/membership/membership_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
@@ -106,6 +106,16 @@ public function pre_processor( $config, $form, $processid ) {
global $transdata;
+ /**
+ * Filter processor config.
+ *
+ * @since 1.0.3
+ * @param array $config The processor config
+ * @param array $form The form config
+ * @param string $processid The process id
+ */
+ $config = apply_filters( 'cfc_membership_pre_processor_config', $config, $form, $processid );
+
// cfc transient object
$transient = $this->plugin->transient->get();
$this->contact_link = 'cid_' . $config['contact_link'];
@@ -114,11 +124,11 @@ public function pre_processor( $config, $form, $processid ) {
$form_values = $this->plugin->helper->map_fields_to_processor( $config, $form, $form_values );
// price field value, if applicable
- $price_field_value = isset( $config['is_price_field_based'] ) ?
+ $price_field_value = isset( $config['is_price_field_based'] ) ?
$this->plugin->helper->get_price_field_value( $form_values['price_field_value'] ) : false;
$form_values['membership_type_id'] = $price_field_value ? $price_field_value['membership_type_id'] : $config['membership_type_id'];
-
+
// is member?
try {
$is_member = civicrm_api3( 'Membership', 'getsingle', [
@@ -126,17 +136,41 @@ public function pre_processor( $config, $form, $processid ) {
'membership_type_id' => $form_values['membership_type_id'],
] );
} catch ( CiviCRM_API3_Exception $e ) {
- // ignore
+ $is_member = false;
}
-
- if ( ! empty( $transient->contacts->{$this->contact_link} ) ) {
+
+ /**
+ * Filter to abort membership processing.
+ *
+ * To abort a membership from being processed return true or,
+ * to abort the form from processing return an array like:
+ * [ 'note' => 'Some message', 'type' => 'success|error|info|warning|danger' ]
+ * The form processing will stop displaying 'Some message'
+ *
+ * @since 1.0.3
+ * @param bool|array $return Whether to abort the processing of a memebership
+ * @param bool|array $membership The current membership being processed or false
+ * @param array $form_values The submitted form values for this membership
+ * @param array $config The processor config
+ * @param array $form The form config
+ * @param string $processid The process id
+ */
+ $return = apply_filters( 'cfc_membership_pre_processor_return', false, $is_member, $form_values, $config, $form, $processid );
+
+ if ( ! empty( $transient->contacts->{$this->contact_link} ) && ! $return ) {
$form_values['contact_id'] = $transient->contacts->{$this->contact_link};
+ if ( ! empty( $config['campaign_id'] ) ) $form_values['campaign_id'] = $config['campaign_id'];
+
// renew/extend necessary params
- if ( isset( $config['is_renewal'] ) && isset( $is_member['id'] ) )
+ if ( isset( $config['is_renewal'] ) && isset( $is_member['id'] ) ) {
$form_values['id'] = $is_member['id'];
+ // Ask the API to calculate the status for us.
+ $form_values['skipStatusCal'] = 0;
+ }
+
$form_values['source'] = isset( $form_values['source'] ) ? $form_values['source'] : $form['name'];
// set start and join date if is not renewal
@@ -151,6 +185,17 @@ public function pre_processor( $config, $form, $processid ) {
// get num_terms
$form_values['num_terms'] = $this->get_num_terms( $form_values, $price_field_value );
+ /**
+ * Filter form values/membership params before processing or storing in transient.
+ *
+ * @since 1.0.3
+ * @param array $form_values The submitted form value/membership api params
+ * @param array $config The processor config
+ * @param array $form The form config
+ * @param string $processid The process id
+ */
+ $form_values = apply_filters( 'cfc_membership_pre_processor_form_values', $form_values, $config, $form, $processid );
+
$transient->memberships->{$config['processor_id']}->params = $form_values;
$this->plugin->transient->save( $transient->ID, $transient );
@@ -165,6 +210,8 @@ public function pre_processor( $config, $form, $processid ) {
return [ 'note' => $error, 'type' => 'error' ];
}
}
+ } elseif ( isset( $return['type'] ) && isset( $return['note'] ) ) {
+ return $return;
}
}
@@ -172,8 +219,8 @@ public function pre_processor( $config, $form, $processid ) {
* Form processor callback.
*
* @since 0.4.4
- *
- * @param array $config Processor configuration
+ *
+ * @param array $config Processor configuration
* @param array $form Form configuration
* @param string $processid The process id (it may not be set)
*/
@@ -309,7 +356,7 @@ public function render_notices( $notices ) {
$end_date = date_format( date_create( $membership['end_date'] ), 'F d, Y' );
$notices[] = [
'type' => 'warning',
- 'note' => sprintf( __( 'Your
%1$s membership expires on %2$s.', 'caldera-forms-civicrm' ), $membership['membership_name'], $end_date )
+ 'note' => sprintf( __( 'Your
%1$s membership expires on %2$s.', 'cf-civicrm' ), $membership['membership_name'], $end_date )
];
}
}
diff --git a/processors/membership/membership_config.php b/processors/membership/membership_config.php
index 4ee5236..f613d84 100644
--- a/processors/membership/membership_config.php
+++ b/processors/membership/membership_config.php
@@ -7,10 +7,10 @@
$membership_fields = [];
foreach ( $fields['values'] as $key => $value ) {
- $membership_fields[$value['name']] = $value['title'];
+ $membership_fields[$value['name']] = $value['title'];
}
-$ignore = [ 'membership_type_id', 'contact_id', 'is_test', 'status_id', 'is_override', 'status_override_end_date', 'owner_membership_id', 'max_related', 'contribution_recur_id', 'id', 'is_pay_later', 'skipStatusCal' ];
+$ignore = [ 'membership_type_id', 'contact_id', 'is_test', 'status_id', 'is_override', 'status_override_end_date', 'owner_membership_id', 'max_related', 'contribution_recur_id', 'id', 'is_pay_later', 'skipStatusCal', 'campaign_id' ];
$current_fields = [ 'source' ];
@@ -21,74 +21,95 @@
'options' => [ 'limit' => 0 ],
] );
+$campaigns = civicrm_api3( 'Campaign', 'get', [
+ 'sequential' => 1,
+ 'is_active' => 1,
+ 'options' => [ 'limit' => 0 ],
+] );
+
?>
+
+
-
+
+
+
+
+
+
+
+ $value ) { ?>
+ }}selected="selected"{{/is}}>
+
+
+
+
+
-
- $value ) {
+
+ $value ) {
if( ! in_array( $key, $ignore ) ) { ?>
@@ -99,7 +120,7 @@
\ No newline at end of file
+ } );
+
diff --git a/processors/note/class-note-processor.php b/processors/note/class-note-processor.php
index cdec2f9..3946628 100644
--- a/processors/note/class-note-processor.php
+++ b/processors/note/class-note-processor.php
@@ -15,10 +15,10 @@ class CiviCRM_Caldera_Forms_Note_Processor {
* @var object $plugin The plugin instance
*/
public $plugin;
-
+
/**
* Contact link.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $contact_link The contact link
@@ -59,8 +59,8 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Note', 'caldera-forms-civicrm' ),
- 'description' => __( 'Add CiviCRM note to contacts', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Note', 'cf-civicrm' ),
+ 'description' => __( 'Add CiviCRM note to contacts', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/note/note_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
@@ -102,7 +102,7 @@ public function pre_processor( $config, $form, $proccesid ) {
* @since 0.4.2
*/
if ( ! empty( $config['note_attachment'] ) )
- $this->plugin->helper->handle_file_attachments_core(
+ $this->plugin->helper->handle_file_attachments_core(
'civicrm_note',
$note['id'],
$config['note_attachment'],
diff --git a/processors/note/note_config.php b/processors/note/note_config.php
index 0719aba..c729ae5 100644
--- a/processors/note/note_config.php
+++ b/processors/note/note_config.php
@@ -8,18 +8,18 @@
?>
-
+
-
+
$value ) {
if( in_array($value['name'], $fields ) ){ ?>
@@ -31,7 +31,7 @@
-
+
diff --git a/processors/order/class-order-processor.php b/processors/order/class-order-processor.php
index 5063515..ad625c3 100644
--- a/processors/order/class-order-processor.php
+++ b/processors/order/class-order-processor.php
@@ -18,7 +18,7 @@ class CiviCRM_Caldera_Forms_Order_Processor {
/**
* Contact link.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $contact_link The contact link
@@ -27,7 +27,7 @@ class CiviCRM_Caldera_Forms_Order_Processor {
/**
* Payment processor fee.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $fee The fee
@@ -97,15 +97,15 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Order', 'caldera-forms-civicrm' ),
- 'description' => __( 'Add CiviCRM Order (Contribution with multiple Line Items, ie Events registrations, Donations, Memberships, etc.)', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Order', 'cf-civicrm' ),
+ 'description' => __( 'Add CiviCRM Order (Contribution with multiple Line Items, ie Events registrations, Donations, Memberships, etc.)', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/order/order_config.php',
'single' => true,
'pre_processor' => [ $this, 'pre_processor' ],
'processor' => [ $this, 'processor' ],
'post_processor' => [ $this, 'post_processor'],
- 'magic_tags' => [ 'order_id' ]
+ 'magic_tags' => [ 'order_id', 'processor_id' ]
];
return $processors;
@@ -122,7 +122,7 @@ public function register_processor( $processors ) {
* @param string $processid The process id
*/
public function pre_processor( $config, $form, $processid ) {
-
+
}
/**
@@ -135,7 +135,7 @@ public function pre_processor( $config, $form, $processid ) {
* @param string $processid The process id
*/
public function processor( $config, $form, $processid ) {
-
+
global $transdata;
$transient = $this->plugin->transient->get();
@@ -149,7 +149,7 @@ public function processor( $config, $form, $processid ) {
$form_values['payment_instrument_id'] = ! isset( $config['is_mapped_field'] ) ?
$config['payment_instrument_id'] :
$form_values['mapped_payment_instrument_id'];
-
+
$form_values['currency'] = $config['currency'];
if ( ! empty( $config['campaign_id'] ) ) $form_values['campaign_id'] = $config['campaign_id'];
@@ -165,13 +165,13 @@ public function processor( $config, $form, $processid ) {
$form_values['is_pay_later'] = 1; // has to be set, if not we get a (Incomplete transaction)
unset( $form_values['trxn_id'] );
}
-
+
// source
if( ! isset( $form_values['source'] ) )
$form_values['source'] = $form['name'];
-
+
$form_values['contact_id'] = $transient->contacts->{$this->contact_link};
-
+
// line items
$line_items = $this->build_line_items_params( $transient, $config, $form );
@@ -187,7 +187,7 @@ public function processor( $config, $form, $processid ) {
// FIXME
// move this into its own finction
- //
+ //
// authorize metadata
if( isset( $transdata[$transdata['transient']]['transaction_data']->transaction_id ) ) {
$metadata = [
@@ -207,17 +207,26 @@ public function processor( $config, $form, $processid ) {
$this->order = ( $create_order['count'] && ! $create_order['is_error'] ) ? $create_order['values'][$create_order['id']] : false;
// create product
- if ( $this->order )
+ if ( $this->order ) {
$this->create_premium( $this->order, $form_values, $config );
+ // save orde data in transient
+ $transient->orders->{$config['processor_id']}->params = $this->order;
+ $this->plugin->transient->save( $transient->ID, $transient );
+ }
+
} catch ( CiviCRM_API3_Exception $e ) {
$transdata['error'] = true;
$transdata['note'] = $e->getMessage() . '
' . $e->getTraceAsString() . ' ';
}
// return order_id magic tag
- if ( is_array( $create_order ) && ! $create_order['is_error'] )
- return $create_order['id'];
+ if ( is_array( $create_order ) && ! $create_order['is_error'] ){
+ return [
+ 'order_id' => $create_order['id'],
+ 'processor_id' => $config['processor_id']
+ ];
+ }
}
@@ -235,7 +244,7 @@ public function post_processor( $config, $form, $processid ) {
global $transdata;
$transient = $this->plugin->transient->get();
- // preserve join dates
+ // preserve join dates
$this->preserve_membership_join_date( $form );
$line_items = civicrm_api3( 'LineItem', 'get', [
@@ -251,7 +260,7 @@ public function post_processor( $config, $form, $processid ) {
* Filter thank you template path.
*
* @since 0.4.4
- *
+ *
* @param string $template_path The template path
* @param array $form Form config
*/
@@ -287,7 +296,7 @@ public function post_processor( $config, $form, $processid ) {
*/
do_action( 'cfc_order_post_processor', $this->order, $config, $form, $processid );
- // send confirmation/receipt
+ // send confirmation/receipt
$this->maybe_send_confirmation( $this->order, $config );
}
@@ -315,13 +324,18 @@ public function build_line_items_params( $transient, $config, $form ) {
$line_item = $transient->line_items->$item_processor_id->params;
- if ( isset( $line_item['line_item'][0]['tax_amount'] ) && $this->plugin->helper->get_tax_settings()['invoicing'] )
+ if ( isset( $line_item['line_item'][0]['tax_amount'] ) && $this->plugin->helper->get_tax_settings()['invoicing'] )
$this->total_tax_amount += $line_item['line_item'][0]['tax_amount'];
// set membership as pending
if ( isset( $line_item['params']['membership_type_id'] ) && $this->is_pay_later ) {
- $line_item['params']['status_id'] = 'Pending';
- $line_item['params']['is_override'] = 1;
+ if ( ! $line_item['params']['id'] ) {
+ $line_item['params']['status_id'] = 'Pending';
+ } else {
+ $line_item['params']['num_terms'] = 0;
+ }
+ $line_item['params']['is_pay_later'] = 1;
+ $line_item['params']['skipStatusCal'] = 1;
}
// set participant as pending
@@ -349,7 +363,7 @@ public function build_line_items_params( $transient, $config, $form ) {
* Reformats the line items to correctly add otpions like donations
* assigned to the right enity, participant in this case.
*
- * @since 1.0.1
+ * @since 1.0.1
* @param array $line_items The formated line items
* @param array $config The processor config
* @param array $form The form config
@@ -367,7 +381,7 @@ public function maybe_format_line_items_to_entity( $line_items, $config, $form )
$processors = array_merge( $processors, $participant_processors );
if ( is_array( $membership_pprocessors ) )
- $processors = array_merge( $processors, $membership_pprocessors );
+ $processors = array_merge( $processors, $membership_pprocessors );
if ( empty( $processors ) ) return $line_items;
@@ -396,7 +410,7 @@ public function maybe_format_line_items_to_entity( $line_items, $config, $form )
$price_field_values_ids = array_column( $lines, 'price_field_value_id' );
- // there cannot be duplicated price field options for the same item
+ // there cannot be duplicated price field options for the same item
if ( ! in_array( $line['price_field_value_id'], $price_field_values_ids ) )
$lines[] = $line;
@@ -444,9 +458,9 @@ public function maybe_format_line_items_to_entity( $line_items, $config, $form )
* @param array $form Form configuration
*/
function preserve_membership_join_date( $form ) {
-
+
$transient = $this->plugin->transient->get();
-
+
if ( Caldera_Forms::get_processor_by_type( 'civicrm_membership', $form ) ) {
foreach ( $form['processors'] as $id => $processor ) {
if ( $processor['type'] == 'civicrm_membership' && isset( $processor['config']['preserve_join_date'] ) ) {
@@ -457,13 +471,13 @@ function preserve_membership_join_date( $form ) {
add_filter( 'cfc_current_membership_get_status', [ $this, 'add_expired_status' ], 10 );
if ( isset( $processor['config']['is_membership_type'] ) ) {
// get oldest membersip
- $oldest_membership = $this->plugin->helper->get_membership(
+ $oldest_membership = $this->plugin->helper->get_membership(
$transient->contacts->{$this->contact_link},
$transient->memberships->$id->params['membership_type_id'],
'ASC'
);
} else {
- $oldest_membership = $this->plugin->helper->get_membership(
+ $oldest_membership = $this->plugin->helper->get_membership(
$transient->contacts->{$this->contact_link},
$membership_type = false,
$sort = 'ASC'
@@ -473,11 +487,11 @@ function preserve_membership_join_date( $form ) {
remove_filter( 'cfc_current_membership_get_status', [ $this, 'add_expired_status' ], 10 );
if ( $this->is_pay_later ) {
- // is pay later, filter membership status to pending
+ // is pay later, filter membership status to pending
add_filter( 'cfc_current_membership_get_status', [ $this, 'set_pending_status' ], 10 );
// get latest membership
if ( $oldest_membership )
- $latest_membership = $this->plugin->helper->get_membership(
+ $latest_membership = $this->plugin->helper->get_membership(
$transient->contacts->{$this->contact_link},
$transient->memberships->$id->params['membership_type_id']
);
@@ -485,14 +499,14 @@ function preserve_membership_join_date( $form ) {
remove_filter( 'cfc_current_membership_get_status', [ $this, 'set_pending_status' ], 10 );
} else {
if ( $oldest_membership )
- $latest_membership = $this->plugin->helper->get_membership(
+ $latest_membership = $this->plugin->helper->get_membership(
$transient->contacts->{$this->contact_link},
$transient->memberships->$id->params['membership_type_id'],
$sort = 'DESC',
$skip_status = true
);
}
-
+
if ( $latest_membership && date( 'Y-m-d', strtotime( $oldest_membership['join_date'] ) ) < date( 'Y-m-d', strtotime( $latest_membership['join_date'] ) ) ) {
// is latest/current membership one of associated?
if ( $associated_memberships && in_array( $latest_membership['membership_type_id'], $associated_memberships ) ) {
@@ -536,7 +550,7 @@ public function add_expired_status( $statuses ) {
* Add payment processor hooks before pre process starts.
*
* @since 0.4.4
- *
+ *
* @param array $form Form config
* @param array $referrer URL referrer
* @param string $process_id The process id
@@ -550,7 +564,7 @@ public function add_payment_processor_hooks( $form, $referrer, $process_id ) {
* Filter Authorize single payment customer data.
*
* @since 0.4.4
- *
+ *
* @param object $customer Customer data
* @param string $prefix processor slug prefix
* @param object $data_object Processor data object
@@ -563,7 +577,7 @@ public function add_payment_processor_hooks( $form, $referrer, $process_id ) {
if ( ! empty( $field['config_field'] ) ) {
// get field config
$field_config = Caldera_Forms_Field_Util::get_field( $field['config_field'], $form );
-
+
// replace country id with label
if ( $field_config['type'] == 'civicrm_country' )
$customer->country = $this->plugin->fields->field_objects['civicrm_country']->field_render_view( $customer->country, $field_config, $form );
@@ -583,7 +597,7 @@ public function add_payment_processor_hooks( $form, $referrer, $process_id ) {
* Process the Stripe balance transaction to get the fee and card detials.
*
* @since 0.4.4
- *
+ *
* @param array $return_charge Data about the successful charge
* @param array $transdata Data used to create transaction
* @param array $config The proessor config
@@ -592,10 +606,10 @@ public function add_payment_processor_hooks( $form, $referrer, $process_id ) {
add_action( 'cf_stripe_post_successful_charge', function( $return_charge, $transdata, $config, $stripe_form ) {
// stripe charge object from the successful payment
$balance_transaction_id = $transdata['stripe']->balance_transaction;
-
+
\Stripe\Stripe::setApiKey( $config['secret'] );
$balance_transaction_object = \Stripe\BalanceTransaction::retrieve( $balance_transaction_id );
-
+
$charge_metadata = [
'fee_amount' => $balance_transaction_object->fee / 100,
'card_type_id' => $this->get_option_by_label( $transdata['stripe']->source->brand ),
@@ -756,12 +770,12 @@ public function has_participant_item( $line_items ) {
* Send email confirmation/receipt.
*
* @since 0.4.4
- *
+ *
* @param array $order The Order api result
* @param array $config Processor config
*/
public function maybe_send_confirmation( $order, $config ) {
-
+
if ( ! $order ) return;
if ( isset( $order['id'] ) && isset( $config['is_email_receipt'] ) ) {
@@ -777,7 +791,7 @@ public function maybe_send_confirmation( $order, $config ) {
* Get OptionValue by label.
*
* @since 0.4.4
- *
+ *
* @param string $label
* @return mixed $value
*/
@@ -786,9 +800,9 @@ public function get_option_by_label( $label ) {
$option_value = civicrm_api3( 'OptionValue', 'getsingle', [
'label' => $label,
] );
-
+
} catch ( CiviCRM_API3_Exception $e ) {
- // ignore
+ // ignore
}
if ( isset( $option_value ) && is_array( $option_value ) )
diff --git a/processors/order/order_config.php b/processors/order/order_config.php
index 5621d67..2fbb054 100644
--- a/processors/order/order_config.php
+++ b/processors/order/order_config.php
@@ -40,18 +40,18 @@
?>
-
Note: This processor does not process payment transactions on it\'s own, it just creates a Contribution in CiviCRM with single or multiple line items. In order to process live payment transaction, a Caldera Forms add-on is needed. Currently this processor intergrates with Caldera Forms\' Stripe and Authorize.net add-ons for single/one-off payments.', 'caldera-forms-civicrm' ) ); ?>
+
Note: This processor does not process payment transactions on it\'s own, it just creates a Contribution in CiviCRM with single or multiple line items. In order to process live payment transaction, a Caldera Forms add-on is needed. Currently this processor intergrates with Caldera Forms\' Stripe and Authorize.net add-ons for single/one-off payments.', 'cf-civicrm' ) ); ?>
-
+
-
fill the data in the receipt, those settings are optional, but please set those if you want better reciepts.', 'caldera-forms-civicrm' ) ); ?>
-
+
fill the data in the receipt, those settings are optional, but please set those if you want better reciepts.', 'cf-civicrm' ) ); ?>
+
@@ -62,7 +62,7 @@
-
+
@@ -77,28 +77,28 @@
-
+
-
+
-
+
$financial_type ) { ?>
@@ -110,7 +110,7 @@
-
+
@@ -123,7 +123,7 @@
-
+
$status ) { ?>
@@ -135,7 +135,7 @@
-
+
$method ) { ?>
@@ -144,7 +144,7 @@
-
+
@@ -153,7 +153,7 @@
-
+
@@ -163,13 +163,13 @@
-
+
-
+
{{{_field slug="receive_date"}}}
@@ -177,7 +177,7 @@
-
+
{{{_field slug="trxn_id"}}}
@@ -185,7 +185,7 @@
-
+
$currency ) { ?>
@@ -197,7 +197,7 @@
-
+
{{{_field slug="check_number"}}}
@@ -205,7 +205,7 @@
-
+
{{{_field slug="product_id" type="civicrm_premium"}}}
@@ -213,7 +213,7 @@
-
+
{{{_field slug="total_amount"}}}
@@ -222,27 +222,27 @@
-
+
{{#each this.line_items as |value item|}}
-
+
@@ -251,7 +251,7 @@ class="pull-right button ajax-trigger"
{{/each}}
{{#unless this.line_items}}
-
+
@@ -261,13 +261,13 @@ class="pull-right button ajax-trigger"
diff --git a/processors/phone/class-phone-processor.php b/processors/phone/class-phone-processor.php
index a633cfb..169f36e 100644
--- a/processors/phone/class-phone-processor.php
+++ b/processors/phone/class-phone-processor.php
@@ -15,10 +15,10 @@ class CiviCRM_Caldera_Forms_Phone_Processor {
* @var object $plugin The plugin instance
*/
public $plugin;
-
+
/**
* Contact link.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $contact_link The contact link
@@ -70,8 +70,8 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Phone', 'caldera-forms-civicrm' ),
- 'description' => __( 'Add CiviCRM phone to contacts', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Phone', 'cf-civicrm' ),
+ 'description' => __( 'Add CiviCRM phone to contacts', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/phone/phone_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
@@ -96,7 +96,7 @@ public function pre_processor( $config, $form, $processid ) {
$this->contact_link = 'cid_' . $config['contact_link'];
if ( ! empty( $transient->contacts->{$this->contact_link} ) ) {
-
+
try {
$phone = civicrm_api3( 'Phone', 'getsingle', [
@@ -143,7 +143,7 @@ public function pre_processor( $config, $form, $processid ) {
* @return array $form The modified form
*/
public function pre_render( $form ){
-
+
// continue as normal if form has no processors
if ( empty( $form['processors'] ) ) return $form;
diff --git a/processors/phone/phone_config.php b/processors/phone/phone_config.php
index 0544919..a0f38f5 100644
--- a/processors/phone/phone_config.php
+++ b/processors/phone/phone_config.php
@@ -18,19 +18,19 @@
?>
-
+
-
+
@@ -43,7 +43,7 @@
-
+
@@ -56,7 +56,7 @@
-
+
$value ) {
if ( in_array( $value['name'], $fields ) ) { ?>
diff --git a/processors/relationship/class-relationship-processor.php b/processors/relationship/class-relationship-processor.php
index 8a4f891..5c2aa81 100644
--- a/processors/relationship/class-relationship-processor.php
+++ b/processors/relationship/class-relationship-processor.php
@@ -48,8 +48,8 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Relationship', 'caldera-forms-civicrm' ),
- 'description' => __( 'Add CiviCRM relationship to contacts', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Relationship', 'cf-civicrm' ),
+ 'description' => __( 'Add CiviCRM relationship to contacts', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/relationship/relationship_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
diff --git a/processors/relationship/relationship_config.php b/processors/relationship/relationship_config.php
index cd3eafd..24ae631 100644
--- a/processors/relationship/relationship_config.php
+++ b/processors/relationship/relationship_config.php
@@ -9,7 +9,7 @@
?>
-
+
$value ) { ?>
@@ -20,37 +20,37 @@
diff --git a/processors/send-email/class-send-email-processor.php b/processors/send-email/class-send-email-processor.php
index b6e07fb..a650928 100644
--- a/processors/send-email/class-send-email-processor.php
+++ b/processors/send-email/class-send-email-processor.php
@@ -17,7 +17,7 @@ class CiviCRM_Caldera_Forms_Send_Email_Processor {
/**
* Contact link.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $contact_link The contact link
@@ -58,8 +58,8 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Send Email', 'caldera-forms-civicrm' ),
- 'description' => __( 'Send Email from CiviCRM (CiviCRM message templates, requires Email API)', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Send Email', 'cf-civicrm' ),
+ 'description' => __( 'Send Email from CiviCRM (CiviCRM message templates, requires Email API)', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/send-email/send_email_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
@@ -89,12 +89,12 @@ public function pre_processor( $config, $form, $processid ) {
'template_id' => $config['template_id'],
];
- if ( isset( $config['from_name'] ) && isset( $config['from_email'] ) ) {
+ if ( ! empty( $config['from_name'] ) && ! empty( $config['from_email'] ) ) {
$params['from_name'] = $config['from_name'];
$params['from_email'] = $config['from_email'];
}
- if ( isset( $config['alternative_receiver_address'] ) ) {
+ if ( ! empty( $config['alternative_receiver_address'] ) ) {
$params['alternative_receiver_address'] = $config['alternative_receiver_address'];
}
diff --git a/processors/send-email/send_email_config.php b/processors/send-email/send_email_config.php
index 6531695..0cb604e 100644
--- a/processors/send-email/send_email_config.php
+++ b/processors/send-email/send_email_config.php
@@ -10,19 +10,19 @@
?>
-
+
-
+
$value ) { ?>
@@ -35,21 +35,21 @@
-
+
diff --git a/processors/website/class-website-processor.php b/processors/website/class-website-processor.php
index 0f5571a..4cfd2f0 100644
--- a/processors/website/class-website-processor.php
+++ b/processors/website/class-website-processor.php
@@ -18,7 +18,7 @@ class CiviCRM_Caldera_Forms_Website_Processor {
/**
* Contact link.
- *
+ *
* @since 0.4.4
* @access protected
* @var string $contact_link The contact link
@@ -70,8 +70,8 @@ public function __construct( $plugin ) {
public function register_processor( $processors ) {
$processors[$this->key_name] = [
- 'name' => __( 'CiviCRM Website', 'caldera-forms-civicrm' ),
- 'description' => __( 'Add CiviCRM website to contacts', 'caldera-forms-civicrm' ),
+ 'name' => __( 'CiviCRM Website', 'cf-civicrm' ),
+ 'description' => __( 'Add CiviCRM website to contacts', 'cf-civicrm' ),
'author' => 'Andrei Mondoc',
'template' => CF_CIVICRM_INTEGRATION_PATH . 'processors/website/website_config.php',
'pre_processor' => [ $this, 'pre_processor' ],
@@ -143,7 +143,7 @@ public function pre_processor( $config, $form, $processid ) {
* @return array $form The modified form
*/
public function pre_render( $form ){
-
+
// continue as normal if form has no processors
if ( empty( $form['processors'] ) ) return $form;
diff --git a/processors/website/website_config.php b/processors/website/website_config.php
index a044ab1..0e36f70 100644
--- a/processors/website/website_config.php
+++ b/processors/website/website_config.php
@@ -11,17 +11,17 @@
$fields = [ 'url' ];
?>
-
+
-
+
@@ -34,7 +34,7 @@
-
+
$value ) {
if( in_array($value['name'], $fields ) ){ ?>
diff --git a/readme.txt b/readme.txt
index 1b673ad..9713aa9 100755
--- a/readme.txt
+++ b/readme.txt
@@ -1,9 +1,9 @@
=== Caldera Forms CiviCRM ===
Contributors: mecachisenros, needle
Tags: civicrm, caldera, forms, integration
-Requires at least: 4.5
-Tested up to: 5.1
-Stable tag: 1.0.2
+Requires at least: 4.7
+Tested up to: 5.2.2
+Stable tag: 1.0.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -20,7 +20,7 @@ This plugin requires a minimum of *CiviCRM 4.6* and *Caldera Forms 1.7.3*.
### Plugin Development
-This plugin is in active development. For feature requests and bug reports (or if you're a plugin author and want to contribute) please visit the plugin's [GitHub repository](https://github.com/mecachisenros/caldera-forms-civicrm).
+This plugin is in active development. For feature requests and bug reports (or if you're a plugin author and want to contribute) please visit the plugin's [GitHub repository](https://github.com/mecachisenros/cf-civicrm).
@@ -34,6 +34,27 @@ This plugin is in active development. For feature requests and bug reports (or i
== Changelog ==
+= 1.0.3 =
+* Published to WP plugin directory, text domain has changed from 'caldera-forms-civicrm' to 'cf-civicrm'
+* Added 'cfc_participant_pre_processor_config' filter
+* Added 'cfc_participant_pre_processor_event_config' filter
+* Added 'cfc_participant_processor_config_template_before_link' action
+* Added 'cfc_participant_pre_processor_return' filter
+* Participant processor can handle multiple registrations for the same contact through the added hooks
+* Fix - Re-registration based on 'Allow same participant email'
+* Date pickers auto-population respects the date format, thanks @kirk-circle
+* Added 'cfc_membership_pre_processor_config' filter
+* Added 'cfc_membership_pre_processor_return' filter
+* Added 'cfc_membership_processor_config_template_before_link' action
+* Added Campaign field for Membership processor
+* Fix - Auto-population checkbox ignored, the form would always be autopopulated with the current user data
+* Case processor now supports custom fields, and custom fields autopopulation/presets
+* Contact Reference can be mapped for Organization Name
+* FIX - jQuery could not be defined breaking processor templates
+* Added 'cfc_case_processor_case_create' action
+* Added 'cfc_case_pre_processor_return' filter
+* Added 'cfc_case_processor_config_template_before_link' action
+
= 1.0.2 =
* Added Participant processor for free and paid events
* Price sets improvements
@@ -52,8 +73,8 @@ This plugin is in active development. For feature requests and bug reports (or i
* Added option to submit empty/blank values for Address entity
* Moved scripts and styles to it's own Assets class
* Added $helper property as a replacement for CiviCRM_Caldera_Forms_Helper static methods and properties
-* Moved Bulk insert/presets and Autopopulate options to their own classes
-* Fixed usability issue in #61 https://github.com/mecachisenros/caldera-forms-civicrm/issues/61
+* Moved Bulk insert/presets and Autopopulate options to their own classes
+* Fixed usability issue in #61 https://github.com/mecachisenros/cf-civicrm/issues/61
* Contact Reference custom field (with option to add new Organization)
* Membership processor (for paid and free Memberships)
* Order processor to process Contributions for Donations and Memberships (to process live transactions a payment add-on is needed see https://calderaforms.com/caldera-forms-add-ons/#/payment it currently integrates with the Stripe and Authorize.net add-ons)
@@ -62,7 +83,7 @@ This plugin is in active development. For feature requests and bug reports (or i
= 0.4.3 =
* Fix to prevent select2 conflicts if different vesions are present
-* Added Activity Target, Source, and Assignee fields as select2 widgets (entityRef-like field)
+* Added Activity Target, Source, and Assignee fields as select2 widgets (entityRef-like field)
* Show CiviCRM API errors in form
* Added Contribution processor (code contributed by Agileware) needs documentation
* Added Case Id magic tag (code contributed by Agileware)