Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar committed Oct 13, 2023
2 parents ac93e8f + b518e84 commit 9e6190f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
4 changes: 2 additions & 2 deletions formscrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: FormsCRM
* Plugin URI: https://closemarketing.net/formscrm
* Description: Connects Forms with CRM, ERP and Email Marketing.
* Version: 3.12.2
* Version: 3.12.3
* Author: Closemarketing
* Author URI: https://close.marketing
* Text Domain: formscrm
Expand All @@ -23,7 +23,7 @@

defined( 'ABSPATH' ) || die( 'No script kiddies please!' );

define( 'FORMSCRM_VERSION', '3.12.2' );
define( 'FORMSCRM_VERSION', '3.12.3' );
define( 'FORMSCRM_PLUGIN', __FILE__ );
define( 'FORMSCRM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'FORMSCRM_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
Expand Down
47 changes: 18 additions & 29 deletions includes/formscrm-library/class-contactform7.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function settings_add_crm( $args ) {
</label>
</td>
<td class="cf7-map-column cf7-map-column-value">
<input type="text" id="wpcf7-crm-field-<?php echo esc_html( $crm_field['name'] ); ?>" name="wpcf7-crm[fc_crm_field-<?php echo esc_html( $crm_field['name'] ); ?>]" class="wide" size="70" placeholder="<?php esc_html_e( 'Name of your field', 'formscrm' ); ?>" value="<?php echo ( isset( $cf7_crm[ 'fc_crm_field-' . $crm_field['name'] ] ) ) ? esc_attr( $cf7_crm[ 'fc_crm_field-' . $crm_field['name'] ] ) : ''; ?>" <?php if ( isset( $crm_field['required'] ) && $crm_field['required'] ) { echo ' required'; } ?>/>
<input type="text" id="wpcf7-crm-field-<?php echo esc_html( $crm_field['name'] ); ?>" name="wpcf7-crm[fc_crm_field-<?php echo esc_html( $crm_field['name'] ); ?>]" class="wide" size="70" placeholder="<?php esc_html_e( 'Name of your field or Default value sent to the CRM', 'formscrm' ); ?>" value="<?php echo ( isset( $cf7_crm[ 'fc_crm_field-' . $crm_field['name'] ] ) ) ? esc_attr( $cf7_crm[ 'fc_crm_field-' . $crm_field['name'] ] ) : ''; ?>" <?php if ( isset( $crm_field['required'] ) && $crm_field['required'] ) { echo ' required'; } ?>/>
</td>
</tr>
<?php
Expand Down Expand Up @@ -244,37 +244,21 @@ public function crm_save_options( $args ) {
public function crm_process_entry( $contact_form ) {
$cf7_crm = get_option( 'cf7_crm_' . $contact_form->id() );
$submission = WPCF7_Submission::get_instance();
$crm_type = ! empty( $cf7_crm['fc_crm_type'] ) ? sanitize_title( $cf7_crm['fc_crm_type'] ) : '';

if ( $cf7_crm == 'res.part' ) {
//create contact in Odoo
$this->include_library( $cf7_crm['fc_crm_type'] );
$merge_vars = $this->get_merge_vars( $cf7_crm, $submission->get_posted_data() );
$response_result = $this->crmlib->create_entry( $cf7_crm, $merge_vars );
// Create contact in CRM.
$this->include_library( $cf7_crm['fc_crm_type'] );
$merge_vars = $this->get_merge_vars( $cf7_crm, $submission->get_posted_data() );
$response_result = $this->crmlib->create_entry( $cf7_crm, $merge_vars );

if ( 'error' === $response_result['status'] ) {
$url = isset( $response_result['url'] ) ? $response_result['url'] : '';
$query = isset( $response_result['query'] ) ? $response_result['query'] : '';

formscrm_debug_email_lead( $cf7_crm['fc_crm_type'], 'Error ' . $response_result['message'], $merge_vars, $url, $query );
}

}else{
//create contact in Odoo
$this->include_library( $cf7_crm['fc_crm_type'] );
$merge_vars = $this->get_merge_vars( $cf7_crm, $submission->get_posted_data() );

$response_result = $this->crmlib->create_entry( $cf7_crm, $merge_vars );

if ( 'error' === $response_result['status'] ) {
$url = isset( $response_result['url'] ) ? $response_result['url'] : '';
$query = isset( $response_result['query'] ) ? $response_result['query'] : '';
if ( 'error' === $response_result['status'] ) {
$url = isset( $response_result['url'] ) ? $response_result['url'] : '';
$query = isset( $response_result['query'] ) ? $response_result['query'] : '';

formscrm_debug_email_lead( $cf7_crm['fc_crm_type'], 'Error ' . $response_result['message'], $merge_vars, $url, $query );
}
formscrm_debug_email_lead( $cf7_crm['fc_crm_type'], 'Error ' . $response_result['message'], $merge_vars, $url, $query );
}

$this->include_library( $cf7_crm['fc_crm_type'] );
//create lead in Oddo with using the previously created contact
$merge_vars = $this->get_merge_vars( $cf7_crm, $submission->get_posted_data() );
if ( 'odoo' === $crm_type && $cf7_crm !== 'res.part' ) {
$response_result = $this->crmlib->create_lead( $cf7_crm, $response_result,$merge_vars );

if ( 'error' === $response_result['status'] ) {
Expand All @@ -298,9 +282,14 @@ private function get_merge_vars( $cf7_crm, $submitted_data ) {
foreach ( $cf7_crm as $key => $value ) {
if ( false !== strpos( $key, 'fc_crm_field' ) ) {
$crm_key = str_replace( 'fc_crm_field-', '', $key );

if ( ! empty( $submitted_data[ $value ] ) ) {
$value = $submitted_data[ $value ];
}

$merge_vars[] = array(
'name' => $crm_key,
'value' => isset( $submitted_data[ $value ] ) ? $submitted_data[ $value ] : '',
'value' => $value,
);
}
}
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Tags: gravityforms, gravity, form, forms, gravity forms, crm, vtiger, sugarcrm
Donate link: https://close.marketing/go/donate/
Requires at least: 5.0
Tested up to: 6.3.0
Stable tag: 3.12.2
Version: 3.12.2
Stable tag: 3.12.3
Version: 3.12.3
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -62,6 +62,10 @@ WordPress installation and then activate the Plugin from Plugins page.
[Official Repository GitHub](https://github.com/closemarketing/formscrm/)

== Changelog ==
= 3.12.3 =
* Added: CF7 now allows values by default.
* Fix: CF7 error after sending a lead.

= 3.12.2 =
* Fix: Holded tags where not importing correctly.
* Fix: Holded Address fields where not importing correctly.
Expand Down

0 comments on commit 9e6190f

Please sign in to comment.