MP_Addon_OfflineConversions_Callback::get_clickid( array $leads, array $post )
Click ID.
Contents
Parameters Parameters
- $leads
-
(array) (Required) leads
- $post
-
(array) (Required) post data
Source Source
File: calculator-offline-conversions-add-on/inc/MP_Addon_OfflineConversions_Callback.php
public function get_clickid( $leads, $post ) {
if ( empty( $post ) ) {
return wp_send_json( __( 'Not found...', 'CalculatorsOfflineConversionsAddon' ) );
}
$clickid = isset( $post['clickid'] ) ? mb_strtolower( $post['clickid'] ) : null;
$clickname = MP_Settings::is_isset( $post['clickname'], __( 'Lead', 'CalculatorsOfflineConversionsAddon' ) );
$click_leads = array();
foreach ( $leads as $lead ) {
if ( ! empty( get_post_meta( $lead, MortgagePlatform::$prefix . 'value', true ) ) &&
! empty( get_post_meta( $lead, MortgagePlatform::$prefix . 'utm', true ) ) &&
isset( get_post_meta( $lead, MortgagePlatform::$prefix . 'utm', true )[ $clickid ] )
) {
array_push( $click_leads, $lead );
}
}
if ( empty( $click_leads ) ) {
return wp_send_json( __( 'Not found...', 'CalculatorsOfflineConversionsAddon' ) );
}
$click = array();
foreach ( $click_leads as $postid ) {
$click[ $postid ] = array(
'email' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead_email', true ),
'phone' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead_phone', true ),
'first_name' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead_first_name', true ),
'second_name' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead_second_name', true ),
'zipcode' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead_zipcode', true ),
'city' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead', true )['client_city'],
'country' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead', true )['client_country'],
'year' => get_post_meta( $postid, MortgagePlatform::$prefix . 'lead_yearofbirth', true ),
'clickid' => get_post_meta( $postid, MortgagePlatform::$prefix . 'utm', true )[ $clickid ],
'name' => $clickname,
'time' => get_the_time( 'Y-m-d H:i:s', $postid ),
'value' => get_post_meta( $postid, MortgagePlatform::$prefix . 'value', true ),
'currency' => 'USD',
);
}
if ( empty( $click ) ) {
return wp_send_json( __( 'Not found...', 'CalculatorsOfflineConversionsAddon' ) );
}
$this->download_offline_conversion_report_in_csv( $click, $clickid );
exit;
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |