Skip to content

Commit

Permalink
Merge pull request #411 from mailchimp/develop
Browse files Browse the repository at this point in the history
Merge release to master
  • Loading branch information
Santiagoebizmarts authored Jul 27, 2017
2 parents 4e848d2 + 265ced3 commit 801008e
Show file tree
Hide file tree
Showing 38 changed files with 1,537 additions and 735 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
dist: trusty
language: php
php:
#- 5.4
#- 5.5
- 5.5
- 5.6
- 7.0

Expand Down Expand Up @@ -57,7 +56,4 @@ script:
- |
if [ "$TEST_SUITE" = "phpunit" ]; then
cd magento/dev/tests/mailchimp && phpunit && cd $TRAVIS_BUILD_DIR
fi
#notifications:
# slack: ebizmarts:DqCqxnqWzW55zoFU069hxs1T
fi
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
$html = '<ul class="checkboxes">';

foreach ($values as $dat) {
if ($dat['value'] >= 7) {
if ($dat['value'] > 7 && $dat['value'] < 10) {
$html .= "<li style='color:red;font-weight: bold;'>{$dat['label']}</li>";
} elseif ($dat['value'] == 10) {
$html .= "<li style='color:forestgreen;font-weight: bold;'>{$dat['label']}</li>";
} elseif($dat['value'] == 3) {
$textArray = explode(':', $dat['label']);
if (strstr($textArray[1], $this->__('Finished'))) {
$html .= "<li>{$textArray[0]} : <span style='color:forestgreen;font-weight: bold;'>{$textArray[1]}</span></li>";
} else {
$html .= "<li>{$textArray[0]} : <span style='color:#ed6502;font-weight: bold;'>{$textArray[1]}</span></li>";
}
} else {
$html .= "<li>{$dat['label']}</li>";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
public function getButtonHtml()
{
$scopeArray = explode('-', Mage::helper('mailchimp')->getScopeString());
if (Mage::helper('mailchimp')->getIfMCStoreIdExistsForScope($scopeArray[1], $scopeArray[0])) {
if (Mage::helper('mailchimp')->getIfConfigExistsForScope(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTOREID, $scopeArray[1], $scopeArray[0])) {
$label = $this->helper('mailchimp')->__('Reset Ecommerce Data');
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
->setData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
public function getButtonHtml()
{
$scopeArray = explode('-', Mage::helper('mailchimp')->getScopeString());
if (Mage::helper('mailchimp')->getIfMCStoreIdExistsForScope($scopeArray[1], $scopeArray[0])) {
if (Mage::helper('mailchimp')->isMailChimpEnabled($scopeArray[1], $scopeArray[0]) || $scopeArray[1] == 0) {
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
->setData(
array(
Expand Down
123 changes: 123 additions & 0 deletions app/code/community/Ebizmarts/MailChimp/Block/Checkout/Subscribe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

/**
* Checkout subscribe checkbox block renderer
*
* @category Ebizmarts
* @package Ebizmarts_MageMonkey
* @author Ebizmarts Team <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php
*/
class Ebizmarts_MailChimp_Block_Checkout_Subscribe extends Mage_Core_Block_Template
{

protected $_lists = array();
protected $_info = array();
protected $_myLists = array();
protected $_generalList = array();
protected $_form;
protected $_api;
protected $helper;
protected $storeId;

public function __construct()
{
parent::__construct();
$this->helper = Mage::helper('mailchimp');
$this->storeId = Mage::app()->getStore()->getId();
}

/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
$helper = $this->helper;
$storeId = $this->storeId;

$alreadySubscribed = Mage::getModel('newsletter/subscriber')
->loadByEmail($this->getQuote()->getCustomerEmail())
->isSubscribed();

if ($helper->isCheckoutSubscribeEnabled($storeId) && !$alreadySubscribed) {
return parent::_toHtml();
} else {
return '';
}
}

/**
* Retrieve current quote object from session
*
* @return Mage_Sales_Model_Quote
*/
protected function getQuote()
{
return Mage::getSingleton('checkout/session')
->getQuote();
}

protected function getCurrentCheckoutSubscribeValue()
{
return $this->helper->getCheckoutSubscribeValue($this->storeId);
}

protected function isForceHidden($currentValue = null)
{
if (!$currentValue) {
$currentValue = $this->getCurrentCheckoutSubscribeValue();
}
return ($currentValue == Ebizmarts_MailChimp_Model_System_Config_Source_Checkoutsubscribe::FORCE_HIDDEN);
}

protected function isForceVisible($currentValue)
{
return ($currentValue == Ebizmarts_MailChimp_Model_System_Config_Source_Checkoutsubscribe::FORCE_VISIBLE);
}

protected function isCheckedByDefault($currentValue)
{
return ($currentValue == Ebizmarts_MailChimp_Model_System_Config_Source_Checkoutsubscribe::CHECKED_BY_DEFAULT);
}

public function isForceEnabled()
{
$currentValue = $this->getCurrentCheckoutSubscribeValue();
if ($this->isForceHidden($currentValue) || $this->isForceVisible($currentValue)) {
return true;
}
return false;
}

public function isChecked()
{
$currentValue = $this->getCurrentCheckoutSubscribeValue();
if ($this->isCheckedByDefault($currentValue) || $this->isForceVisible($currentValue)) {
return true;
}
return false;
}

public function addToPostOnLoad()
{
return ($this->isChecked() || $this->isForceHidden());
}

/**
* Get list data from MC
*
* @return array
*/
public function getGeneralList()
{
$storeId = $this->storeId;
$helper = $this->helper;
$listId = $helper->getGeneralList($storeId);

//@Todo add support for intetest groups

return $listId;
}
}
Loading

0 comments on commit 801008e

Please sign in to comment.