} $account_body = array( 'sales_account' => $account_fields ); // check if account exists if( isset( $account_fields['name'] ) && $account_fields['name'] ){ $account_id = adfoin_freshsales_if_account_exists( $account_fields['name'], $cred_id ); } if( $account_id ) { $account_response = adfoin_freshsales_request( 'sales_accounts/' . $account_id, 'PUT', $account_body, $record, $cred_id ); } else{ $account_response = adfoin_freshsales_request( 'sales_accounts', 'POST', $account_body, $record, $cred_id ); } $account_return = json_decode( wp_remote_retrieve_body( $account_response ) ); if( 200 === (int) wp_remote_retrieve_response_code( $account_response ) && isset( $account_return->sales_account->id ) ) { $account_id = $account_return->sales_account->id; } } if( !empty( $contact_fields ) ) { if( $account_id ) { $contact_fields['sales_accounts'] = array( array( 'id' => $account_id, 'is_primary' => true ) ); } if( !empty( $contact_fields['lists'] ) ) { $contact_lists = explode( ',', $contact_fields['lists'] ); unset( $contact_fields['lists'] ); } $contact_types = adfoin_freshsales_field_types( 'contacts', $cred_id ); $contact_fields = adfoin_freshsales_coerce_fields( $contact_fields, $contact_types ); if( !empty( $contact_custom_fields ) ) { $contact_fields['custom_field'] = adfoin_freshsales_coerce_fields( $contact_custom_fields, $contact_types ); } $contact_body = array( 'contact' => $contact_fields ); if( isset( $contact_fields['email'] ) && $contact_fields['email'] ){ $contact_id = adfoin_freshsales_if_contact_exists( $contact_fields['email'], $cred_id ); // Merge tags only for an EXISTING contact (so we append instead // of overwrite). For a new contact the comma string is sent as-is. // Guard every step — a missing/failed lookup must not fatal. if( $contact_id && isset( $contact_body['contact']['tags'] ) && $contact_body['contact']['tags'] ){ $tags = explode( ',', $contact_body['contact']['tags'] ); $existing_response = adfoin_freshsales_request( 'contacts/' . $contact_id, 'GET', array(), array(), $cred_id ); if( ! is_wp_error( $existing_response ) ) { $existing_body = json_decode( wp_remote_retrieve_body( $existing_response ), true ); $existing_tags = ( isset( $existing_body['contact']['tags'] ) && is_array( $existing_body['contact']['tags'] ) ) ? $existing_body['contact']['tags'] : array(); $tags = array_unique( array_merge( $tags, $existing_tags ) ); } $contact_body['contact']['tags'] = implode( ',', $tags ); } } if( $contact_id ) { $contact_response = adfoin_freshsales_request( 'contacts/' . $contact_id, 'PUT', $contact_body, $record, $cred_id ); } else{ $contact_response = adfoin_freshsales_request( 'contacts', 'POST', $contact_body, $record, $cred_id ); } $contact_body = json_decode( wp_remote_retrieve_body( $contact_response ) ); if( 200 === (int) wp_remote_retrieve_response_code( $contact_response ) && isset( $contact_body->contact->id ) ) { $contact_id = $contact_body->contact->id; } if( !empty( $contact_lists ) && $contact_id ) { foreach( $contact_lists as $list ) { $list_body = array( 'ids' => array( $contact_id ) ); $list_response = adfoin_freshsales_request( 'lists/' . trim( $list ) . '/add_contacts', 'PUT', $list_body, $record, $cred_id ); } } } if( !empty( $deal_fields ) ) { $deal_types = adfoin_freshsales_field_types( 'deals', $cred_id ); $deal_fields = adfoin_freshsales_coerce_fields( $deal_fields, $deal_types ); if ( $account_id ) { $deal_fields['sales_account_id'] = $account_id; } if( $contact_id ) { $deal_fields['contacts_added_list'] = array( $contact_id ); } if( !empty( $deal_custom_fields ) ) { $deal_fields['custom_field'] = adfoin_freshsales_coerce_fields( $deal_custom_fields, $deal_types ); } $body = array( 'deal' => $deal_fields ); $response = adfoin_freshsales_request( 'deals', 'POST', $body, $record, $cred_id ); $body = json_decode( wp_remote_retrieve_body( $response ) ); if( 200 === (int) wp_remote_retrieve_response_code( $response ) && isset( $body->deal->id ) ) { $deal_id = $body->deal->id; } } } return; } Scan Energy https://validator.w3.org/feed/docs/rss2.html Wechselservice aktivieren test Startseite Cookie-Richtlinie (EU) Balkonkraftwerk-Überschuss sinnvoll nutzen Solarlösungen für Zuhause Balkonkraftwerk Speicher nachrüsten Balkonkraftwerk Komplettset vergleichen Photovoltaikanlage fürs Haus prüfen Stromvergleich Gasvergleich Seriöse Stromanbieter Seriöse Gasanbieter Weiterempfehlen Neukundenbonus Gas Neukundenbonus Strom Strom Grundversorgung Gas Grundversorgung Gasanbieter wechseln Stromanbieter wechseln Tests & Auszeichnungen Weiterempfehlen Registrierung Über Uns Wechselservice Kann ich mich an Scan Energy wenden, wenn mir etwas unklar ist? Habe ich die Möglichkeit, vom Vertrag zurückzutreten, falls ich es mir nochmal anders überlege? Wie schnell kann ich meinen Stromvertrag kündigen? Habe ich auch die Möglichkeit, zurück zum Grundversorger zu wechseln? Ich ziehe bald in eine neue Wohnung! Kann ich Scan Energy auch dafür in Anspruch nehmen? Gibt es im Zusammenhang mit einem Umzug noch andere Punkte zu beachten? Es gibt viele Vergleichsportale. Was macht Scan Energy besonders? Wie kommt es eigentlich, dass der Strom jedes Jahr teurer wird? Welche Energie-Anbieter empfiehlt Scan Energy? Kann Scan Energy deutschlandweit den besten Anbieter finden? Sind die Tarif-Empfehlungen von Scan Energy wirklich kostenlos? Führt Scan Energy den gesamten Wechsel für mich durch? An welchem Punkt verdient Scan Energy Geld? Wie viel kann ich jährlich sparen? Könnten finanzielle Nachteile für mich entstehen, wenn ich meinen Anbieter über Scan Energy wechsle? Muss ich selbst bei meinem alten Anbieter kündigen? Bekomme ich auch den Wechselbonus vom neuen Anbieter, wenn ich über Scan Energy wechsle? Warum sollte ich ausgerechnet Scan Energy beauftragen? Angenommen, ich wechsle nach 12 Monaten wieder den Anbieter: Erhalte ich den Bonus dennoch? Wie lange bin ich nach dem Wechsel an den Anbieter gebunden? Kann es passieren, dass ich ohne Strom dastehe? Werden meine Tarif-Informationen für zukünftige Wechsel gespeichert? Angenommen, ich habe mit Scan Energy gewechselt. Wie geht es danach weiter? Erhalte ich auch Unterlagen zum Wechsel? Kann ich einen Vertrag für Strom/Gas auch im Voraus abschließen? Sind die Tarif-Empfehlungen unverbindlich?