-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed comments and added live debug support
- Loading branch information
Showing
2 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# fluentcrm-handler | ||
Integrates FluentCRM with Awesome. | ||
<p align="center"> | ||
<a href="https://www.wpoets.com/" target="_blank"><img width="200"src="https://www.wpoets.com/wp-content/uploads/2018/05/WPoets-logo-1.svg"></a> | ||
</p> | ||
|
||
# FluentCRM handler | ||
|
||
Integrates FluentCRM with Awesome Enterprise. Introduces fluentcrm.contact.* shortcodes. | ||
|
||
It can be installed using following composer command | ||
|
||
`composer require wpoets/fluentcrm-handler` | ||
|
||
### Changelog | ||
|
||
##### 1.0.0 | ||
* Initial release with ability to add/update contacts. | ||
|
||
Here the shortcode that you use once this handler is enabled. | ||
`[fluentcrm.contact.add] | ||
{ | ||
"first_name" : "Jhon", | ||
"last_name" : "Doe", | ||
"email" : "amit@wpoets.com", | ||
"status" : "pending", | ||
"tags" : [ 1,4 ], | ||
"lists" : [1] , | ||
"custom_values" :{ | ||
"custom_field_slug_1" : "custom_field_value_1", | ||
"custom_field_slug_2" : "custom_field_value_2" | ||
} | ||
} | ||
[/fluentcrm.contact.add]` | ||
|
||
|
||
## We're Hiring! | ||
|
||
<p align="center"> | ||
<a href="https://www.wpoets.com/careers/"><img src="https://www.wpoets.com/wp-content/uploads/2020/11/work-with-us_1776x312.png" alt="Join us at WPoets, We specialize in designing, building and maintaining complex enterprise websites and portals in WordPress."></a> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,65 @@ | ||
<?php | ||
namespace aw2\fluentcrm; | ||
/** | ||
* [fluentcrm.contact.add /] | ||
* [fluentcrn.contact.update /] | ||
* [.attach] | ||
* [.detach] | ||
*/ | ||
|
||
\aw2_library::add_service('fluentcrm','FLuentCRM Library.',['namespace'=>__NAMESPACE__]); | ||
|
||
\aw2_library::add_service('fluentcrm.contact.add','Run WooCommerce actions',['func'=>'contact_add','namespace'=>__NAMESPACE__]); | ||
|
||
function contact_add($atts, $content = null, $shortcode=null){ | ||
\util::var_dump($content); | ||
if(\aw2_library::is_live_debug()){ | ||
|
||
$live_debug_event=array(); | ||
$live_debug_event['flow']='fluentcrm'; | ||
$live_debug_event['action']='fluentcrm.contact.add'; | ||
$live_debug_event['stream']='fluentcrm.contact'; | ||
|
||
} | ||
|
||
if(is_fluentcrm_active()===false){ | ||
if(\aw2_library::is_live_debug()){ | ||
|
||
$temp_debug=$live_debug_event; | ||
$temp_debug['error']='yes'; | ||
$temp_debug['error_message']='FluentCRM plugin is not active'; | ||
$temp_debug['error_type']='plugin_error'; | ||
\aw2\live_debug\publish_event(['event'=>$temp_debug,'bgcolor'=>'#FFC3C3']); | ||
} | ||
throw new Exception('FluentCRM is not active.'); | ||
} | ||
|
||
|
||
$data = json_decode($content,true); | ||
\util::var_dump($data); | ||
if(empty($data)){ | ||
if(\aw2_library::is_live_debug()){ | ||
|
||
$temp_debug=$live_debug_event; | ||
$temp_debug['error']='yes'; | ||
$temp_debug['error_message']='JSON decode failed.'; | ||
$temp_debug['content']=$content; | ||
$temp_debug['error_type']='json_fail'; | ||
\aw2\live_debug\publish_event(['event'=>$temp_debug,'bgcolor'=>'#FFC3C3']); | ||
} | ||
throw new Exception('Issue with JSON data.'); | ||
} | ||
|
||
$contactApi = FluentCrmApi('contacts'); | ||
$contact = $contactApi->createOrUpdate($data); | ||
|
||
// send a double opt-in email if the status is pending | ||
if($contact && $contact->status == 'pending') { | ||
$contact->sendDoubleOptinEmail(); | ||
} | ||
|
||
if(\aw2_library::is_live_debug()){ | ||
|
||
$temp_debug=$live_debug_event; | ||
$temp_debug['content']=$content; | ||
$temp_debug['message']='Contact added to FluentCRM'; | ||
\aw2\live_debug\publish_event(['event'=>$temp_debug,'bgcolor'=>'#FFC3C3']); | ||
} | ||
} | ||
|
||
function is_fluentcrm_active(){ | ||
$status= function_exists('FluentCrmApi')?true:false; | ||
return $status; | ||
} |