Skip to content

Commit c9e668d

Browse files
Merge branch 'develop'
2 parents abd2a16 + 0166e06 commit c9e668d

File tree

57 files changed

+4592
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4592
-333
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Author : Ebizmarts <[email protected]>
4+
* Date : 4/24/13
5+
* Time : 1:15 PM
6+
* File : Add.php
7+
* Module : Ebizmarts_MailChimp
8+
*/
9+
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add extends Mage_Adminhtml_Block_Widget_Form_Container {
10+
protected $_mode = 'add';
11+
public function __construct() {
12+
$this->_controller = 'adminhtml_mergevars';
13+
$this->_blockGroup = 'mailchimp';
14+
15+
parent::__construct();
16+
$this->_removeButton("delete");
17+
$this->_removeButton("back");
18+
$this->_removeButton("reset");
19+
}
20+
// public function getMovtypes()
21+
// {
22+
// $types = Mage::getSingleton('mailchimp/system_config_source_movtype')->getMovtypes();
23+
// return $types;
24+
// }
25+
public function getHeaderText()
26+
{
27+
return Mage::helper('mailchimp')->__('New Field Type');
28+
}
29+
public function _prepareForm() {
30+
}
31+
32+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Author : Ebizmarts <[email protected]>
4+
* Date : 4/24/13
5+
* Time : 4:00 PM
6+
* File : Form.php
7+
* Module : Ebizmarts_MailChimp
8+
*/
9+
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add_Form extends Mage_Adminhtml_Block_Widget_Form
10+
{
11+
protected function _prepareForm() {
12+
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/saveadd'), 'method' => 'post'));
13+
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('mailchimp')->__('Mergevars Data')));
14+
15+
16+
$fieldset->addField('mergevar_label', 'text', array(
17+
'name' => 'mergevar[label]',
18+
'label' => Mage::helper('mailchimp')->__('MergeVar Name'),
19+
'id' => 'mergevar_label',
20+
'title' => Mage::helper('mailchimp')->__('MergeVar Name'),
21+
'required' => true
22+
));
23+
$fieldset->addField('mergevar_fieldtype','select',array(
24+
'name' => 'mergevar[fieldtype]',
25+
'label' => Mage::helper('mailchimp')->__('Field Type'),
26+
'id' => 'mergevar_fieldtype',
27+
'values' => Mage::getSingleton('mailchimp/system_config_source_fieldtype')->getFieldTypes(),
28+
'required' => true
29+
));
30+
31+
$fieldset->addField('mergevar_value', 'text', array(
32+
'name' => 'mergevar[value]',
33+
'label' => Mage::helper('mailchimp')->__('Value for case entry'),
34+
'id' => 'mergevar_value',
35+
'title' => Mage::helper('mailchimp')->__('Value for case entry'),
36+
'note' => 'This value should be added in the case of Data.php file',
37+
'required' => true
38+
));
39+
40+
41+
42+
$form->setUseContainer(true);
43+
$this->setForm($form);
44+
return parent::_prepareForm();
45+
}
46+
}

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/Grid/Renderer/Abandoned.php renamed to app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/Grid/Renderer/Mailchimp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
* @date: 7/7/16 1:31 PM
1111
* @file: Abandoned.php
1212
*/
13-
class Ebizmarts_MailChimp_Block_Adminhtml_Sales_Order_Grid_Renderer_Abandoned extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
13+
class Ebizmarts_MailChimp_Block_Adminhtml_Sales_Order_Grid_Renderer_Mailchimp extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
1414
{
1515
public function render(Varien_Object $row)
1616
{
1717
$order = Mage::getModel('sales/order')->load($row->getData('entity_id'));
18-
if ($order->getMailchimpAbandonedcartFlag()) {
19-
$result = '<img src="' . $this->getSkinUrl("mailchimp/images/logo-freddie-monocolor-200.png") . '" width="40" title="recovered cart by Mailchimp" />';
18+
if ($order->getMailchimpAbandonedcartFlag() || $order->getMailchimpCampaignId()) {
19+
$result = '<img src="' . $this->getSkinUrl("ebizmarts/mailchimp/images/logo-freddie-monocolor-200.png") . '" width="40" title="hep hep thanks MailChimp" />';
2020
} else {
2121
$result = '';
2222
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* mc-magento Magento Component
4+
*
5+
* @category Ebizmarts
6+
* @package mc-magento
7+
* @author Ebizmarts Team <[email protected]>
8+
* @copyright Ebizmarts (http://ebizmarts.com)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10+
* @date: 30/8/16 1:02 PM
11+
* @file: CreateMergeFields.php
12+
*/
13+
class Ebizmarts_MailChimp_Block_Adminhtml_System_Config_CreateMergeFields
14+
extends Mage_Adminhtml_Block_System_Config_Form_Field
15+
{
16+
protected function _construct()
17+
{
18+
parent::_construct();
19+
$this->setTemplate('ebizmarts/mailchimp/system/config/createmergefields.phtml');
20+
}
21+
22+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
23+
{
24+
return $this->_toHtml();
25+
}
26+
27+
public function getButtonHtml()
28+
{
29+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
30+
->setData(
31+
array(
32+
'id' => 'createmergefields_button',
33+
'label' => $this->helper('mailchimp')->__('Create Merge Fields'),
34+
'onclick' => 'javascript:createMergeFields(); return false;'
35+
)
36+
);
37+
38+
return $button->toHtml();
39+
}
40+
public function getAjaxCheckUrl()
41+
{
42+
return Mage::helper('adminhtml')->getUrl('adminhtml/ecommerce/createMergeFields');
43+
}
44+
45+
}

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/Fieldset/Hint.php renamed to app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/Fieldset/Mailchimp/Hint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @date: 4/29/16 3:55 PM
1010
* @file: Hint.php
1111
*/
12-
class Ebizmarts_MailChimp_Block_Adminhtml_System_Config_Fieldset_Hint
12+
class Ebizmarts_MailChimp_Block_Adminhtml_System_Config_Fieldset_Mailchimp_Hint
1313
extends Mage_Adminhtml_Block_Abstract
1414
implements Varien_Data_Form_Element_Renderer_Interface
1515
{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* MailChimp For Magento
4+
*
5+
* @category Ebizmarts_MailChimp
6+
* @author Ebizmarts Team <[email protected]>
7+
* @copyright Ebizmarts (http://ebizmarts.com)
8+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9+
* @date: 4/29/16 3:55 PM
10+
* @file: Hint.php
11+
*/
12+
class Ebizmarts_MailChimp_Block_Adminhtml_System_Config_Fieldset_Mandrill_Hint
13+
extends Mage_Adminhtml_Block_Abstract
14+
implements Varien_Data_Form_Element_Renderer_Interface
15+
{
16+
protected $_template = 'ebizmarts/mandrill/system/config/fieldset/hint.phtml';
17+
18+
/**
19+
* Render fieldset html
20+
*
21+
* @param Varien_Data_Form_Element_Abstract $element
22+
* @return string
23+
*/
24+
public function render(Varien_Data_Form_Element_Abstract $element)
25+
{
26+
return $this->toHtml();
27+
}
28+
29+
public function getMandrillVersion()
30+
{
31+
return (string)Mage::getConfig()->getNode('modules/Ebizmarts_Mandrill/version');
32+
}
33+
}
34+

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/Form/Field/Mapfields.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function __construct()
2929
)
3030
);
3131
$this->_addAfter = false;
32-
$this->_addButtonLabel = Mage::helper('mailchimp')->__('Add new field');
3332
parent::__construct();
3433
$this->setTemplate('ebizmarts/mailchimp/system/config/form/field/array_dropdown.phtml');
3534

@@ -44,6 +43,16 @@ public function __construct()
4443
$this->_customerAttributes[$option['attribute_id']] = $option['frontend_label'];
4544
}
4645
}
46+
$customFieldTypes = unserialize(
47+
Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_CUSTOM_MAP_FIELDS)
48+
);
49+
if(is_array($customFieldTypes)) {
50+
foreach ($customFieldTypes as $customFieldType) {
51+
$label = $customFieldType['label'];
52+
$value = $customFieldType['value'];
53+
$this->_customerAttributes[$value] = $label;
54+
}
55+
}
4756
ksort($this->_customerAttributes);
4857
}
4958

@@ -66,4 +75,12 @@ protected function _renderCellTemplate($columnName)
6675
}
6776
return $rendered;
6877
}
78+
79+
protected function _getMailChimpValue(){
80+
return Mage::getSingleton('core/session')->getMailchimpValue();
81+
}
82+
83+
protected function _getMailChimpLabel(){
84+
return Mage::getSingleton('core/session')->getMailchimpLabel();
85+
}
6986
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* Account details renderer for configuration settings
5+
*
6+
* @category Ebizmarts
7+
* @package Ebizmarts_Mandrill
8+
* @author Ebizmarts Team <[email protected]>
9+
* @license http://opensource.org/licenses/osl-3.0.php
10+
*/
11+
class Ebizmarts_MailChimp_Block_Adminhtml_System_Config_Userinfo
12+
extends Mage_Adminhtml_Block_System_Config_Form_Field
13+
{
14+
15+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
16+
{
17+
$values = $element->getValues();
18+
19+
$html = '<ul class="checkboxes">';
20+
21+
foreach ($values as $dat) {
22+
$html .= "<li>{$dat['label']}</li>";
23+
}
24+
25+
$html .= '</ul>';
26+
27+
return $html;
28+
}
29+
30+
}

app/code/community/Ebizmarts/MailChimp/Helper/Data.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,76 @@ public function deleteStore()
297297
Mage::getConfig()->deleteConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTOREID);
298298
}
299299
}
300+
301+
public function createMergeFields()
302+
{
303+
$listId = Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_LIST);
304+
$apiKey = Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_APIKEY);
305+
$maps = unserialize(Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_MAP_FIELDS));
306+
$customFieldTypes = unserialize(
307+
Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_CUSTOM_MAP_FIELDS)
308+
);
309+
310+
if ($apiKey != null && $apiKey != "") {
311+
$api = new Ebizmarts_Mailchimp($apiKey, null, 'Mailchimp4Magento' . (string)Mage::getConfig()->getNode('modules/Ebizmarts_MailChimp/version'));
312+
try {
313+
$mailchimpFields = $api->lists->mergeFields->getAll($listId, null, null, 50);
314+
} catch (Mailchimp_Error $e) {
315+
Mage::helper('mailchimp')->logErrors($e->getFriendlyMessage());
316+
}
317+
if(count($mailchimpFields) > 0) {
318+
foreach ($maps as $map) {
319+
$customAtt = $map['magento'];
320+
$chimpTag = $map['mailchimp'];
321+
$alreadyExists = false;
322+
$created = false;
323+
foreach ($mailchimpFields['merge_fields'] as $mailchimpField) {
324+
if ($mailchimpField['tag'] == $chimpTag || strtoupper($chimpTag) == 'EMAIL') {
325+
$alreadyExists = true;
326+
}
327+
}
328+
if (!$alreadyExists) {
329+
foreach ($customFieldTypes as $customFieldType) {
330+
if($customFieldType['value'] == $chimpTag) {
331+
try {
332+
$api->lists->mergeFields->add($listId, $customFieldType['label'], $customFieldType['field_type'], null, $chimpTag);
333+
} catch (Mailchimp_Error $e) {
334+
Mage::helper('mailchimp')->logErrors($e->getFriendlyMessage());
335+
}
336+
$created = true;
337+
}
338+
}
339+
if (!$created) {
340+
$attrSetId = Mage::getResourceModel('eav/entity_attribute_collection')
341+
->setEntityTypeFilter(1)
342+
->addSetInfo()
343+
->getData();
344+
$label = null;
345+
foreach ($attrSetId as $option) {
346+
if ($option['attribute_id'] == $customAtt && $option['frontend_label']) {
347+
$label = $option['frontend_label'];
348+
}
349+
}
350+
try {
351+
if($label) {
352+
//Shipping and Billing Address
353+
if ($customAtt == 13 || $customAtt == 14) {
354+
$api->lists->mergeFields->add($listId, $label, 'address', null, $chimpTag);
355+
//Birthday
356+
} elseif ($customAtt == 11) {
357+
$api->lists->mergeFields->add($listId, $label, 'date', null, $chimpTag);
358+
} else {
359+
$response = $api->lists->mergeFields->add($listId, $label, 'text', null, $chimpTag);
360+
}
361+
}
362+
} catch (Mailchimp_Error $e) {
363+
Mage::helper('mailchimp')->logErrors($e->getFriendlyMessage());
364+
}
365+
}
366+
}
367+
}
368+
}
369+
}
370+
371+
}
300372
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* mc-magento Magento Component
4+
*
5+
* @category Ebizmarts
6+
* @package mc-magento
7+
* @author Ebizmarts Team <[email protected]>
8+
* @copyright Ebizmarts (http://ebizmarts.com)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10+
* @date: 8/30/16 3:31 PM
11+
* @file: Mandrill.php
12+
*/
13+
class Ebizmarts_MailChimp_Helper_Mandrill extends Mage_Core_Helper_Abstract
14+
{
15+
/**
16+
* @param $message
17+
*/
18+
public function log($message)
19+
{
20+
if (Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::MANDRILL_LOG)) {
21+
Mage::log($message, null, 'Mandrill_Request.log', true);
22+
}
23+
}
24+
/**
25+
* Get module User-Agent to use on API requests
26+
*
27+
* @return string
28+
*/
29+
public function getUserAgent()
30+
{
31+
$modules = Mage::getConfig()->getNode('modules')->children();
32+
$modulesArray = (array)$modules;
33+
34+
$aux = (array_key_exists('Enterprise_Enterprise', $modulesArray)) ? 'EE' : 'CE';
35+
$v = (string)Mage::getConfig()->getNode('modules/Ebizmarts_Mandrill/version');
36+
$version = strpos(Mage::getVersion(), '-') ? substr(Mage::getVersion(), 0, strpos(Mage::getVersion(), '-')) : Mage::getVersion();
37+
return (string)'Ebizmarts_Mandrill' . $v . '/Mage' . $aux . $version;
38+
}
39+
}

0 commit comments

Comments
 (0)