From f23c680ebb9981ebea6294fd52b38d06f885121f Mon Sep 17 00:00:00 2001 From: Javier Giorello Date: Tue, 25 Jun 2019 10:01:05 -0300 Subject: [PATCH 001/168] PHPCBF runned and no Frontend Template fixed --- .../Adminhtml/Customer/Edit/Tab/Mailchimp.php | 1 + .../Block/Adminhtml/Mailchimpstores/Edit.php | 9 +- .../Adminhtml/Mailchimpstores/Edit/Form.php | 129 ++++++++++------ .../Sales/Order/View/Info/Monkey.php | 1 + .../System/Config/CreateMergeFields.php | 1 + .../MailChimp/Block/Checkout/Subscribe.php | 3 + .../Block/Customer/Newsletter/Index.php | 1 + .../Ebizmarts/MailChimp/Block/Group/Type.php | 1 + .../Ebizmarts/MailChimp/Helper/Data.php | 89 +++++++++++ .../Ebizmarts/MailChimp/Model/Api/Batches.php | 9 ++ .../Ebizmarts/MailChimp/Model/Api/Carts.php | 5 + .../MailChimp/Model/Api/Customers.php | 2 + .../Ebizmarts/MailChimp/Model/Api/Orders.php | 4 + .../MailChimp/Model/Api/Products.php | 25 +++ .../MailChimp/Model/Api/PromoCodes.php | 2 + .../MailChimp/Model/Api/PromoRules.php | 4 + .../Ebizmarts/MailChimp/Model/Api/Stores.php | 2 + .../MailChimp/Model/Api/Subscribers.php | 8 + .../MailChimp/Model/Email/Template.php | 2 + .../Ebizmarts/MailChimp/Model/Observer.php | 17 ++- .../MailChimp/Model/ProcessWebhook.php | 6 + .../Model/System/Config/Backend/Store.php | 1 + .../Model/System/Config/Source/Account.php | 5 + .../System/Config/Source/CustomerGroup.php | 1 + .../Model/System/Config/Source/List.php | 2 + .../Model/System/Config/Source/Store.php | 2 + .../Adminhtml/EcommerceController.php | 2 + .../Adminhtml/MailchimpController.php | 1 + .../Adminhtml/MailchimperrorsController.php | 2 + .../Adminhtml/MailchimpstoresController.php | 1 + .../MailChimp/controllers/GroupController.php | 2 + .../controllers/WebhookController.php | 2 + .../mysql4-upgrade-1.1.12-1.1.12.2.php | 7 +- .../mailchimp/customer/tab/mailchimp.phtml | 11 +- .../config/form/field/array_dropdown.phtml | 1 + .../mailchimp/checkout/subscribe.phtml | 27 ++-- .../mailchimp/checkout/success/groups.phtml | 20 ++- .../mailchimp/customer/newsletter/index.phtml | 10 +- .../mailchimp/group/type/checkboxes.phtml | 23 ++- .../mailchimp/group/type/dropdown.phtml | 13 +- .../mailchimp/group/type/radio.phtml | 18 ++- .../mailchimp/popup/emailcatcher.phtml | 144 +++++++++++++----- .../Sales/Order/View/Info/MonkeyTest.php | 1 + .../Ebizmarts/MailChimp/Helper/DataTest.php | 54 ++++--- .../MailChimp/Model/Api/BatchesTest.php | 18 ++- .../MailChimp/Model/Api/CartsTest.php | 24 ++- .../MailChimp/Model/Api/OrdersTest.php | 30 ++-- .../MailChimp/Model/Api/ProductsTest.php | 18 ++- .../MailChimp/Model/Api/PromoRulesTest.php | 6 +- .../MailChimp/Model/Email/TemplateTest.php | 6 +- .../MailChimp/Model/ObserverTest.php | 18 ++- .../MailChimp/Model/ProcessWebhookTest.php | 46 +++--- .../MailchimperrorsControllerTest.php | 6 +- .../MailchimpstoresControllerTest.php | 6 +- .../controllers/GroupControllerTest.php | 18 ++- 55 files changed, 652 insertions(+), 215 deletions(-) diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Customer/Edit/Tab/Mailchimp.php b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Customer/Edit/Tab/Mailchimp.php index e15943121..25a8547ff 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Customer/Edit/Tab/Mailchimp.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Customer/Edit/Tab/Mailchimp.php @@ -94,6 +94,7 @@ protected function getStoreId() if (!$storeId) { $storeId = $this->_customer->getMailchimpStoreView(); } + return $storeId; } } diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit.php b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit.php index 71cfa028b..4077b2fcf 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit.php @@ -20,7 +20,8 @@ public function __construct() parent::__construct(); $this->removeButton('reset'); - $this->updateButton('delete', null, array( + $this->updateButton( + 'delete', null, array( 'label' => Mage::helper('adminhtml')->__('Delete Store'), 'class' => 'delete', 'onclick' => 'deleteMCStoreConfirm(\'' @@ -31,7 +32,8 @@ public function __construct() . $this->getDeleteUrl() . '\')', 'sort_order' => 0 - )); + ) + ); $scopeArray = $this->getScopeArrayIfValueExists(); if ($scopeArray !== false) { @@ -39,6 +41,7 @@ public function __construct() } else { $jsCondition = 'false'; } + $mcInUseMessage = $this->getMCInUseMessage($scopeArray); $this->_formScripts[] = "function deleteMCStoreConfirm(message, url) { if ($jsCondition) { @@ -87,6 +90,7 @@ protected function getMCInUseMessage($scope) } else { $message = $helper->__("This store is currently in use for this Magento store. Do you want to proceed anyways?"); } + return $message; } @@ -101,6 +105,7 @@ protected function getScopeArrayIfValueExists() if ($keyIfExist === null) { $keyIfExist = 'false'; } + return $keyIfExist; } diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit/Form.php b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit/Form.php index bb1a0df2a..13d17e39d 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit/Form.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimpstores/Edit/Form.php @@ -17,27 +17,36 @@ protected function _prepareForm() { $helper = $this->makeHelper(); - $form = new Varien_Data_Form(array( + $form = new Varien_Data_Form( + array( 'id' => 'edit_form', 'action' => $this->getUrl('*/*/save'), 'method' => 'post', - )); + ) + ); $store = Mage::registry('current_mailchimpstore'); if ($store->getStoreid()) { - $form->addField('storeid', 'hidden', array( + $form->addField( + 'storeid', 'hidden', array( 'name' => 'storeid', - )); - $form->addField('apikey', 'hidden', array( + ) + ); + $form->addField( + 'apikey', 'hidden', array( 'name' => 'apikey' - )); + ) + ); $form->setValues($store->getData()); } - $fieldset = $form->addFieldset('base_fieldset', array( + + $fieldset = $form->addFieldset( + 'base_fieldset', array( 'legend' => $helper->__('Store Information'), 'class' => 'fieldset', - )); + ) + ); if (!$store->getId()) { $stores = Mage::app()->getStores(); $apikeys = array(); @@ -48,122 +57,156 @@ protected function _prepareForm() $apikeys[$encryptedApiKey] = $helper->mask($apikey); } } - $apikeyField = $fieldset->addField('apikey', 'select', array( + + $apikeyField = $fieldset->addField( + 'apikey', 'select', array( 'label' => $helper->__('Api Key'), 'title' => $helper->__('Api Key'), 'name' => 'apikey', 'required' => true, 'options' => $apikeys, - )); + ) + ); $getStoresUrl = Mage::helper('adminhtml')->getUrl('adminhtml/mailchimpstores/getstores'); $apikeyField->setAfterElementHtml(""); - $fieldset->addField('listid', 'select', array( + $fieldset->addField( + 'listid', 'select', array( 'name' => 'listid', 'label' => $helper->__('List'), 'title' => $helper->__('List'), 'required' => true, 'options' => array() - )); + ) + ); } - $fieldset->addField('name', 'text', array( + + $fieldset->addField( + 'name', 'text', array( 'name' => 'name', 'label' => $helper->__('Store Name'), 'title' => $helper->__('Store Name'), 'required' => true, - )); - $fieldset->addField('domain', 'text', array( - 'name' => 'domain', - 'label' => $helper->__('Domain'), - 'title' => $helper->__('Domain'), + ) + ); + $fieldset->addField( + 'domain', 'text', array( + 'name' => 'domain', + 'label' => $helper->__('Domain'), + 'title' => $helper->__('Domain'), + 'required' => true + ) + ); + $fieldset->addField( + 'email_address', 'text', array( + 'name' => 'email_address', + 'label' => $helper->__('Email'), + 'title' => $helper->__('Email'), 'required' => true - )); - $fieldset->addField('email_address', 'text', array( - 'name' => 'email_address', - 'label' => $helper->__('Email'), - 'title' => $helper->__('Email'), - 'required' => true - )); + ) + ); $currencies = Mage::getModel('adminhtml/system_config_source_currency')->toOptionArray(false); $currencyArray = array(); foreach ($currencies as $c) { $currencyArray[$c['value']] = $c['label']; } - $fieldset->addField('currency_code', 'select', array( + + $fieldset->addField( + 'currency_code', 'select', array( 'label' => $helper->__('Currency'), 'title' => $helper->__('Currency'), 'name' => 'currency_code', 'required' => true, 'options' => $currencyArray, - )); + ) + ); $locales = Mage::getModel('adminhtml/system_config_source_locale')->toOptionArray(); $localeArray = array(); foreach ($locales as $c) { $localeArray[$c['value']] = $c['label']; } - $fieldset->addField('primary_locale', 'select', array( + + $fieldset->addField( + 'primary_locale', 'select', array( 'label' => $helper->__('Locale'), 'title' => $helper->__('Locale'), 'name' => 'primary_locale', 'required' => true, 'options' => $localeArray, - )); + ) + ); $timeszones = Mage::getModel('adminhtml/system_config_source_locale_timezone')->toOptionArray(); $timezoneArray = array(); foreach ($timeszones as $c) { $timezoneArray[$c['value']] = $c['label']; } - $fieldset->addField('timezone', 'select', array( + + $fieldset->addField( + 'timezone', 'select', array( 'label' => $helper->__('Time Zone'), 'title' => $helper->__('Time Zone'), 'name' => 'timezone', 'required' => true, 'options' => $timezoneArray, - )); + ) + ); - $fieldset->addField('phone', 'text', array( + $fieldset->addField( + 'phone', 'text', array( 'name' => 'phone', 'label' => $helper->__('Phone'), 'title' => $helper->__('Phone'), 'required' => true - )); - $fieldset->addField('address_address_one', 'text', array( + ) + ); + $fieldset->addField( + 'address_address_one', 'text', array( 'name' => 'address_address_one', 'label' => $helper->__('Street'), 'title' => $helper->__('Street'), 'required' => true - )); + ) + ); - $fieldset->addField('address_address_two', 'text', array( + $fieldset->addField( + 'address_address_two', 'text', array( 'name' => 'address_address_two', 'label' => $helper->__('Street'), 'title' => $helper->__('Street'), 'required' => false - )); - $fieldset->addField('address_city', 'text', array( + ) + ); + $fieldset->addField( + 'address_city', 'text', array( 'name' => 'address_city', 'label' => $helper->__('City'), 'title' => $helper->__('City'), 'required' => true - )); - $fieldset->addField('address_postal_code', 'text', array( + ) + ); + $fieldset->addField( + 'address_postal_code', 'text', array( 'name' => 'address_postal_code', 'label' => $helper->__('Postal Code'), 'title' => $helper->__('Postal Code'), 'required' => true - )); + ) + ); $countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(); $countryArray = array(); foreach ($countries as $c) { $countryArray[$c['value']] = $c['label']; } - $fieldset->addField('address_country_code', 'select', array( + + $fieldset->addField( + 'address_country_code', 'select', array( 'label' => $helper->__('Country'), 'title' => $helper->__('Country'), 'name' => 'address_country_code', 'required' => true, 'options' => $countryArray, - )); + ) + ); $form->setValues($store->getData()); diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/View/Info/Monkey.php b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/View/Info/Monkey.php index 9cfff0bd9..ae39151a9 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/View/Info/Monkey.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/View/Info/Monkey.php @@ -79,6 +79,7 @@ protected function getCurrentOrder() if (!$this->order) { $this->order = Mage::registry('current_order'); } + return $this->order; } diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/CreateMergeFields.php b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/CreateMergeFields.php index 117544291..7c314e73c 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/CreateMergeFields.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/CreateMergeFields.php @@ -56,6 +56,7 @@ public function getMessageForMailchimpErrorLog() if (!$helper->isErrorLogEnabled()) { $message = 'There was an error on the merge fields creation. Please enable the error logs and try again for more information.'; } + return $helper->__($message); } diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Checkout/Subscribe.php b/app/code/community/Ebizmarts/MailChimp/Block/Checkout/Subscribe.php index e3fc73cde..f91ef6d23 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Checkout/Subscribe.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Checkout/Subscribe.php @@ -72,6 +72,7 @@ protected function isForceHidden($currentValue = null) if (!$currentValue) { $currentValue = $this->getCurrentCheckoutSubscribeValue(); } + return ($currentValue == Ebizmarts_MailChimp_Model_System_Config_Source_Checkoutsubscribe::FORCE_HIDDEN); } @@ -91,6 +92,7 @@ public function isForceEnabled() if ($this->isForceHidden($currentValue) || $this->isForceVisible($currentValue)) { return true; } + return false; } @@ -100,6 +102,7 @@ public function isChecked() if ($this->isCheckedByDefault($currentValue) || $this->isForceVisible($currentValue)) { return true; } + return false; } diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Customer/Newsletter/Index.php b/app/code/community/Ebizmarts/MailChimp/Block/Customer/Newsletter/Index.php index ac87f3bb7..b5944ba26 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Customer/Newsletter/Index.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Customer/Newsletter/Index.php @@ -45,6 +45,7 @@ public function getInterest() $customerId = null; $storeId = $subscriber->getStoreId(); } + $interest = $helper->getInterestGroups($customerId, $subscriber->getSubscriberId(), $storeId); return $interest; } diff --git a/app/code/community/Ebizmarts/MailChimp/Block/Group/Type.php b/app/code/community/Ebizmarts/MailChimp/Block/Group/Type.php index bfdf6600f..0c2ab83b8 100644 --- a/app/code/community/Ebizmarts/MailChimp/Block/Group/Type.php +++ b/app/code/community/Ebizmarts/MailChimp/Block/Group/Type.php @@ -19,6 +19,7 @@ public function __construct(array $args = array()) $type = $interests['interest']['type']; $this->setTemplate("ebizmarts/mailchimp/group/type/$type.phtml"); } + parent::__construct($args); } diff --git a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php index 7f2dafc24..7fe750aa3 100755 --- a/app/code/community/Ebizmarts/MailChimp/Helper/Data.php +++ b/app/code/community/Ebizmarts/MailChimp/Helper/Data.php @@ -248,6 +248,7 @@ public function getStoreRelation() if (!array_key_exists($mcStoreId, $storeRelation)) { $storeRelation[$mcStoreId] = array(); } + $storeRelation[$mcStoreId][] = $storeId; } } @@ -730,6 +731,7 @@ public function resendMCEcommerceData($scopeId, $scope, $filters = null) if (!$this->getResendEnabled($scopeId, $scope)) { $this->saveLastItemsSent($scopeId, $scope, $filters); } + $this->removeEcommerceSyncData($scopeId, $scope, false, $filters); $this->clearErrorGrid($scopeId, $scope, true, $filters); @@ -988,6 +990,7 @@ public function resetErrors($scopeId, $scope = 'stores') $subscriber->setData("mailchimp_sync_error", ''); $subscriber->save(); } + // reset ecommerce data with errors $this->removeEcommerceSyncData($scopeId, $scope, true); $this->clearErrorGrid($scopeId, $scope); @@ -1205,6 +1208,7 @@ protected function getLastCartSent($scopeId, $scope) $cartSyncData = $syncDataCollection->getFirstItem(); $lastCartSent = $cartSyncData->getRelatedId(); } + return $lastCartSent; } @@ -1272,6 +1276,7 @@ public function createMergeFields($scopeId, $scope) } catch (MailChimp_Error $e) { $this->logError($e->getFriendlyMessage()); } + $created = true; } } @@ -1408,9 +1413,11 @@ public function saveEcommerceSyncData( } elseif ($allowBatchRemoval) { $ecommerceSyncDataItem->setData("batch_id", null); } + if ($syncError) { $ecommerceSyncDataItem->setData("mailchimp_sync_error", $syncError); } + //Always set modified value to 0 when saving sync delta or errors. $ecommerceSyncDataItem->setData("mailchimp_sync_modified", $syncModified); if ($syncDeleted !== null) { @@ -1419,15 +1426,19 @@ public function saveEcommerceSyncData( $ecommerceSyncDataItem->setData("mailchimp_sync_error", $syncError); } } + if ($token) { $ecommerceSyncDataItem->setData("mailchimp_token", $token); } + if ($deletedRelatedId) { $ecommerceSyncDataItem->setData("deleted_related_id", $deletedRelatedId); } + if ($syncedFlag !== null) { $ecommerceSyncDataItem->setData("mailchimp_synced_flag", $syncedFlag); } + $ecommerceSyncDataItem->save(); } } @@ -1457,6 +1468,7 @@ public function getEcommerceSyncDataItem($itemId, $itemType, $mailchimpStoreId) ->setData("type", $itemType) ->setData("mailchimp_store_id", $mailchimpStoreId); } + return $ecommerceSyndDataItem; } @@ -1485,13 +1497,16 @@ public function addStoresToFilter($collection, $scopeId, $scope) if ($scopeId === 0) { $filterArray[] = array('eq' => 0); } + foreach ($storesForScope as $storeId) { $filterArray[] = array('eq' => $storeId); } } + if (count($filterArray)) { $collection->addFieldToFilter('store_id', $filterArray); } + return $collection; } @@ -1534,6 +1549,7 @@ public function getDefaultStoreIdForMailChimpScope($magentoStoreId) } else { $magentoStoreId = null; } + return $magentoStoreId; } @@ -1599,6 +1615,7 @@ public function getImageUrlById($productId, $magentoStoreId) $imageSize = Ebizmarts_MailChimp_Model_Config::IMAGE_SIZE_DEFAULT; break; } + $productImage = $productResourceModel->getAttributeRawValue($productId, $imageSize, $magentoStoreId); $productModel->setData($imageSize, $productImage); @@ -1612,6 +1629,7 @@ public function getImageUrlById($productId, $magentoStoreId) } else { $imageUrl = $this->getImageUrlForSize($imageSize, $productModel); } + $this->setCurrentStore($curStore); } @@ -1815,6 +1833,7 @@ public function customMergeFieldAlreadyExists($value, $scopeId, $scope) return true; } } + return false; } @@ -1831,6 +1850,7 @@ public function getCustomMergeFields($scopeId, $scope = null) if (!$customMergeFields) { $customMergeFields = array(); } + return $customMergeFields; } @@ -1865,6 +1885,7 @@ public function getMCJs() } else { $url = $this->retrieveAndSaveMCJsUrlInConfig($storeId); } + $script = ''; } @@ -1899,6 +1920,7 @@ public function retrieveAndSaveMCJsUrlInConfig($scopeId, $scope = 'stores') } catch (Exception $e) { $this->logError($e->getMessage()); } + return $mcJsUrlSaved; } @@ -2235,6 +2257,7 @@ protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initi if (!$collection->getSize()) { $finished = true; } + // $collection->addFieldToFilter('mailchimp_sync_delta', array('gt' => '0000-00-00 00:00:00')); $collection->setPageSize(100); @@ -2255,6 +2278,7 @@ protected function _makeForCollectionItem($collection, $mailchimpStoreId, $initi if ($this->timePassed($initialTime)) { break; } + if ($currentPage == $pages) { $finished = true; } @@ -2281,6 +2305,7 @@ public function timePassed($initialTime) if ($difference > $timeAmount) { $timePassed = true; } + return $timePassed; } @@ -2332,12 +2357,14 @@ protected function _migrateOrdersFrom116($initialTime) if ($this->isEcomSyncDataEnabled($storeId)) { Mage::getModel('mailchimp/api_batches')->replaceAllOrders($initialTime, $storeId); } + if ($this->timePassed($initialTime)) { $finished = false; break; } } } + return $finished; } @@ -2358,6 +2385,7 @@ public function migrationFinished() if (!$migrateFrom115 && !$migrateFrom116 && !$migrateFrom1164) { $migrationFinished = true; } + return $migrationFinished; } @@ -2415,6 +2443,7 @@ public function handleDeleteMigrationConfigData($arrayMigrationConfigData) $this->delete1164MigrationConfigData(); } } + $this->getConfig()->cleanCache(); } @@ -2440,6 +2469,7 @@ public function getMagentoStoreIdsByListId($listId) } } } + Mage::register('mailchimp_store_ids_for_list_' . $listId, $storeIds); } @@ -2490,6 +2520,7 @@ public function loadListSubscriber($listId, $email) } } } + return $subscriber; } @@ -2556,6 +2587,7 @@ protected function deleteCurrentWebhook($scopeId, $scope, $listId) } catch (Exception $e) { $this->logError($e->getMessage()); } + $this->getConfig()->deleteConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_WEBHOOK_ID, $scope, $scopeId); } else { $webhookUrl = $this->getWebhookUrl($scopeId, $scope); @@ -2616,6 +2648,7 @@ public function createNewWebhook($scopeId, $scope, $listId) 'api' => false ); } + try { $response = $api->lists->webhooks->getAll($listId); $createWebhook = true; @@ -2626,6 +2659,7 @@ public function createNewWebhook($scopeId, $scope, $listId) } } } + if ($createWebhook) { $newWebhook = $api->lists->webhooks->add($listId, $hookUrl, $events, $sources); $newWebhookId = $newWebhook['id']; @@ -2643,6 +2677,7 @@ public function createNewWebhook($scopeId, $scope, $listId) $errorMessage = 'Your store could not be accessed by MailChimp\'s Api. Please confirm the URL: ' . $hookUrl . ' is accessible externally to allow the webhook creation.'; $this->logError($errorMessage); } + return $this->__($errorMessage); } catch (Exception $e) { $this->logError($e->getMessage()); @@ -2673,6 +2708,7 @@ protected function getWebhookUrl() if (false != strstr($hookUrl, '?', true)) { $hookUrl = strstr($hookUrl, '?', true); } + return $hookUrl; } @@ -2691,6 +2727,7 @@ public function getRealScopeForConfig($path, $scopeId, $scope = 'stores') } else { $scopeIdsArray = array($scopeId, 0); } + $configCollection = Mage::getResourceModel('core/config_data_collection') ->addFieldToFilter('path', array('eq' => $path)) ->addFieldToFilter('scope_id', array('in' => $scopeIdsArray)); @@ -2701,6 +2738,7 @@ public function getRealScopeForConfig($path, $scopeId, $scope = 'stores') if ($this->isExtraEntry($config, $scope, $scopeId, $websiteId)) { continue; } + switch ($config->getScope()) { case 'stores': $scopeSoFar = array('scope_id' => $config->getScopeId(), 'scope' => $config->getScope()); @@ -2717,6 +2755,7 @@ public function getRealScopeForConfig($path, $scopeId, $scope = 'stores') break; } } + return $scopeSoFar; } @@ -2747,6 +2786,7 @@ public function getIfConfigExistsForScope($configPath, $scopeId, $scope = 'store } } } + Mage::register('mailchimp_' . $configName . '_exists_for_scope_' . $scope . '_' . $scopeId, $configAssociatedToScope); } @@ -2769,6 +2809,7 @@ public function getScopeByMailChimpStoreId($mailChimpStoreId) $configEntry = $collection->getFirstItem(); $mailchimpScope = array('scope' => $configEntry->getScope(), 'scope_id' => $configEntry->getScopeId()); } + return $mailchimpScope; } @@ -2789,6 +2830,7 @@ public function getFirstScopeFromConfig($path, $value) $configEntry = $collection->getFirstItem(); $mailchimpScope = array('scope' => $configEntry->getScope(), 'scope_id' => $configEntry->getScopeId()); } + return $mailchimpScope; } @@ -2813,13 +2855,16 @@ public function updateSubscriberSyndData($itemId, $syncDelta = null, $syncError if ($syncDelta) { $subscriber->setData("mailchimp_sync_delta", $syncDelta); } + if ($syncError) { $subscriber->setData("mailchimp_sync_error", $syncError); } + $subscriber->setData("mailchimp_sync_modified", $syncModified); if ($syncDeleted) { $subscriber->setData("mailchimp_sync_deleted", $syncDeleted); } + $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); $subscriber->save(); } @@ -2854,6 +2899,7 @@ public function addEntriesToArray($batchArray, $productData, $counter) } } } + return array($batchArray, $counter); } @@ -3030,6 +3076,7 @@ public function addResendFilter($collection, $magentoStoreId, $itemType) $lastItemSent = 0; $this->logError($this->__('The item type sent in the filter does not match any of the available options.')); } + if ($resendTurn) { $collection->addFieldToFilter($keyCol, array('lteq' => $lastItemSent)); } else { @@ -3129,6 +3176,7 @@ public function handleResendDataAfter() } else { $this->setResendTurn(1, $scopeId, $scope); } + $this->handleResendFinish($scopeId, $scope); } else { //if ecommerce data sync is disabled delete old config values. @@ -3150,18 +3198,21 @@ protected function allResendItemsSentPerStoreView($storeId) } else { $isMissingCustomer = false; } + $productId = $this->getProductResendLastId($storeId); if ($productId) { $isMissingProduct = $this->isMissingItemLowerThanId($productId, Ebizmarts_MailChimp_Model_Config::IS_PRODUCT, $storeId); } else { $isMissingProduct = false; } + $orderId = $this->getOrderResendLastId($storeId); if ($orderId) { $isMissingOrder = $this->isMissingItemLowerThanId($orderId, Ebizmarts_MailChimp_Model_Config::IS_ORDER, $storeId); } else { $isMissingOrder = false; } + $cartId = $this->getCartResendLastId($storeId); if ($cartId) { $isMissingCart = $this->isMissingItemLowerThanId($cartId, Ebizmarts_MailChimp_Model_Config::IS_QUOTE, $storeId); @@ -3174,6 +3225,7 @@ protected function allResendItemsSentPerStoreView($storeId) } else { $allItemsSent = false; } + return $allItemsSent; } @@ -3191,11 +3243,13 @@ protected function allResendItemsSentPerScope($stores) } else { $storeId = $store; } + $allItemsSentInCurrentStore = $this->allResendItemsSentPerStoreView($storeId); if (!$allItemsSentInCurrentStore) { $allItemsSent = false; } } + return $allItemsSent; } @@ -3224,6 +3278,7 @@ protected function isMissingItemLowerThanId($itemId, $itemType, $mailchimpStoreI $isMissing = false; break; } + return $isMissing; } @@ -3245,6 +3300,7 @@ protected function isMissingCustomerLowerThanId($itemId, $storeId) } else { $isMissing = false; } + return $isMissing; } @@ -3268,6 +3324,7 @@ protected function isMissingProductLowerThanId($itemId, $storeId) } else { $isMissing = false; } + return $isMissing; } @@ -3286,6 +3343,7 @@ protected function isMissingOrderLowerThanId($itemId, $storeId) if ($firstDate) { $orderCollection->addFieldToFilter('created_at', array('gt' => $firstDate)); } + Mage::getModel('mailchimp/api_orders')->joinMailchimpSyncDataWithoutWhere($orderCollection, $mailchimpStoreId); $orderCollection->getSelect()->where("m4m.mailchimp_sync_delta IS null"); if ($orderCollection->getSize()) { @@ -3293,6 +3351,7 @@ protected function isMissingOrderLowerThanId($itemId, $storeId) } else { $isMissing = false; } + return $isMissing; } @@ -3314,6 +3373,7 @@ protected function isMissingQuoteLowerThanId($itemId, $storeId) if ($firstDate) { $quoteCollection->addFieldToFilter('updated_at', array('gt' => $firstDate)); } + Mage::getModel('mailchimp/api_carts')->joinMailchimpSyncDataWithoutWhere($quoteCollection, $mailchimpStoreId); $quoteCollection->getSelect()->where("m4m.mailchimp_sync_delta IS null"); if ($quoteCollection->getSize()) { @@ -3321,6 +3381,7 @@ protected function isMissingQuoteLowerThanId($itemId, $storeId) } else { $isMissing = false; } + return $isMissing; } @@ -3340,6 +3401,7 @@ public function getMailChimpCampaignNameById($campaignId, $scopeId, $scope = 'st if (isset($campaignData['settings']['title'])) { $campaignName = $campaignData['settings']['title']; } + if ($campaignName == '' && isset($campaignData['settings']['subject_line'])) { $campaignName = $campaignData['settings']['subject_line']; } @@ -3351,6 +3413,7 @@ public function getMailChimpCampaignNameById($campaignId, $scopeId, $scope = 'st } catch (Exception $e) { $this->logError($e->getMessage()); } + return $campaignName; } @@ -3462,6 +3525,7 @@ public function getAllMailChimpStoreIds() $scopeData = $row->getScope() . '_' . $row->getScopeId(); $mailchimpStoreIdsArray[$scopeData] = $row->getValue(); } + return $mailchimpStoreIdsArray; } @@ -3476,6 +3540,7 @@ public function subscribeMember($subscriber, $forceUpdateStatus = false) if ($forceUpdateStatus) { $subscriber->setMailchimpSyncModified(1); } + $this->setMemberGeneralData($subscriber); } @@ -3552,6 +3617,7 @@ public function validateDate($date, $format = 'Y-m-d H:i:s') } else { $d = null; } + return $d && $d->format($format) == $date; } @@ -3630,6 +3696,7 @@ public function isNewApiKeyForSameAccount($oldApiKey, $newApiKey) } } } + return $isNewApiKeyForSameAccount; } @@ -3692,17 +3759,21 @@ protected function makeWhereString($connection, $scopeId, $scope) if (count($storesForScope)) { $whereString .= " AND ("; } + $counter = 0; foreach ($storesForScope as $storeId) { if ($counter) { $whereString .= " OR "; } + $whereString .= $connection->quoteInto("store_id = ?", $storeId); $counter++; } + if (count($storesForScope)) { $whereString .= ")"; } + return $whereString; } @@ -3766,6 +3837,7 @@ public function getSyncFlagDataHtml($dat, $string) } else { $string .= "
  • {$syncFlagDataArray[Ebizmarts_MailChimp_Model_System_Config_Source_Account::SYNC_FLAG_LABEL]} : {$this->__('In Progress')}
  • "; } + return $string; } @@ -3790,6 +3862,7 @@ protected function fixTimeTextIfNecessary($textArray) if ($this->isDate($textArray)) { $textArray[1] = "$textArray[1]:$textArray[2]:$textArray[3]"; } + return $textArray; } @@ -3823,6 +3896,7 @@ public function getListIdByApiKeyAndMCStoreId($apiKey, $mailchimpStoreId) } catch (Exception $e) { $this->logError($e->getMessage()); } + return $listId; } @@ -3851,6 +3925,7 @@ public function getListInterestCategoriesByKeyAndList($apiKey, $listId) } catch (Exception $e) { $this->logError($e->getMessage()); } + return $interestGroupsArray; } @@ -3874,6 +3949,7 @@ public function getListInterestGroups($scopeId, $scope = 'stores') foreach ($interestGroups['interests'] as $interestGroup) { $groups[$interestGroup['id']] = $interestGroup['name']; } + $interestGroupsArray[] = array( 'id' => $interestCategory['id'], 'title' => $interestCategory['title'], @@ -3884,6 +3960,7 @@ public function getListInterestGroups($scopeId, $scope = 'stores') } catch (Exception $e) { $this->logError($e->getMessage()); } + return $interestGroupsArray; } @@ -3934,6 +4011,7 @@ public function getInterest($storeId) } else { $interest = array(); } + $api = $this->getApi($storeId); $listId = $this->getGeneralList($storeId); try { @@ -3944,6 +4022,7 @@ public function getInterest($storeId) $rc[$item['id']]['interest'] = array('id' => $item['id'], 'title' => $item['title'], 'type' => $item['type']); } } + $apiInterestCategoryInterest = $apiInterestCategory->getInterests(); foreach ($interest as $interestId) { $mailchimpInterest = $apiInterestCategoryInterest->getAll($listId, $interestId); @@ -3954,6 +4033,7 @@ public function getInterest($storeId) } catch (MailChimp_Error $e) { $this->logError($e->getFriendlyMessage()); } + return $rc; } @@ -3972,6 +4052,7 @@ public function getInterestGroups($customerId, $subscriberId, $storeId, $interes if (!$interest) { $interest = $this->getInterest($storeId); } + $interestGroup = $this->getInterestGroupModel(); $interestGroup->getByRelatedIdStoreId($customerId, $subscriberId, $storeId); if ($interestGroup->getId()) { @@ -4000,6 +4081,7 @@ public function getInterestGroups($customerId, $subscriberId, $storeId, $interes } } } + return $interest; } else { return array(); @@ -4049,10 +4131,12 @@ public function saveInterestGroupData($params, $storeId, $customerId = null, $su $customerId = $customerData->getId(); } } + $subscriberId = null; if ($subscriber) { $subscriberId = $subscriber->getSubscriberId(); } + $interestGroup = $this->getInterestGroupModel(); $interestGroup->getByRelatedIdStoreId($customerId, $subscriberId, $storeId); $origSubscriberId = $interestGroup->getSubscriberId(); @@ -4060,9 +4144,11 @@ public function saveInterestGroupData($params, $storeId, $customerId = null, $su if (!$origSubscriberId || $subscriberId && $origSubscriberId != $subscriberId) { $interestGroup->setSubscriberId($subscriberId); } + if (!$origCustomerId || $customerId && $origCustomerId != $customerId) { $interestGroup->setCustomerId($customerId); } + $encodedGroups = $this->arrayEncode($groups); $interestGroup->setGroupdata($encodedGroups); //Avoid creating a new entry if no groupData available. (Customer creation) @@ -4070,6 +4156,7 @@ public function saveInterestGroupData($params, $storeId, $customerId = null, $su if ($storeId) { $interestGroup->setStoreId($storeId); } + $interestGroup->setUpdatedAt($this->getCurrentDateTime()); $interestGroup->save(); } @@ -4088,6 +4175,7 @@ public function getInterestGroupsIfAvailable($params) } elseif (isset($params['group'])) { $groups = $params['group']; } + return $groups; } @@ -4152,6 +4240,7 @@ public function getAllApiKeys() continue; } } + return $ret; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php index 278806736..4b9bd0671 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Batches.php @@ -207,6 +207,7 @@ public function handleEcommerceBatches() } } } + $helper->handleResendDataAfter(); $syncedDateArray = array(); @@ -214,6 +215,7 @@ public function handleEcommerceBatches() $storeId = $store->getId(); $syncedDateArray = $this->addSyncValueToArray($storeId, $syncedDateArray); } + $this->handleSyncingValue($syncedDateArray); } @@ -231,6 +233,7 @@ protected function _ping($storeId) } catch (Exception $e) { return false; } + return true; } @@ -343,6 +346,7 @@ public function _sendEcommerceBatch($magentoStoreId) $promoCodesArray = $apiPromoCodes->createBatchJson($mailchimpStoreId, $magentoStoreId); $batchArray['operations'] = array_merge($batchArray['operations'], $promoCodesArray); } + //deleted product operations $deletedProductsArray = $apiProducts->createDeletedProductsBatchJson($mailchimpStoreId, $magentoStoreId); $batchArray['operations'] = array_merge($batchArray['operations'], $deletedProductsArray); @@ -589,6 +593,7 @@ public function getBatchResponse($batchId, $magentoStoreId) $files[] = $baseDir . DS . 'var' . DS . 'mailchimp' . DS . $batchId . '/' . $d; } } + unlink($baseDir . DS . 'var' . DS . 'mailchimp' . DS . $batchId . '/' . $batchId . '.tar'); unlink($fileName); } @@ -651,6 +656,7 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId, $helper->modifyCounterDataSentToMailchimp($type); continue; } + $error = $response->title . " : " . $response->detail; if ($type == Ebizmarts_MailChimp_Model_Config::IS_PRODUCT) { @@ -687,8 +693,10 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId, } } } + unlink($file); } + $this->_showResumeDataSentToMailchimp($magentoStoreId); } @@ -799,6 +807,7 @@ protected function addSyncValueToArray($storeId, $syncedDateArray) } } } + return $syncedDateArray; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Carts.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Carts.php index 20f89ce3e..4af616132 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Carts.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Carts.php @@ -46,6 +46,7 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) // get all the carts modified but not converted in orders $allCarts = array_merge($allCarts, $this->_getModifiedQuotes($mailchimpStoreId, $magentoStoreId)); } + // get new carts $allCarts = array_merge($allCarts, $this->_getNewQuotes($mailchimpStoreId, $magentoStoreId)); return $allCarts; @@ -166,6 +167,7 @@ public function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId) $this->_updateSyncData($cartId, $mailchimpStoreId); continue; } + // send the products that not already sent $allCarts = $this->addProductNotSentData($mailchimpStoreId, $magentoStoreId, $cart, $allCarts); @@ -321,6 +323,7 @@ public function _makeCart($cart, $mailchimpStoreId, $magentoStoreId, $isModified if (empty($customer)) { return ""; } + $oneCart['customer'] = $customer; if ($campaignId) { $oneCart['campaign_id'] = $campaignId; @@ -407,6 +410,7 @@ protected function _getCheckoutUrl($cart, $isModified) } else { $token = $cart->getMailchimpToken(); } + $url = Mage::getModel('core/url')->setStore($cart->getStoreId())->getUrl('', array('_nosid' => true, '_secure' => true)) . 'mailchimp/cart/loadquote?id=' . $cart->getEntityId() . '&token=' . $token; $this->setToken($token); return $url; @@ -488,6 +492,7 @@ public function _getCustomer($cart, $magentoStoreId) if ($billingAddress->getCompany()) { $customer["company"] = $billingAddress->getCompany(); } + return $customer; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Customers.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Customers.php index f20749149..0d2b39950 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Customers.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Customers.php @@ -124,6 +124,7 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) $counter++; } + return $customerArray; } @@ -423,6 +424,7 @@ public function joinMailchimpSyncDataWithoutWhere($collection, $mailchimpStoreId if (!$mailchimpStoreId) { $mailchimpStoreId = $this->mailchimpStoreId; } + $joinCondition = "m4m.related_id = e.entity_id and m4m.type = '%s' AND m4m.mailchimp_store_id = '%s'"; $mailchimpTableName = $this->getSyncDataTableName(); diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php index bfcd78938..b3171dcc1 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Orders.php @@ -48,6 +48,7 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) // get all the orders modified $batchArray = array_merge($batchArray, $this->_getModifiedOrders($mailchimpStoreId, $magentoStoreId)); } + // get new orders $batchArray = array_merge($batchArray, $this->_getNewOrders($mailchimpStoreId, $magentoStoreId)); @@ -189,6 +190,7 @@ public function GeneratePOSTPayload($order, $mailchimpStoreId, $magentoStoreId) if ($dataPromo !== null) { $data['promos'] = $dataPromo; } + $statusArray = $this->_getMailChimpStatus($order); if (isset($statusArray['financial_status'])) { $data['financial_status'] = $statusArray['financial_status']; @@ -197,6 +199,7 @@ public function GeneratePOSTPayload($order, $mailchimpStoreId, $magentoStoreId) if (isset($statusArray['fulfillment_status'])) { $data['fulfillment_status'] = $statusArray['fulfillment_status']; } + $data['processed_at_foreign'] = $order->getCreatedAt(); $data['updated_at_foreign'] = $order->getUpdatedAt(); if ($this->isOrderCanceled($order)) { @@ -658,6 +661,7 @@ public function getPromoData($order) } } } + return $promo; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Products.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Products.php index 3fb4aa319..a41a61bb1 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Products.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Products.php @@ -51,6 +51,7 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) ->setConfig(Mage_Catalog_Helper_Category_Flat::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY, 0) ->setConfig(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, 0); } + $this->_markSpecialPrices($mailchimpStoreId, $magentoStoreId); $collection = $this->makeProductsNotSentCollection($magentoStoreId); $this->joinMailchimpSyncData($collection, $mailchimpStoreId); @@ -87,6 +88,7 @@ public function createBatchJson($mailchimpStoreId, $magentoStoreId) $this->_updateSyncData($productId, $mailchimpStoreId, $this->getCurrentDate(), "This product type is not supported on MailChimp.", 0, null, 0); } } + $helper->getMageApp()->setCurrentStore($oldStore); return $batchArray; } @@ -107,8 +109,10 @@ public function createDeletedProductsBatchJson($mailchimpStoreId, $magentoStoreI $batchArray[$counter] = $data; $counter++; } + $this->_updateSyncData($product->getId(), $mailchimpStoreId, null, self::PRODUCT_DISABLED_IN_MAGENTO, 0, null, 0); } + return $batchArray; } @@ -193,6 +197,7 @@ protected function _buildUpdateProductRequest($product, $batchId, $mailchimpStor //@TODO bundle return array(); } + $bodyData = $this->_buildProductData($product, $magentoStoreId, false, $variantProducts); try { $body = json_encode($bodyData, JSON_HEX_APOS|JSON_HEX_QUOT); @@ -228,9 +233,11 @@ protected function _buildProductData($product, $magentoStoreId, $isVariant = tru } else { $url = $this->getProductUrl($product, $magentoStoreId); } + if (!$url) { $url = Mage::app()->getStore($magentoStoreId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); } + $data["url"] = $url; //image @@ -266,10 +273,12 @@ protected function _buildProductData($product, $magentoStoreId, $isVariant = tru if (isset($data["image_url"])) { $this->_parentImageUrl = $data["image_url"]; } + $this->_parentId = $product->getId(); if ($this->currentProductIsVisible()) { $this->_parentUrl = $data['url']; } + $price = $this->getMailchimpFinalPrice($product); if ($price) { $this->_parentPrice = $price; @@ -301,6 +310,7 @@ public function update($productId, $mailchimpStoreId) foreach ($parentIdArray as $parentId) { $this->_updateSyncData($parentId, $mailchimpStoreId, null, null, 1, 0, null, true, false); } + $this->_updateSyncData($productId, $mailchimpStoreId, null, null, 1, 0, null, true, false); } @@ -341,6 +351,7 @@ public function sendModifiedProduct($order, $mailchimpStoreId, $magentoStoreId) if ($productId) { $this->_updateSyncData($productId, $mailchimpStoreId, $this->getCurrentDate(), "This product type is not supported on MailChimp.", 0, null, 0); } + continue; } @@ -419,6 +430,7 @@ public function makeProductsNotSentCollection($magentoStoreId, $isParentProduct if (!$isParentProduct) { $collection->addFinalPrice(); } + $collection->addStoreFilter($magentoStoreId); $this->mailchimpHelper->addResendFilter($collection, $magentoStoreId, Ebizmarts_MailChimp_Model_Config::IS_PRODUCT); @@ -730,6 +742,7 @@ public function getNotVisibleProductUrl($childId, $magentoStoreId) } else { $parentId = $this->_parentId; } + if ($parentId) { $collection = $this->getProductWithAttributesById($magentoStoreId, $parentId); @@ -740,6 +753,7 @@ public function getNotVisibleProductUrl($childId, $magentoStoreId) $path = $rc->getAttributeRawValue($parentId, 'url_path', $magentoStoreId); $url = $this->getUrlByPath($path, $magentoStoreId); } + $tailUrl = '#'; $count = 0; foreach ($collection as $attribute) { @@ -749,16 +763,20 @@ public function getNotVisibleProductUrl($childId, $magentoStoreId) if ($count > 0) { $tailUrl .= '&'; } + $tailUrl .= $attributeId . '=' . $attributeValue; } + $count++; } + if ($tailUrl != '#') { $url .= $tailUrl; } } else { $url = null; } + return $url; } @@ -771,10 +789,12 @@ public function getParentImageUrl($childId, $magentoStoreId) } else { $parentId = $this->_parentId; } + if ($parentId) { $helper = $this->getMailChimpHelper(); $imageUrl = $helper->getImageUrlById($parentId, $magentoStoreId); } + return $imageUrl; } @@ -811,8 +831,10 @@ public function getProductCategories($product, $magentoStoreId) foreach ($collection as $category) { $categoryNames[] = $category->getName(); } + $categoryName = (count($categoryNames)) ? implode(" - ", $categoryNames) : 'None'; } + return $categoryName; } @@ -827,6 +849,7 @@ protected function getParentId($childId) if (count($parentIds)) { $parentId = $parentIds[0]; } + return $parentId; } @@ -878,6 +901,7 @@ protected function getMailChimpImageUrl($product, $magentoStoreId) if (!$imageUrl) { $imageUrl = $this->getParentImageUrl($product->getId(), $magentoStoreId); } + return $imageUrl; } @@ -900,6 +924,7 @@ protected function getMailChimpProductPrice($product, $magentoStoreId) $price = $this->_parentPrice; } } + return $price; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoCodes.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoCodes.php index 503c739aa..5fc50d259 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoCodes.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoCodes.php @@ -293,6 +293,7 @@ public function getApiPromoRules() if (!$this->apiPromoRules) { $this->apiPromoRules = Mage::getModel('mailchimp/api_promoRules'); } + return $this->apiPromoRules; } @@ -352,6 +353,7 @@ protected function getPromoCodesForRule($promoRuleId) $helper->logError($e->getFriendlyMessage()); } } + return $promoCodes; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoRules.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoRules.php index f302c34dd..bd500d74f 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoRules.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/PromoRules.php @@ -83,6 +83,7 @@ public function getNewPromoRule($ruleId, $batchId, $mailchimpStoreId, $magentoSt if (!$error) { $error = $helper->__('Something went wrong when retrieving the information.'); } + $this->_updateSyncData($ruleId, $mailchimpStoreId, Varien_Date::now(), $error); } } catch (Exception $e) { @@ -271,6 +272,7 @@ protected function getMailChimpType($promoAction) $mailChimpType = self::TYPE_FIXED; break; } + return $mailChimpType; } @@ -286,6 +288,7 @@ protected function getMailChimpTarget($promoAction) $mailChimpTarget = self::TARGET_PER_ITEM; break; } + return $mailChimpTarget; } @@ -327,6 +330,7 @@ protected function getMailChimpDiscountAmount($promoRule) } else { $mailChimpDiscount = $promoRule->getDiscountAmount(); } + return $mailChimpDiscount; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Stores.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Stores.php index 5d46cc8e2..84fc96868 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Stores.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Stores.php @@ -77,6 +77,7 @@ public function createMailChimpStore( $adminSession = $this->getAdminSession(); $adminSession->addError($errorMessage); } + return $response; } @@ -138,6 +139,7 @@ public function editMailChimpStore( $adminSession = $this->getAdminSession(); $adminSession->addError($errorMessage); } + return $response; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php b/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php index 812131241..244b6d9ea 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Api/Subscribers.php @@ -119,6 +119,7 @@ protected function _buildSubscriberData($subscriber) if ($subscriber->getMailchimpSyncModified()) { $data["status"] = $status; } + $data["language"] = $helper->getStoreLanguageCode($storeId); $interest = $this->_getInterest($subscriber); if (count($interest)) { @@ -144,6 +145,7 @@ protected function _getInterest($subscriber) $rc[$value['id']] = $value['checked']; } } + return $rc; } @@ -381,6 +383,7 @@ public function updateSubscriber($subscriber, $updateStatus = false) $helper->logError($e->getMessage()); return; } + $mergeVars = $this->getMergeVars($subscriber); $language = $helper->getStoreLanguageCode($storeId); $interest = $this->_getInterest($subscriber); @@ -422,6 +425,7 @@ public function updateSubscriber($subscriber, $updateStatus = false) $errorMessage = $helper->__("The subscription could not be applied."); $this->addError($errorMessage); } + $subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED); $saveSubscriber = true; } catch (Exception $e) { @@ -436,6 +440,7 @@ public function updateSubscriber($subscriber, $updateStatus = false) $errorMessage = $helper->__("The subscription could not be applied."); $this->addError($errorMessage); } + $subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED); $saveSubscriber = true; } @@ -448,11 +453,13 @@ public function updateSubscriber($subscriber, $updateStatus = false) $errorMessage = $helper->__("The subscription could not be applied."); $this->addError($errorMessage); } + $subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED); } } catch (Exception $e) { $helper->logError($e->getMessage()); } + if ($saveSubscriber) { $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); $subscriber->save(); @@ -578,6 +585,7 @@ protected function getAddressData($address) $addressData["country"] = Mage::getModel('directory/country')->loadByCode($address->getCountry())->getName(); } } + return $addressData; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Email/Template.php b/app/code/community/Ebizmarts/MailChimp/Model/Email/Template.php index 37d3112d3..6239f8636 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/Email/Template.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Email/Template.php @@ -234,6 +234,7 @@ protected function getSendersDomains($mail) } catch (Exception $e) { Mage::log($e->getMessage(), null, 'Mandrill.log', true); } + return $mandrillSenders; } @@ -250,6 +251,7 @@ protected function sendMail($email, $mail) } catch (Exception $e) { Mage::log($e->getMessage(), null, 'Mandrill.log', true); } + return $mailSent; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php index 12c94c74d..fecbacc70 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/Observer.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/Observer.php @@ -147,11 +147,13 @@ public function saveConfigBefore(Varien_Event_Observer $observer) $message = $helper->__('The Mailchimp store configuration was not modified. There is a Mailchimp audience configured for this scope. Both must be set to inherit at the same time.'); $this->getAdminSession()->addError($message); } + if ($configDataChanged) { $config->setData($configData); } } } + return $observer; } @@ -310,6 +312,7 @@ public function customerSaveAfter(Varien_Event_Observer $observer) if (!$storeId) { $storeId = $customer->getMailchimpStoreView(); } + $helper = $this->makeHelper(); $isEnabled = $helper->isSubscriptionEnabled($storeId); $params = $this->getRequest()->getParams(); @@ -334,6 +337,7 @@ public function customerSaveAfter(Varien_Event_Observer $observer) } } } + //update subscriber data if a subscriber with the same email address exists and was not affected. if (!$origEmail || $origEmail == $customerEmail) { $apiSubscriber->update($customerEmail, $storeId); @@ -393,6 +397,7 @@ public function newOrder(Varien_Event_Observer $observer) $subscriber->setSubscriberFirstname($order->getCustomerFirstname()); $subscriber->setSubscriberLastname($order->getCustomerLastname()); } + $subscriber->subscribe($email); } } @@ -559,6 +564,7 @@ public function addColumnToSalesOrderGrid(Varien_Event_Observer $observer) 'created_at' ); } + if ($addColumnConfig == Ebizmarts_MailChimp_Model_Config::ADD_SYNC_STATUS_TO_GRID || $addColumnConfig == Ebizmarts_MailChimp_Model_Config::ADD_BOTH_TO_GRID) { $block->addColumnAfter( 'mailchimp_synced_flag', @@ -696,6 +702,7 @@ public function newCreditMemo(Varien_Event_Observer $observer) $apiOrder->update($order->getEntityId(), $storeId); } + return $observer; } @@ -734,6 +741,7 @@ public function cancelCreditMemo(Varien_Event_Observer $observer) $apiOrder->update($order->getEntityId(), $storeId); } + return $observer; } @@ -1021,14 +1029,18 @@ public function addCustomerTab(Varien_Event_Observer $observer) if (!$storeId) { $storeId = $customer->getMailchimpStoreView(); } + if ($helper->getLocalInterestCategories($storeId) && ($this->getRequest()->getActionName() == 'edit' || $this->getRequest()->getParam('type'))) { - $block->addTab('mailchimp', array( + $block->addTab( + 'mailchimp', array( 'label' => $helper->__('MailChimp'), 'url' => $block->getUrl('adminhtml/mailchimp/index', array('_current' => true)), 'class' => 'ajax' - )); + ) + ); } } + return $observer; } @@ -1064,6 +1076,7 @@ public function handleCustomerGroups($subscriberEmail, $params, $storeId, $custo //save frontend groupdata when customer is not subscribed. $helper->saveInterestGroupData($params, $storeId, $customerId); } + return $subscriber; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php b/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php index ecd0366c1..05a8562ab 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php @@ -77,6 +77,7 @@ public function processWebhookData() $this->_profile($data); } } + $webhookRequest->setProcessed(1) ->save(); } @@ -160,6 +161,7 @@ protected function _subscribe(array $data) $subscriberLname = filter_var($data['merges']['LNAME'], FILTER_SANITIZE_STRING); $subscriber->setSubscriberLastname($subscriberLname); } + $helper->subscribeMember($subscriber); } } @@ -216,10 +218,12 @@ public function _profile(array $data) $customer->setFirstname($fname); $saveRequired = true; } + if ($lname && $lname !== $customer->getLastname()) { $customer->setLastname($lname); $saveRequired = true; } + if ($saveRequired) { $customer->save(); } @@ -231,10 +235,12 @@ public function _profile(array $data) $subscriber->setSubscriberFirstname($fname); $saveRequired = true; } + if ($lname && $lname !== $subscriber->getSubscriberLastname()) { $subscriber->setSubscriberLastname($lname); $saveRequired = true; } + if ($saveRequired) { $subscriber->setSubscriberSource(Ebizmarts_MailChimp_Model_Subscriber::SUBSCRIBE_SOURCE); $subscriber->save(); diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Backend/Store.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Backend/Store.php index 29823831b..4c8e0d43b 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Backend/Store.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Backend/Store.php @@ -31,6 +31,7 @@ protected function _afterSave() $configValues = array(array(Ebizmarts_MailChimp_Model_Config::GENERAL_ECOMMMINSYNCDATEFLAG."_$newMailchimpStoreId", Varien_Date::now())); $helper->saveMailchimpConfig($configValues, 0, 'default'); } + if ($isSyncing === null) { $configValues = array(array(Ebizmarts_MailChimp_Model_Config::GENERAL_MCISSYNCING . "_$newMailchimpStoreId", true)); $helper->saveMailchimpConfig($configValues, $scopeId, $scope); diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Account.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Account.php index cfd745f9e..19f96bf05 100755 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Account.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Account.php @@ -75,8 +75,10 @@ public function __construct($params) $message = $helper->__('Looks like your Mailchimp store was deleted. Please create a new one and associate it in order to get your Ecommerce data synced.'); Mage::getSingleton('adminhtml/session')->addWarning($message); } + $this->_accountDetails['store_exists'] = false; } + try { $listId = (isset($mcStore['list_id']) && $mcStore['list_id']) ? $mcStore['list_id'] : null; @@ -135,6 +137,7 @@ public function toOptionArray() $totalListSubscribersText = $helper->__('Total Audience Subscribers:'); $totalListSubscribers = $totalListSubscribersText . ' ' . $this->_accountDetails['list_subscribers']; } + $username = $helper->__('Username:') . ' ' . $this->_accountDetails['account_name']; $returnArray = array( array('value' => self::USERNAME_KEY, 'label' => $username), @@ -143,6 +146,7 @@ public function toOptionArray() if ($totalListSubscribers) { $returnArray[] = array('value' => self::TOTAL_LIST_SUB_KEY, 'label' => $totalListSubscribers); } + if ($this->_accountDetails['store_exists']) { $totalCustomersText = $helper->__(' Total Customers:'); $totalCustomers = $totalCustomersText . ' ' . $this->_accountDetails['total_customers']; @@ -163,6 +167,7 @@ public function toOptionArray() $syncValue = self::FINISHED; } } + $syncLabel = $helper->__('Initial sync') . ': ' . $syncValue; $returnArray = array_merge( $returnArray, diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/CustomerGroup.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/CustomerGroup.php index b1189cb15..eeabb2a7a 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/CustomerGroup.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/CustomerGroup.php @@ -46,6 +46,7 @@ public function toOptionArray() } else { $groups[] = array('value' => '', 'label' => $helper->__('--- No data ---')); } + return $groups; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/List.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/List.php index f3b20cc28..b10833494 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/List.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/List.php @@ -83,6 +83,7 @@ public function toOptionArray() if (count($mcLists['lists']) > 1) { $lists[] = array('value' => '', 'label' => $helper->__('--- Select a Mailchimp List ---')); } + foreach ($mcLists['lists'] as $list) { $memberCount = $list['stats']['member_count']; $memberText = $helper->__('members'); @@ -92,6 +93,7 @@ public function toOptionArray() } else { $lists[] = array('value' => '', 'label' => $helper->__('--- No data ---')); } + return $lists; } diff --git a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Store.php b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Store.php index ed9d60fc8..fb87cac8c 100644 --- a/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Store.php +++ b/app/code/community/Ebizmarts/MailChimp/Model/System/Config/Source/Store.php @@ -58,6 +58,7 @@ public function toOptionArray() if ($store['list_id']=='') { continue; } + if (isset($store['connected_site'])) { $label = $store['name']; } else { @@ -70,6 +71,7 @@ public function toOptionArray() } else { $stores[] = array('value' => '', 'label' => $helper->__('--- No data ---')); } + return $stores; } diff --git a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/EcommerceController.php b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/EcommerceController.php index 10730185a..1f63f4973 100644 --- a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/EcommerceController.php +++ b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/EcommerceController.php @@ -33,6 +33,7 @@ public function resetLocalErrorsAction() $helper->resetErrors($store->getId()); } } + $helper->resetErrors($scopeId, $scope); } catch (Exception $e) { $helper->logError($e->getMessage()); @@ -68,6 +69,7 @@ public function resendEcommerceDataAction() $this->addError($e->getMessage()); } } + $mageApp->getResponse()->setBody($success); } diff --git a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpController.php b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpController.php index efb093f0a..8f2367363 100644 --- a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpController.php +++ b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpController.php @@ -103,6 +103,7 @@ public function getInfoAction() $data[$key]['label'] = $liElement; } } + $jsonData = json_encode($data); $response = $this->getResponse(); diff --git a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimperrorsController.php b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimperrorsController.php index 481311da8..038ae94b0 100644 --- a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimperrorsController.php +++ b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimperrorsController.php @@ -59,6 +59,7 @@ public function downloadresponseAction() $fileContent = $this->__("Response was deleted from MailChimp server."); break; } + foreach ($files as $file) { $items = $this->getFileContent($file); foreach ($items as $item) { @@ -76,6 +77,7 @@ public function downloadresponseAction() $response->setBody(json_encode($fileContent, JSON_PRETTY_PRINT)); } + return; } diff --git a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpstoresController.php b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpstoresController.php index e5efe361d..179dac787 100644 --- a/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpstoresController.php +++ b/app/code/community/Ebizmarts/MailChimp/controllers/Adminhtml/MailchimpstoresController.php @@ -156,6 +156,7 @@ protected function _loadStores() $helper->logError($e->getMessage()); continue; } + try { $root = $api->getRoot()->info(); $stores = $api->getEcommerce()->getStores()->get(null, null, null, 100); diff --git a/app/code/community/Ebizmarts/MailChimp/controllers/GroupController.php b/app/code/community/Ebizmarts/MailChimp/controllers/GroupController.php index 7044662ba..1f2457a90 100644 --- a/app/code/community/Ebizmarts/MailChimp/controllers/GroupController.php +++ b/app/code/community/Ebizmarts/MailChimp/controllers/GroupController.php @@ -33,6 +33,7 @@ public function indexAction() $subscriber->setSubscriberLastname($order->getCustomerLastname()); $subscriber->subscribe($customerEmail); } + $subscriberId = $subscriber->getSubscriberId(); $interestGroup->getByRelatedIdStoreId($customerId, $subscriberId, $storeId); $encodedGroups = $helper->arrayEncode($params); @@ -50,6 +51,7 @@ public function indexAction() $helper->logError($e->getMessage()); $session->addWarning($this->__('Something went wrong with the interests subscription. Please go to the account subscription menu to subscriber to the interests successfully.')); } + $this->_redirect('/'); } diff --git a/app/code/community/Ebizmarts/MailChimp/controllers/WebhookController.php b/app/code/community/Ebizmarts/MailChimp/controllers/WebhookController.php index e429dc8ef..3bb2a623c 100755 --- a/app/code/community/Ebizmarts/MailChimp/controllers/WebhookController.php +++ b/app/code/community/Ebizmarts/MailChimp/controllers/WebhookController.php @@ -22,6 +22,7 @@ protected function getHelper() if (!$this->mailchimpHelper) { $this->mailchimpHelper = Mage::helper('mailchimp'); } + return $this->mailchimpHelper; } @@ -48,6 +49,7 @@ public function indexAction() $helper->logError($e->getMessage()); $api = null; } + if (!$api) { try { $webhooks = $api->lists->webhooks->getAll($listId); diff --git a/app/code/community/Ebizmarts/MailChimp/sql/mailchimp_setup/mysql4-upgrade-1.1.12-1.1.12.2.php b/app/code/community/Ebizmarts/MailChimp/sql/mailchimp_setup/mysql4-upgrade-1.1.12-1.1.12.2.php index eba25f786..0fadb8eab 100644 --- a/app/code/community/Ebizmarts/MailChimp/sql/mailchimp_setup/mysql4-upgrade-1.1.12-1.1.12.2.php +++ b/app/code/community/Ebizmarts/MailChimp/sql/mailchimp_setup/mysql4-upgrade-1.1.12-1.1.12.2.php @@ -18,13 +18,15 @@ } catch (Exception $e) { Mage::log($e->getMessage(), null, 'MailChimp_Errors.log', true); } + $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $entityTypeId = $setup->getEntityTypeId('customer'); $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId); $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); -$setup->addAttribute("customer", "mailchimp_store_view", array( +$setup->addAttribute( + "customer", "mailchimp_store_view", array( "type" => "int", "label" => "Store View (For MailChimp)", "input" => "select", @@ -34,7 +36,8 @@ "unique" => false, "note" => "A store view must be specified to sync this customer to MailChimp" -)); + ) +); try { $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "mailchimp_store_view"); diff --git a/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/customer/tab/mailchimp.phtml b/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/customer/tab/mailchimp.phtml index 4a08493c4..0d7a8c85f 100644 --- a/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/customer/tab/mailchimp.phtml +++ b/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/customer/tab/mailchimp.phtml @@ -26,7 +26,8 @@ $interest = $this->getInterest(); value="" id="" title="" - + /> @@ -42,7 +43,8 @@ $interest = $this->getInterest(); title=""> - + @@ -59,14 +61,15 @@ $interest = $this->getInterest(); value="" id="" title="" - + /> - + diff --git a/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/system/config/form/field/array_dropdown.phtml b/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/system/config/form/field/array_dropdown.phtml index 68e52a01a..47feaee07 100644 --- a/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/system/config/form/field/array_dropdown.phtml +++ b/app/design/adminhtml/default/default/template/ebizmarts/mailchimp/system/config/form/field/array_dropdown.phtml @@ -11,6 +11,7 @@ $_colspan = 2; if (!$this->_addAfter) { $_colspan -= 1; } + $_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : ''; ?> diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/subscribe.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/subscribe.phtml index 986e23744..5bfa3391d 100644 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/subscribe.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/subscribe.phtml @@ -1,4 +1,3 @@ - isForceEnabled(); $check = $this->isChecked(); @@ -62,23 +61,27 @@ $generalList = $this->getGeneralList(); }; -
    style="display:none;"> +
    style="display:none;">
    -

    __('Newsletter Subscription'); ?>

    +

    quoteEscape($this->__('Newsletter Subscription')); ?>

    getBlockHtml('formkey'); ?>
    • - checked="checked" type="checkbox" - onchange="addSubscribeToPost(this);" - name="list[][subscribed]" - id="mailchimp-trigger" - value="" - title="" - class="mailchimp-list-subscriber"/> - + checked="checked" type="checkbox" + onchange="addSubscribeToPost(this);" + name="list[escapeHtml($generalList); ?>][subscribed]" + id="mailchimp-trigger" + value="escapeHtml($generalList); ?>" + title="escapeHtml($generalList); ?>" + class="mailchimp-list-subscriber"/> +
    @@ -87,6 +90,6 @@ $generalList = $this->getGeneralList(); diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/success/groups.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/success/groups.phtml index ed56409ce..2372cccf2 100644 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/success/groups.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/checkout/success/groups.phtml @@ -5,17 +5,21 @@ $helper = $block->getMailChimpHelper(); ?>

    isInterestGroupEnabled($this->_getStoreId())): ?> - getMessageBefore() ?> -

    + quoteEscape($block->getMessageBefore()) ?> +
    -
    @@ -28,12 +32,12 @@ $helper = $block->getMailChimpHelper(); title="escapeHtml(__('Subscribe to more detailed newsletters')) ?>" style="margin-top: 10px; margin-bottom: 10px;" > - + escapeHtml(__('Subscribe to more detailed newsletters')) ?>
    -getMessageAfter() ?> - +escapeHtml($block->getMessageAfter()) ?> +

    diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/customer/newsletter/index.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/customer/newsletter/index.phtml index cc6068e99..bae9337c2 100644 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/customer/newsletter/index.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/customer/newsletter/index.phtml @@ -6,11 +6,15 @@ $interest = $block->getInterest(); diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/checkboxes.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/checkboxes.phtml index 9c0bd1924..4490e99ab 100644 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/checkboxes.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/checkboxes.phtml @@ -3,17 +3,26 @@ $block = $this; $i = $this->getCurrentInterest(); ?> diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/dropdown.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/dropdown.phtml index 1769b36eb..f2db60b3c 100644 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/dropdown.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/dropdown.phtml @@ -4,12 +4,15 @@ $i = $this->getCurrentInterest(); ?>
    diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/radio.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/radio.phtml index a01dd058e..172cf0239 100644 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/radio.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/group/type/radio.phtml @@ -3,17 +3,21 @@ $block = $this; $i = $this->getCurrentInterest(); ?> diff --git a/app/design/frontend/base/default/template/ebizmarts/mailchimp/popup/emailcatcher.phtml b/app/design/frontend/base/default/template/ebizmarts/mailchimp/popup/emailcatcher.phtml index b6475efa3..369c92b64 100755 --- a/app/design/frontend/base/default/template/ebizmarts/mailchimp/popup/emailcatcher.phtml +++ b/app/design/frontend/base/default/template/ebizmarts/mailchimp/popup/emailcatcher.phtml @@ -1,16 +1,13 @@ - -_getStoreId()) && Mage::getStoreConfig(Ebizmarts_MailChimp_Model_Config::ENABLE_POPUP, $this->_getStoreId())): ?> - +_getStoreId()) + && Mage::getStoreConfig(Ebizmarts_MailChimp_Model_Config::ENABLE_POPUP, $this->_getStoreId())): ?>