Skip to content

Commit 28ddf3d

Browse files
author
Shaun Kutch
committed
mailchimp made optional
1 parent 50600c8 commit 28ddf3d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

application/controllers/config.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function mailchimpinfo()
1919

2020
function save()
2121
{
22-
2322
$batch_save_data=array(
2423
'company'=>$this->input->post('company'),
2524
'address'=>$this->input->post('address'),
@@ -36,6 +35,16 @@ function save()
3635
'timezone'=>$this->input->post('timezone'),
3736
'print_after_sale'=>$this->input->post('print_after_sale')
3837
);
38+
39+
if ($key = $this->input->post('mc_api_key')) {
40+
$this->load->library('MailChimp', array('api_key'=>$key), 'MailChimp');
41+
$success = ($this->MailChimp->ping() === "Everything's Chimpy!");
42+
$mc_message = $success ? 'Connected to MailChimp! '
43+
: "Unable to connect to MailChimp. Please check your connection and your API key. ";
44+
$validated_api_key = $success ? $this->input->post('mc_api_key') : '';
45+
46+
$batch_save_data['mc_api_key'] = $validated_api_key;
47+
}
3948

4049
if($_SERVER['HTTP_HOST'] !='demo.phppointofsale.com' && $this->Appconfig->batch_save($batch_save_data))
4150
{

0 commit comments

Comments
 (0)