diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedmails.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedmails.php new file mode 100644 index 0000000..f46fb04 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedmails.php @@ -0,0 +1,24 @@ + + * Date : 5/7/13 + * Time : 11:52 PM + * File : Abandonedmails.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Block_Adminhtml_Abandonedmails extends Mage_Adminhtml_Block_Widget_Grid_Container +{ + public function __construct() + { + // The blockGroup must match the first half of how we call the block, and controller matches the second half + // ie. foo_bar/adminhtml_baz + $this->_blockGroup = 'ebizmarts_abandonedcart'; + $this->_controller = 'adminhtml_abandonedmails'; + $this->_headerText = $this->__('Mails sent from autoresponders and abandoned carts'); + + parent::__construct(); + $this->removeButton('add'); + + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedmails/Grid.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedmails/Grid.php new file mode 100644 index 0000000..9eb3f05 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedmails/Grid.php @@ -0,0 +1,97 @@ + + * Date : 5/7/13 + * Time : 11:08 PM + * File : Grid.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Block_Adminhtml_Abandonedmails_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + public function __construct() + { + parent::__construct(); + $this->setDefaultSort('id'); + $this->setId('ebizmarts_abandonedcart_abandonedmails_grid'); + $this->setUseAjax(true); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + } + + protected function _getCollectionClass() + { + return 'ebizmarts_abandonedcart/mailssent_collection'; + } + + protected function _prepareCollection() + { + $collection = Mage::getResourceModel($this->_getCollectionClass()); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + protected function _prepareColumns() + { + + $this->addColumn('store', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Store'), + 'type' => 'store', + 'index' => 'store_id' + )); + + $this->addColumn('sent_at', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Sent At'), + 'index' => 'sent_at', + 'filter_index' => 'sent_at', + 'type' => 'datetime', + 'width' => '100px', + )); + + $this->addColumn('customer_email', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Customer Email'), + 'index' => 'customer_email', + )); + + $this->addColumn('customer_name', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Customer Name'), + 'index' => 'customer_name', + )); + + $this->addColumn('mail_type', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Mail Type'), + 'index' => 'mail_type', + 'type' => 'options', + 'options' => $this->getMailTypeOptions(), + )); + $this->addColumn('coupon', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Coupon #'), + 'index' => 'coupon_number', + )); + $this->addColumn('coupon_type', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Coupon type'), + 'type' => 'options', + 'index' => 'coupon_type', + 'options' => Mage::getModel('Ebizmarts_AbandonedCart_Model_System_Config_Discounttype')->options(), + )); + $this->addColumn('coupon_amount', array( + 'header' => Mage::helper('ebizmarts_abandonedcart')->__('Coupon amount'), + 'index' => 'coupon_amount', + )); + + $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV')); + $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML')); + + return parent::_prepareColumns(); + } + + public function getGridUrl() + { + return $this->getUrl('*/*/grid', array('_current'=>true)); + } + + protected function getMailTypeOptions() + { + return array('abandoned cart'=>'abandoned cart','happy birthday'=>'happy birthday','new order'=>'new order', 'related products'=>'related products', 'product review'=>'product review', 'no activity'=>'no activity', 'wishlist'=>'wishlist'); + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedorder/Grid.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedorder/Grid.php index 4700c8d..be4fd8e 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedorder/Grid.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Abandonedorder/Grid.php @@ -37,8 +37,9 @@ protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $this->setCollection($collection); - $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag'); - $collection->addFieldToFilter('sales_flat_quote.ebizmarts_abandonedcart_flag',array('eq' => 1)); + $sales_flat_order_table = Mage::getSingleton('core/resource')->getTableName('sales_flat_order'); + $collection->getSelect()->join($sales_flat_order_table , 'main_table.increment_id = '.$sales_flat_order_table.'.increment_id', 'ebizmarts_abandonedcart_flag'); + $collection->addFieldToFilter($sales_flat_order_table.'.ebizmarts_abandonedcart_flag',array('eq' => 1)); return parent::_prepareCollection(); } @@ -59,6 +60,7 @@ protected function _prepareColumns() $this->addColumn('store_id', array( 'header' => Mage::helper('sales')->__('Purchased From (Store)'), 'index' => 'store_id', + 'filter_index' => 'main_table.store_id', 'type' => 'store', 'store_view'=> true, 'display_deleted' => true, diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Sales.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Sales.php index fd9d215..93b0e6d 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Sales.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Sales.php @@ -31,9 +31,8 @@ protected function _prepareLayout() $collection = Mage::getResourceModel('ebizmarts_abandonedcart/order_collection') ->calculateSales($isFilter); - $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag'); - $collection->addFieldToFilter('sales_flat_quote.ebizmarts_abandonedcart_flag',array('eq' => 1)); - +// $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag'); + $collection->addFieldToFilter('main_table.ebizmarts_abandonedcart_flag',array('eq' => 1)); if ($this->getRequest()->getParam('store')) { diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Totals.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Totals.php index 0c78dd7..1cb3585 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Totals.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/Dashboard/Totals.php @@ -30,8 +30,8 @@ protected function _prepareLayout() $collection = Mage::getResourceModel('ebizmarts_abandonedcart/order_collection') ->addCreateAtPeriodFilter($period) ->calculateTotals($isFilter); - $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag'); - $collection->addFieldToFilter('sales_flat_quote.ebizmarts_abandonedcart_flag',array('eq' => 1)); +// $collection->getSelect()->join('sales_flat_quote' , 'main_table.increment_id = sales_flat_quote.reserved_order_id', 'ebizmarts_abandonedcart_flag'); + $collection->addFieldToFilter('main_table.ebizmarts_abandonedcart_flag',array('eq' => 1)); @@ -111,14 +111,44 @@ protected function _prepareLayout() } // add totals for emails if($particular) { - $aux = $particular['sent'] - $particular['hard_bounces']; // - $particular['soft_bounces']; - $received = sprintf('%d (%2.2f%%)',$aux,$aux/$particular['sent']*100); - $this->addTotal($this->__('Emails Sent'),$particular['sent'],true); - $this->addTotal($this->__('Emails Received'),$received,true); - $opens = sprintf('%d (%2.2f%%)',$particular['unique_opens'],$particular['unique_opens']/$particular['sent']*100); + + $_sent = $particular['sent']; + $_hard_bounces = $particular['hard_bounces']; + $_unique_opens = $particular['unique_opens']; + $_unique_clicks = $particular['unique_clicks']; + + + //Emails Sent and Received + $aux = $_sent - $_hard_bounces; // - $particular['soft_bounces']; + if($aux > 0) { + $aux2 = $aux/ $_sent*100; + }else{ + $aux2 = 0; + } + $received = sprintf('%d (%2.2f%%)', $aux, $aux2); + + $this->addTotal($this->__('Emails Sent'), $_sent,true); + $this->addTotal($this->__('Emails Received'), $received,true); + + //Emails Opened + if($_unique_opens > 0) { + $emailsOpened = $_unique_opens / $_sent*100; + }else{ + $emailsOpened = 0; + } + + $opens = sprintf('%d (%2.2f%%)', $_unique_opens, $emailsOpened); $this->addTotal($this->__('Emails Opened'),$opens,true); - $clicks = sprintf('%d (%2.2f%%)',$particular['unique_clicks'],$particular['unique_clicks']/$particular['unique_opens']*100); - $this->addTotal($this->__('Emails Clicked'),$clicks,true); + + //Emails Clicked + if($_unique_clicks > 0){ + $emailsClicked = $_unique_clicks / $_unique_opens*100; + }else{ + $emailsClicked = 0; + } + + $clicks = sprintf('%d (%2.2f%%)', $_unique_clicks, $emailsClicked); + $this->addTotal($this->__('Emails Clicked'), $clicks,true); } } } @@ -132,8 +162,8 @@ private function __getMandrillStatistics($period,$store) { $mandrill = Mage::helper('mandrill')->api(); $mandrill->setApiKey(Mage::helper('mandrill')->getApiKey($store)); - - $tags = $mandrill->tagsInfo('AbandonedCart'); + $mandrillTag = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MANDRILL_TAG, $store)."_$store"; + $tags = $mandrill->tagsInfo($mandrillTag); if(!$tags) { return false; } diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/System/Config/Date.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/System/Config/Date.php new file mode 100644 index 0000000..ec5ff67 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Adminhtml/System/Config/Date.php @@ -0,0 +1,16 @@ +setFormat(Varien_Date::DATE_INTERNAL_FORMAT); + $element->setImage($this->getSkinUrl('images/grid-cal.gif')); + return parent::render($element); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Oder/Items.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Oder/Items.php deleted file mode 100644 index 1b64f19..0000000 --- a/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Oder/Items.php +++ /dev/null @@ -1,6 +0,0 @@ -getItem()->getOrder(); - } - - public function getItemOptions() - { - $result = array(); - if ($options = $this->getItem()->getProductOptions()) { - if (isset($options['options'])) { - $result = array_merge($result, $options['options']); - } - if (isset($options['additional_options'])) { - $result = array_merge($result, $options['additional_options']); - } - if (isset($options['attributes_info'])) { - $result = array_merge($result, $options['attributes_info']); - } - } - - return $result; - } - - public function getValueHtml($value) - { - if (is_array($value)) { - return sprintf('%d', $value['qty']) . ' x ' . $this->escapeHtml($value['title']) . " " . $this->getItem()->getOrder()->formatPrice($value['price']); - } else { - return $this->escapeHtml($value); - } - } - - public function getSku($item) - { - if ($item->getProductOptionByCode('simple_sku')) - return $item->getProductOptionByCode('simple_sku'); - else - return $item->getSku(); - } - - /** - * Return product additional information block - * - * @return Mage_Core_Block_Abstract - */ - public function getProductAdditionalInformationBlock() - { - return $this->getLayout()->getBlock('additional.product.info'); - } -} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Oder/Items/Order/Grouped.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Oder/Items/Order/Grouped.php deleted file mode 100644 index 4f12bcf..0000000 --- a/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Oder/Items/Order/Grouped.php +++ /dev/null @@ -1,26 +0,0 @@ -getItem()->getOrderItem()) { - $item = $this->getItem()->getOrderItem(); - } else { - $item = $this->getItem(); - } - if ($productType = $item->getRealProductType()) { - $renderer = $this->getRenderedBlock()->getItemRenderer($productType); - $renderer->setItem($this->getItem()); - return $renderer->toHtml(); - } - return parent::_toHtml(); - } -} diff --git a/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Order/Items.php b/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Order/Items.php new file mode 100644 index 0000000..b4e4327 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Order/Items.php @@ -0,0 +1,22 @@ +setTemplate('ebizmarts_abandonedcart/email_order_items.phtml'); + } + + public function getTax($_item) + { + if (Mage::helper('tax')->displayCartPriceInclTax()){ + $subtotal = Mage::helper('tax')->__('Incl. Tax') . ' : ' .Mage::helper('checkout')->formatPrice($_item['row_total_incl_tax']); + } elseif(Mage::helper('tax')->displayCartBothPrices()) { + $subtotal = Mage::helper('tax')->__('Excl. Tax') . ' : ' . Mage::helper('checkout')->formatPrice($_item['row_total']) . '
'. Mage::helper('tax')->__('Incl. Tax') . ' : ' . Mage::helper('checkout')->formatPrice($_item['row_total_incl_tax']); + } else { + $subtotal = Mage::helper('tax')->__('Excl. Tax') . ' : ' . Mage::helper('checkout')->formatPrice($_item['row_total']); + } + return $subtotal; + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Helper/Data.php b/app/code/community/Ebizmarts/AbandonedCart/Helper/Data.php index f1b5ca4..4a32ce1 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Helper/Data.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Helper/Data.php @@ -25,5 +25,40 @@ public function getDatePeriods() 'lifetime' => $this->__('Lifetime'), ); } - + public function log($message) + { + if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::LOG)) { + Mage::log($message); + } + } + public function saveMail($mailType,$mail,$name,$couponCode,$storeId) + { + if($couponCode!='') { + $coupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code'); + $rule = Mage::getModel('salesrule/rule')->load($coupon->getRuleId()); + $couponAmount = $rule->getDiscountAmount(); + switch($rule->getSimpleAction()) { + case 'cart_fixed': + $couponType = 1; + break; + case 'by_percent': + $couponType = 2; + break; + } + } + else { + $couponType = 0; + $couponAmount = 0; + } + $sent = Mage::getModel('ebizmarts_abandonedcart/mailssent'); + $sent->setMailType($mailType) + ->setStoreId($storeId) + ->setCustomerEmail($mail) + ->setCustomerName($name) + ->setCouponNumber($couponCode) + ->setCouponType($couponType) + ->setCouponAmount($couponAmount) + ->setSentAt(Mage::getModel('core/date')->gmtDate()) + ->save(); + } } \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/Config.php b/app/code/community/Ebizmarts/AbandonedCart/Model/Config.php new file mode 100644 index 0000000..52460b3 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Config.php @@ -0,0 +1,36 @@ +getStores(); foreach($allStores as $storeid => $val) { - $this->_proccess($storeid); + if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE,$storeid)) { + $this->_proccess($storeid); + } } } @@ -21,71 +23,148 @@ public function abandoned() */ protected function _proccess($store) { - - Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); + Mage::app()->setCurrentStore($store); $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); - $days = Mage::getStoreConfig("ebizmarts_abandonedcart/general/days", $store); - $maxtimes = Mage::getStoreConfig("ebizmarts_abandonedcart/general/max", $store); - $sendcoupondays = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/sendon", $store); - $sendcoupon = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/create", $store); + $days = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::DAYS, $store); + $maxtimes = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MAXTIMES, $store); + $sendcoupondays = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_DAYS, $store); + $sendcoupon = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::SEND_COUPON, $store); + $firstdate = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::FIRST_DATE, $store); + $unit = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::UNIT, $store); + $customergroups = explode(",",Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::CUSTOMER_GROUPS, $store)); + $mailsubject = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::SUBJECT, $store); + $mandrillTag = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MANDRILL_TAG, $store)."_$store"; if(!$days) { return; } - $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); - $from = new Zend_Db_Expr($expr); + if($unit == Ebizmarts_AbandonedCart_Model_Config::IN_DAYS) { + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + + // get a collection of abandoned carts + $collection = Mage::getResourceModel('reports/quote_collection'); + $collection->addFieldToFilter('items_count', array('neq' => '0')) + ->addFieldToFilter('main_table.is_active', '1') + ->addFieldToFilter('main_table.store_id',array('eq'=>$store)) + ->addSubtotal($store) + ->setOrder('updated_at'); + + $collection->addFieldToFilter('main_table.converted_at', array(array('null'=>true),$this->_getSuggestedZeroDate())) + ->addFieldToFilter('main_table.updated_at', array('to' => $from,'from' => $firstdate)) + ->addFieldToFilter('main_table.ebizmarts_abandonedcart_counter',array('lt' => $maxtimes)); + + $collection->addFieldToFilter('main_table.customer_email', array('neq' => '')); + if(count($customergroups)) { + $collection->addFieldToFilter('main_table.customer_group_id', array('in', $customergroups)); + } + } else { + // make the collection for first run + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'HOUR')); + $from = new Zend_Db_Expr($expr); + + // get a collection of abandoned carts + $collection1 = Mage::getResourceModel('reports/quote_collection'); + $collection1->addFieldToFilter('items_count', array('neq' => '0')) + ->addFieldToFilter('main_table.is_active', '1') + ->addFieldToFilter('main_table.store_id',array('eq'=>$store)) + ->addSubtotal($store) + ->setOrder('updated_at'); + + + $collection1->addFieldToFilter('main_table.converted_at', array(array('null'=>true),$this->_getSuggestedZeroDate())) + ->addFieldToFilter('main_table.updated_at', array('to' => $from,'from' => $firstdate)) + ->addFieldToFilter('main_table.ebizmarts_abandonedcart_counter',array('eq' => 0)); + + $collection1->addFieldToFilter('main_table.customer_email', array('neq' => '')); + if(count($customergroups)) { + $collection1->addFieldToFilter('main_table.customer_group_id', array('in', $customergroups)); + } - // get a collection of abandoned carts - $collection = Mage::getResourceModel('reports/quote_collection'); - // $collection->prepareForAbandonedReport($store); - $collection->addFieldToFilter('items_count', array('neq' => '0')) - ->addFieldToFilter('main_table.is_active', '1') - ->addSubtotal($store) - ->setOrder('updated_at'); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql(1, 'DAY')); + $from = new Zend_Db_Expr($expr); + // get a collection of abandoned carts who aren't the first run + $collection2 = Mage::getResourceModel('reports/quote_collection'); + $collection2->addFieldToFilter('items_count', array('neq' => '0')) + ->addFieldToFilter('main_table.is_active', '1') + ->addFieldToFilter('main_table.store_id',array('eq'=>$store)) + ->addSubtotal($store) + ->setOrder('updated_at'); - $collection->addFieldToFilter('main_table.converted_at', array(array('null'=>true),$this->_getSuggestedZeroDate())) - ->addFieldToFilter('main_table.updated_at', array('to' => $from)) - ->addFieldToFilter('main_table.ebizmarts_abandonedcart_counter',array('lt' => $maxtimes)); + $collection2->addFieldToFilter('main_table.converted_at', array(array('null'=>true),$this->_getSuggestedZeroDate())) + ->addFieldToFilter('main_table.updated_at', array('to' => $from,'from' => $firstdate)) + ->addFieldToFilter('main_table.ebizmarts_abandonedcart_counter',array('from' => 1,'to' => $maxtimes-1)); - $collection->addFieldToFilter('main_table.customer_email', array('neq' => '')); -// Mage::log((string)$collection->getSelect()); + $collection2->addFieldToFilter('main_table.customer_email', array('neq' => '')); + if(count($customergroups)) { + $collection2->addFieldToFilter('main_table.customer_group_id', array('in', $customergroups)); + } + Mage::helper('ebizmarts_abandonedcart')->log((string)$collection1->getSelect()); + Mage::helper('ebizmarts_abandonedcart')->log((string)$collection2->getSelect()); + $collection = $collection1; + foreach($collection2 as $quote) { + $collection->addItem($quote); + } + } // for each cart foreach($collection as $quote) { - $url = Mage::getBaseUrl('web').'ebizmarts_abandonedcart/abandoned/loadquote?id='.$quote->getEntityId(); + // check if they are any order from the customer with date >= + $collection2 = Mage::getResourceModel('reports/quote_collection'); + $collection2->addFieldToFilter('main_table.is_active', '0') + ->addFieldToFilter('main_table.reserved_order_id',array('neq' => 'NULL' )) + ->addFieldToFilter('main_table.customer_email',array('eq' => $quote->getCustomerEmail())) + ->addFieldToFilter('main_table.updated_at',array('from'=>$quote->getUpdatedAt())); + if($collection2->getSize()) { + continue; + } + // + //$url = Mage::getBaseUrl('web').'ebizmarts_abandonedcart/abandoned/loadquote?id='.$quote->getEntityId(); + srand((double)microtime()*1000000); + $token = md5(rand(0,9999999)); + $url = Mage::getModel('core/url')->setStore($store)->getUrl('',array('_nosid'=>true)).'ebizmarts_abandonedcart/abandoned/loadquote?id='.$quote->getEntityId().'&token='.$token; $data = array('AbandonedURL'=>$url, 'AbandonedDate' => $quote->getUpdatedAt()); // send email - $mailsubject = 'Abandoned Cart'; - $senderid = Mage::getStoreConfig("ebizmarts_abandonedcart/general/identity", $store); - $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderid/name"), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderid/email")); + $senderid = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::SENDER, $store); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderid/name",$store), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderid/email",$store)); $email = $quote->getCustomerEmail(); + if($this->_isSubscribed($email,'abandonedcart',$store)) { + $name = $quote->getCustomerFirstname().' '.$quote->getCustomerLastname(); + $quote2 = Mage::getModel('sales/quote')->loadByIdWithoutStore($quote->getId()); + $unsubscribeUrl = Mage::getModel('core/url')->setStore($store)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=abandonedcart&email='.$email.'&store='.$store; + $couponcode = ''; + if($sendcoupon && $quote2->getEbizmartsAbandonedcartCounter() + 1 == $sendcoupondays) + { + $templateId = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::EMAIL_TEMPLATE_XML_PATH); + // create a new coupon + if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_AUTOMATIC)==2) { + list($couponcode,$discount,$toDate) = $this->_createNewCoupon($store,$email); + $vars = array('quote'=>$quote,'url'=>$url, 'couponcode'=>$couponcode,'discount' => $discount, + 'todate' => $toDate, 'name' => $name,'tags'=>array($mandrillTag),'unsubscribeurl'=>$unsubscribeUrl); + } + else { + $couponcode = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_CODE); + $vars = array('quote'=>$quote,'url'=>$url, 'couponcode'=>$couponcode, 'name' => $name,'tags'=>array($mandrillTag),'unsubscribeurl'=>$unsubscribeUrl); + } + } + else { + $templateId = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::EMAIL_TEMPLATE_XML_PATH); + $vars = array('quote'=>$quote,'url'=>$url,'unsubscribeurl'=>$unsubscribeUrl,'tags'=>array($mandrillTag)); - $name = $quote->getCustomerFirstname().' '.$quote->getCustomerLastname(); - $quote2 = Mage::getModel('sales/quote')->loadByIdWithoutStore($quote->getId()); - if($sendcoupon && $quote2->getEbizmartsAbandonedcartCounter() + 1 == $sendcoupondays) - { - // create a new coupon - list($couponcode,$discount,$toDate) = $this->_createNewCoupon($store,$email); -// $templateId = Mage::getStoreConfig(self::EMAIL_TEMPLATE_XML_PATH_W_COUPON); - $templateId = Mage::getStoreConfig(self::EMAIL_TEMPLATE_XML_PATH); - $vars = array('quote'=>$quote,'url'=>$url, 'couponcode'=>$couponcode,'discount' => $discount, 'todate' => $toDate); - } - else { - $templateId = Mage::getStoreConfig(self::EMAIL_TEMPLATE_XML_PATH); - $vars = array('quote'=>$quote,'url'=>$url); - + } + $translate = Mage::getSingleton('core/translate'); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailsubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$store); + $translate->setTranslateInLine(true); + $quote2->setEbizmartsAbandonedcartCounter($quote2->getEbizmartsAbandonedcartCounter()+1); + $quote2->setEbizmartsAbandonedcartToken($token); + $quote2->save(); + Mage::helper('ebizmarts_abandonedcart')->saveMail('abandoned cart',$email,$name,$couponcode,$store); } - $translate = Mage::getSingleton('core/translate'); - Mage::log("sending mail to $name $email"); - Mage::getModel('core/email_template')->setTemplateSubject($mailsubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$store); - $translate->setTranslateInLine(true); - $quote2->setEbizmartsAbandonedcartCounter($quote2->getEbizmartsAbandonedcartCounter()+1); - $quote2->save(); } } @@ -97,11 +176,12 @@ protected function _proccess($store) */ protected function _createNewCoupon($store,$email) { - $couponamount = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/discount", $store); - $couponexpiredays = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/expire", $store); - $coupontype = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/discounttype", $store); - $couponlength = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/length", $store); - $couponlabel = Mage::getStoreConfig("ebizmarts_abandonedcart/coupon/couponlabel", $store); + $couponamount = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_AMOUNT, $store); + $couponexpiredays = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_EXPIRE, $store); + $coupontype = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_TYPE, $store); + $couponlength = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_LENGTH, $store); + $couponlabel = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_LABEL, $store); + $websiteid = Mage::getModel('core/store')->load($store)->getWebsiteId(); $fromDate = date("Y-m-d"); $toDate = date('Y-m-d', strtotime($fromDate. " + $couponexpiredays day")); @@ -113,7 +193,12 @@ protected function _createNewCoupon($store,$email) $action = 'by_percent'; $discount = "$couponamount%"; } - + $customer_group = new Mage_Customer_Model_Group(); + $allGroups = $customer_group->getCollection()->toOptionHash(); + $groups = array(); + foreach($allGroups as $groupid=>$name) { + $groups[] = $groupid; + } $coupon_rule = Mage::getModel('salesrule/rule'); $coupon_rule->setName("Abandoned coupon $email") ->setDescription("Abandoned coupon $email") @@ -123,7 +208,7 @@ protected function _createNewCoupon($store,$email) ->setCouponType(2) ->setUsesPerCoupon(1) ->setUsesPerCustomer(1) - ->setCustomerGroupIds(array(0,1)) + ->setCustomerGroupIds($groups) ->setProductIds('') ->setLengthMin($couponlength) ->setLengthMax($couponlength) @@ -131,13 +216,13 @@ protected function _createNewCoupon($store,$email) ->setStoreLabels(array($couponlabel)) ->setSimpleAction($action) ->setDiscountAmount($couponamount) - ->setDiscountQty(1) + ->setDiscountQty(0) ->setDiscountStep('0') ->setSimpleFreeShipping('0') ->setApplyToShipping('0') ->setIsRss(0) - ->setWebsiteIds($store); - $uniqueId = $coupon_rule->getCouponCodeGenerator()->generateCode(); + ->setWebsiteIds($websiteid); + $uniqueId = Mage::getSingleton('salesrule/coupon_codegenerator', array('length' => $couponlength))->generateCode(); $coupon_rule->setCouponCode($uniqueId); $coupon_rule->save(); return array($uniqueId,$discount,$toDate); @@ -160,5 +245,12 @@ function _getSuggestedZeroDate() { return '0000-00-00 00:00:00'; } - + protected function _isSubscribed($email,$list,$storeId) + { + $collection = Mage::getModel('ebizmarts_autoresponder/unsubscribe')->getCollection(); + $collection->addFieldtoFilter('main_table.email',array('eq'=>$email)) + ->addFieldtoFilter('main_table.list',array('eq'=>$list)) + ->addFieldtoFilter('main_table.store_id',array('eq'=>$storeId)); + return $collection->getSize() == 0; + } } diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/EventObserver.php b/app/code/community/Ebizmarts/AbandonedCart/Model/EventObserver.php new file mode 100644 index 0000000..7f3cd2a --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/EventObserver.php @@ -0,0 +1,21 @@ + + * Date : 8/21/13 + * Time : 1:50 AM + * File : EventObserver.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Model_EventObserver +{ + public function saveConfig(Varien_Event_Observer $o) + { + $store = is_null($o->getEvent()->getStore()) ? 'default': $o->getEvent()->getStore(); + if(!Mage::helper('mandrill')->useTransactionalService()) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/Mailssent.php b/app/code/community/Ebizmarts/AbandonedCart/Model/Mailssent.php new file mode 100644 index 0000000..277aa95 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Mailssent.php @@ -0,0 +1,15 @@ + + * Date : 7/15/13 + * Time : 1:21 PM + * File : MailsSent.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Model_Mailssent extends Mage_Core_Model_Abstract +{ + public function _construct() { + $this->_init('ebizmarts_abandonedcart/mailssent'); + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Mailssent.php b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Mailssent.php new file mode 100644 index 0000000..69eac35 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Mailssent.php @@ -0,0 +1,16 @@ + + * Date : 7/15/13 + * Time : 1:24 PM + * File : MailsSent.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Model_Resource_Mailssent extends Mage_Core_Model_Mysql4_Abstract +{ + public function _construct() + { + $this->_init('ebizmarts_abandonedcart/mailssent','id'); + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Mailssent/Collection.php b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Mailssent/Collection.php new file mode 100644 index 0000000..35126cd --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Mailssent/Collection.php @@ -0,0 +1,16 @@ + + * Date : 7/15/13 + * Time : 1:26 PM + * File : Collection.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Model_Resource_Mailssent_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + protected function _construct() + { + $this->_init('ebizmarts_abandonedcart/mailssent'); + } +} + diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Order/Collection.php b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Order/Collection.php index 7cd0cf6..4ebeddb 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Order/Collection.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Order/Collection.php @@ -6,8 +6,13 @@ * Time: 3:26 PM */ -class Ebizmarts_AbandonedCart_Model_Resource_Order_Collection extends Mage_Reports_Model_Resource_Order_Collection +class Ebizmarts_AbandonedCart_Model_Resource_Order_Collection extends Mage_Reports_Model_Mysql4_Order_Collection { + public function isLive() + { + return true; + } + /** * @param string $period * @return Ebizmarts_AbandonedCart_Model_Resource_Order_Collection|Mage_Reports_Model_Resource_Order_Collection @@ -46,7 +51,7 @@ public function calculateSales($isFilter = 0) } $adapter = $this->getConnection(); - if (Mage::getStoreConfig('sales/dashboard/use_aggregated_data')) { + if (Mage::getStoreConfig('sales/dashboard/use_aggregated_data')==8) { $this->setMainTable('sales/order_aggregated_created'); $this->removeAllFieldsFromSelect(); $averageExpr = $adapter->getCheckSql( @@ -67,15 +72,21 @@ public function calculateSales($isFilter = 0) } else { $this->setMainTable('sales/order'); $this->removeAllFieldsFromSelect(); - - $expr = sprintf('%s - %s - %s - (%s - %s - %s)', - $adapter->getIfNullSql('main_table.base_total_invoiced', 0), - $adapter->getIfNullSql('main_table.base_tax_invoiced', 0), - $adapter->getIfNullSql('main_table.base_shipping_invoiced', 0), - $adapter->getIfNullSql('main_table.base_total_refunded', 0), - $adapter->getIfNullSql('main_table.base_tax_refunded', 0), - $adapter->getIfNullSql('main_table.base_shipping_refunded', 0) - ); + if(version_compare(Mage::getVersion(), '1.6.0.0')==1) { + $expr = 'IFNULL(main_table.base_subtotal, 0) - IFNULL(main_table.base_subtotal_refunded, 0)' + . ' - IFNULL(main_table.base_subtotal_canceled, 0) - ABS(IFNULL(main_table.base_discount_amount, 0))' + . ' + IFNULL(main_table.base_discount_refunded, 0)'; + } + else { + $expr = sprintf('%s - %s - %s - (%s - %s - %s)', + $adapter->getIfNullSql('main_table.base_total_invoiced', 0), + $adapter->getIfNullSql('main_table.base_tax_invoiced', 0), + $adapter->getIfNullSql('main_table.base_shipping_invoiced', 0), + $adapter->getIfNullSql('main_table.base_total_refunded', 0), + $adapter->getIfNullSql('main_table.base_tax_refunded', 0), + $adapter->getIfNullSql('main_table.base_shipping_refunded', 0) + ); + } if ($isFilter == 0) { $expr = '(' . $expr . ') * main_table.base_to_global_rate'; diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Automatic.php b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Automatic.php new file mode 100644 index 0000000..657f5db --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Automatic.php @@ -0,0 +1,21 @@ + 1, 'label' => Mage::helper('ebizmarts_abandonedcart')->__('Specific')), + array('value'=> 2, 'label' => Mage::helper('ebizmarts_abandonedcart')->__('Automatic')) + ); + return $options; + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Cmspage.php b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Cmspage.php new file mode 100644 index 0000000..0cd833a --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Cmspage.php @@ -0,0 +1,18 @@ + + * Date : 8/13/13 + * Time : 2:00 PM + * File : Cmspage.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Model_System_Config_Cmspage +{ + + public function toOptionArray() + { + $collection = Mage::getModel('cms/page')->getCollection()->addOrder('title', 'asc'); + return array('checkout/cart'=> "Shopping Cart (default page)") + $collection->toOptionIdArray(); + } + +} diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Customergroup.php b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Customergroup.php new file mode 100644 index 0000000..e1766f9 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Customergroup.php @@ -0,0 +1,21 @@ + + * Date : 5/3/13 + * Time : 12:47 PM + * File : Customergroup.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Model_System_Config_Customergroup +{ + protected $_options; + + public function toOptionArray() + { + if (!$this->_options) { + $this->_options = Mage::getResourceModel('customer/group_collection') + ->loadData()->toOptionArray(); + } + return $this->_options; + } +} diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Discounttype.php b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Discounttype.php index dcf301f..645c10e 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Discounttype.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Discounttype.php @@ -13,4 +13,10 @@ public function toOptionArray() ); return $options; } + public function options() + { + $options[1] = Mage::helper('ebizmarts_abandonedcart')->__('Fixed amount'); + $options[2] = Mage::helper('ebizmarts_abandonedcart')->__('Percentage'); + return $options; + } } \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Unit.php b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Unit.php new file mode 100644 index 0000000..dfcdca7 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/System/Config/Unit.php @@ -0,0 +1,19 @@ + Ebizmarts_AbandonedCart_Model_Config::IN_DAYS, 'label' => Mage::helper('ebizmarts_abandonedcart')->__('Days')), + array('value'=> Ebizmarts_AbandonedCart_Model_Config::IN_HOURS, 'label' => Mage::helper('ebizmarts_abandonedcart')->__('Hours')) + ); + return $options; + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/controllers/AbandonedController.php b/app/code/community/Ebizmarts/AbandonedCart/controllers/AbandonedController.php index 147d58b..eae40c0 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/controllers/AbandonedController.php +++ b/app/code/community/Ebizmarts/AbandonedCart/controllers/AbandonedController.php @@ -13,13 +13,42 @@ public function loadquoteAction() if(isset($params['id'])) { //restore the quote - Mage::log($params['id']); +// Mage::log($params['id']); $quote = Mage::getModel('sales/quote')->load($params['id']); - $quote->setEbizmartsAbandonedcartFlag(1); - $quote->save(); - $this->_getSession()->setQuoteId($quote->getId()); + if(!isset($params['token']) || (isset($params['token'])&&$params['token']!=$quote->getEbizmartsAbandonedcartToken())) { + Mage::getSingleton('customer/session')->addNotice("Your token cart is incorrect"); + $this->_redirect('/'); + } + else { + $url = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::PAGE,$quote->getStoreId()); + $quote->setEbizmartsAbandonedcartFlag(1); + $quote->save(); + if(!$quote->getCustomerId()) { + $this->_getSession()->setQuoteId($quote->getId()); + $this->_redirect($url); + } + else { + if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AUTOLOGIN,$quote->getStoreId())) { + $customer = Mage::getModel('customer/customer')->load($quote->getCustomerId()); + if($customer->getId()) + { + Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); + } + $this->_redirect($url); + } + else { + if(Mage::helper('customer')->isLoggedIn()) { + $this->_redirect($url); + } + else { + Mage::getSingleton('customer/session')->addNotice("Login to complete your order"); + $this->_redirect('customer/account'); + } + } + } + } } - $this->_redirect('checkout/cart'); +// $this->_redirect('checkout/cart'); } } \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/controllers/Adminhtml/AbandonedmailsController.php b/app/code/community/Ebizmarts/AbandonedCart/controllers/Adminhtml/AbandonedmailsController.php new file mode 100644 index 0000000..62521f2 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/controllers/Adminhtml/AbandonedmailsController.php @@ -0,0 +1,68 @@ + + * Date : 5/7/13 + * Time : 11:33 PM + * File : AbandonedmailsController.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_AbandonedCart_Adminhtml_AbandonedmailsController extends Mage_Adminhtml_Controller_Action +{ + /** + * + */ + public function indexAction() + { + // Let's call our initAction method which will set some basic params for each action + $this->_initAction() + ->renderLayout(); + } + + /** + * @return Ebizmarts_AbandonedCart_Adminhtml_AbandonedorderController + */ + protected function _initAction() + { + $this->loadLayout() + // Make the active menu match the menu config nodes (without 'children' inbetween) + ->_setActiveMenu('newsletter/ebizmarts_emails') + ->_title($this->__('Newsletter'))->_title($this->__('Emails Sent')) + ->_addBreadcrumb($this->__('Newsletter'), $this->__('Newsletter')) + ->_addBreadcrumb($this->__('abandonedorder'), $this->__('Mails')); + + return $this; + } + + /** + * + */ + public function exportCsvAction() + { + $fileName = 'orders.csv'; + $grid = $this->getLayout()->createBlock('ebizmarts_abandonedcart/adminhtml_abandonedmails_grid'); + $this->_prepareDownloadResponse($fileName, $grid->getCsvFile()); + } + + /** + * Export order grid to Excel XML format + */ + public function exportExcelAction() + { + $fileName = 'orders.xml'; + $grid = $this->getLayout()->createBlock('ebizmarts_abandonedcart/adminhtml_abandonedmails_grid'); + $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName)); + } + + /** + * + */ + public function gridAction() + { + $this->loadLayout(false); + $this->renderLayout(); + } + + /** + * + */ +} diff --git a/app/code/community/Ebizmarts/AbandonedCart/etc/adminhtml.xml b/app/code/community/Ebizmarts/AbandonedCart/etc/adminhtml.xml index f525c18..a9945aa 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/etc/adminhtml.xml +++ b/app/code/community/Ebizmarts/AbandonedCart/etc/adminhtml.xml @@ -10,6 +10,19 @@ + + + + + + Emails Sent + 810 + adminhtml/abandonedmails/index + + + + + @@ -34,6 +47,9 @@ Ebizmarts Abandoned Cart + + Ebizmarts Emails + diff --git a/app/code/community/Ebizmarts/AbandonedCart/etc/config.xml b/app/code/community/Ebizmarts/AbandonedCart/etc/config.xml index 678fae6..41d7249 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/etc/config.xml +++ b/app/code/community/Ebizmarts/AbandonedCart/etc/config.xml @@ -2,7 +2,7 @@ - 0.1.5 + 0.1.24 @@ -10,17 +10,14 @@ - AbandonedCart sales/abandoned_cart.html html - + + AbandonedCart + Ebizmarts_AbandonedCart_Model @@ -28,6 +25,12 @@ Ebizmarts_AbandonedCart_Model_Resource + ebizmarts_abandonedcart_mysql4 + + + magemonkey_mails_sent
+
+
@@ -47,6 +50,13 @@ + + + + * + + +
@@ -69,6 +79,25 @@ + + + + + Ebizmarts_AbandonedCart.csv + + + + + + + + + ebizmarts_abandonedcart/eventObserver + saveConfig + + + + @@ -84,7 +113,7 @@ - ebizmarts_abandonedcart.xml + ebizmarts/abandonedcart.xml @@ -101,4 +130,14 @@ + + + + Abandoned Cart Email + AbandonedCart + 0 + checkout/cart + + +
\ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml b/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml index 388a01e..cecf945 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml +++ b/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml @@ -2,13 +2,20 @@ - - customer - 404 + + monkey + 300 1 1 1 + + ebizmarts_abandonedcart/adminhtml_system_config_fieldset_hint + 0 + 1 + 1 + 1 + 1 @@ -17,13 +24,6 @@ 1 1 - - ebizmarts_abandonedcart/adminhtml_system_config_fieldset_hint - 0 - 1 - 1 - 1 - select @@ -33,6 +33,32 @@ 1 1 + + + select + adminhtml/system_config_source_yesno + 11 + 1 + 1 + 1 + + 1 + + + + + date + ebizmarts_abandonedcart/adminhtml_system_config_date + 12 + 1 + 1 + 1 + + + 1 + + + select @@ -58,19 +84,44 @@ 1 - - - select - ebizmarts_abandonedcart/general/coupon_template - adminhtml/system_config_source_email_template + + + text 25 1 1 1 + 0 + + + 1 + + + + + select + ebizmarts_abandonedcart/general/page + ebizmarts_abandonedcart/system_config_cmspage + 26 + 1 + 1 + 1 + + + 1 + + + + + text + 27 + 1 + 1 + 1 1 - + text @@ -79,11 +130,25 @@ 1 1 0 - + 1 + + + select + ebizmarts_abandonedcart/system_config_unit + 35 + 1 + 1 + 1 + 0 + + + 1 + + text @@ -97,6 +162,33 @@ 1 + + + multiselect + ebizmarts_abandonedcart/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + select + adminhtml/system_config_source_yesno + 60 + 1 + 1 + 1 + + + 1 + + @@ -130,6 +222,32 @@ 1 + + + select + ebizmarts_abandonedcart/system_config_automatic + 115 + 1 + 1 + 1 + + 1 + + + + + text + 120 + 1 + 1 + 1 + 0 + + + 1 + 1 + + text @@ -141,6 +259,7 @@ 1 + 2 @@ -154,6 +273,7 @@ 1 + 2 @@ -168,6 +288,7 @@ 1 + 2 @@ -181,6 +302,7 @@ 1 + 2 @@ -194,6 +316,7 @@ 1 + 2 diff --git a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-install-0.1.0.php b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-install-0.1.0.php index a00c266..7f084a1 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-install-0.1.0.php +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-install-0.1.0.php @@ -3,10 +3,7 @@ $installer->startSetup(); -$installer->run(" - - ALTER TABLE `{$this->getTable('sales_flat_quote')}` - add column ebizmarts_abandonedcart_counter int(5) default '0' - "); - +$installer->getConnection()->addColumn( + $installer->getTable('sales_flat_quote'), 'ebizmarts_abandonedcart_counter', 'int(5)', null, array('default' => '0') +); $installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.12-0.1.13.php b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.12-0.1.13.php new file mode 100644 index 0000000..a8b954e --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.12-0.1.13.php @@ -0,0 +1,21 @@ + + * Date : 6/5/13 + * Time : 12:42 PM + * File : mysql4-upgrade-0.1.7-0.1.8.php + * Module : Ebizmarts_Magemonkey + */ +$installer = $this; + +$installer->startSetup(); + +$installer->run(" + + ALTER TABLE `{$this->getTable('sales_flat_quote')}` CHANGE `ebizmarts_abandonedcart_counter` `ebizmarts_abandonedcart_counter` INT( 5 ) NOT NULL DEFAULT '0'; + ALTER TABLE `{$this->getTable('sales_flat_quote')}` CHANGE `ebizmarts_abandonedcart_flag` `ebizmarts_abandonedcart_flag` INT( 5 ) NOT NULL DEFAULT '0'; + + +"); + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.18-0.1.19.php b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.18-0.1.19.php new file mode 100644 index 0000000..4421ff2 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.18-0.1.19.php @@ -0,0 +1,28 @@ + + * Date : 6/5/13 + * Time : 12:42 PM + * File : mysql4-upgrade-0.1.7-0.1.8.php + * Module : Ebizmarts_Magemonkey + */ +$installer = $this; + +$installer->startSetup(); + +$installer->run(" + CREATE TABLE IF NOT EXISTS `{$this->getTable('magemonkey_mails_sent')}` ( + `id` INT(10) unsigned NOT NULL auto_increment, + `store_id` smallint(5), + `mail_type` ENUM('abandoned cart','happy birthday','new order', 'related products', 'product review', 'no activity', 'wishlist') NOT NULL, + `customer_email` varchar(255), + `customer_name` varchar(255), + `coupon_number` varchar(255), + `coupon_type` smallint(2), + `coupon_amount` decimal(10,2), + `sent_at` DATETIME NOT NULL , + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +"); + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.2-0.1.3.php b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.2-0.1.3.php index 476642a..10230e9 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.2-0.1.3.php +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.2-0.1.3.php @@ -9,10 +9,8 @@ $installer->startSetup(); -$installer->run(" - - ALTER TABLE `{$this->getTable('sales_flat_quote')}` - add column ebizmarts_abandonedcart_flag int(1) default '0' - "); +$installer->getConnection()->addColumn( + $installer->getTable('sales_flat_quote'), 'ebizmarts_abandonedcart_flag', 'int(1)', null, array('default' => '0') +); $installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.20-0.1.21.php b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.20-0.1.21.php new file mode 100644 index 0000000..ea2ce93 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.20-0.1.21.php @@ -0,0 +1,17 @@ + + * Date : 7/31/13 + * Time : 1:56 PM + * File : mysql4-upgrade-0.1.20-0.1.21.php + * Module : Ebizmarts_Magemonkey + */ +$installer = $this; + +$installer->startSetup(); + +$installer->getConnection()->addColumn( + $installer->getTable('sales_flat_quote'), 'ebizmarts_abandonedcart_token', 'varchar(255)', null, array('default' => 'null') +); + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.6-0.1.7.php b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.6-0.1.7.php new file mode 100644 index 0000000..9861326 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.6-0.1.7.php @@ -0,0 +1,17 @@ +startSetup(); + +$installer->getConnection()->addColumn( + $installer->getTable('sales_flat_order'), 'ebizmarts_abandonedcart_flag', 'int(1)', null, array('default' => '0') +); + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Birthday/Fieldset/Hint.php b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Birthday/Fieldset/Hint.php new file mode 100644 index 0000000..ba0d3df --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Birthday/Fieldset/Hint.php @@ -0,0 +1,25 @@ + + * Date : 6/25/13 + * Time : 2:15 PM + * File : Hint.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Adminhtml_System_Config_Birthday_Fieldset_Hint + extends Mage_Adminhtml_Block_Abstract + implements Varien_Data_Form_Element_Renderer_Interface +{ + protected $_template = 'ebizmarts/autoresponder/system/config/birthday/fieldset/hint.phtml'; + + /** + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + return $this->toHtml(); + } + + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Fieldset/Hint.php b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Fieldset/Hint.php new file mode 100644 index 0000000..0dfdc38 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Fieldset/Hint.php @@ -0,0 +1,52 @@ +toHtml(); + } + + /** + * @return string + */ + public function getVersion() + { + return (string) Mage::getConfig()->getNode('modules/Ebizmarts_Autoresponder/version'); + } + + /** + * @return string + */ + public function getPxParams() { + $v = (string)Mage::getConfig()->getNode('modules/Ebizmarts_Autoresponder/version'); + $ext = "Abandoned Cart;{$v}"; + + $modulesArray = (array)Mage::getConfig()->getNode('modules')->children(); + $aux = (array_key_exists('Enterprise_Enterprise', $modulesArray))? 'EE' : 'CE' ; + $mageVersion = Mage::getVersion(); + $mage = "Magento {$aux};{$mageVersion}"; + + $hash = md5($ext . '_' . $mage . '_' . $ext); + + return "ext=$ext&mage={$mage}&ctrl={$hash}"; + + } + + /** + * @return mixed + */ + public function verify() + { + return Mage::helper('ebizmarts_autoresponder')->verify(); + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Review/Fieldset/Hint.php b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Review/Fieldset/Hint.php new file mode 100644 index 0000000..8e26227 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Review/Fieldset/Hint.php @@ -0,0 +1,25 @@ + + * Date : 6/28/13 + * Time : 2:35 PM + * File : Hint.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Adminhtml_System_Config_Review_Fieldset_Hint + extends Mage_Adminhtml_Block_Abstract + implements Varien_Data_Form_Element_Renderer_Interface +{ + protected $_template = 'ebizmarts/autoresponder/system/config/review/fieldset/hint.phtml'; + + /** + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + return $this->toHtml(); + } + + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Wishlist/Fieldset/Hint.php b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Wishlist/Fieldset/Hint.php new file mode 100644 index 0000000..90c9b87 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Adminhtml/System/Config/Wishlist/Fieldset/Hint.php @@ -0,0 +1,25 @@ + + * Date : 6/28/13 + * Time : 3:13 PM + * File : Hint.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Adminhtml_System_Config_Wishlist_Fieldset_Hint + extends Mage_Adminhtml_Block_Abstract + implements Varien_Data_Form_Element_Renderer_Interface +{ + protected $_template = 'ebizmarts/autoresponder/system/config/wishlist/fieldset/hint.phtml'; + + /** + * @param Varien_Data_Form_Element_Abstract $element + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + return $this->toHtml(); + } + + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Customer/Account/List.php b/app/code/community/Ebizmarts/Autoresponder/Block/Customer/Account/List.php new file mode 100644 index 0000000..7e6a953 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Customer/Account/List.php @@ -0,0 +1,20 @@ + + * Date : 6/26/13 + * Time : 1:02 PM + * File : List.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Customer_Account_List extends Mage_Core_Block_Template +{ + public function getLists() + { + return Mage::helper('ebizmarts_autoresponder')->getLists(); + } + public function getSaveUrl() + { + return $this->getUrl('ebizautoresponder/autoresponder/savelist'); + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Email/Related/Items.php b/app/code/community/Ebizmarts/Autoresponder/Block/Email/Related/Items.php new file mode 100644 index 0000000..5085b02 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Email/Related/Items.php @@ -0,0 +1,15 @@ + + * Date : 6/19/13 + * Time : 2:50 PM + * File : Items.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Email_Related_Items extends Mage_Sales_Block_Items_Abstract +{ + public function _construct() + { + $this->setTemplate('ebizmarts/autoresponder_related_items.phtml'); + } +} diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Email/Review/Items.php b/app/code/community/Ebizmarts/Autoresponder/Block/Email/Review/Items.php new file mode 100644 index 0000000..c39eefe --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Email/Review/Items.php @@ -0,0 +1,15 @@ + + * Date : 6/21/13 + * Time : 1:43 PM + * File : Items.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Email_Review_Items extends Mage_Sales_Block_Items_Abstract +{ + public function _construct() + { + $this->setTemplate('ebizmarts/autoresponder_review_items.phtml'); + } +} diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Email/Wishlist/Items.php b/app/code/community/Ebizmarts/Autoresponder/Block/Email/Wishlist/Items.php new file mode 100644 index 0000000..feb02fb --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Email/Wishlist/Items.php @@ -0,0 +1,15 @@ + + * Date : 6/24/13 + * Time : 4:37 PM + * File : Items.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Email_Wishlist_Items extends Mage_Sales_Block_Items_Abstract +{ + public function _construct() + { + $this->setTemplate('ebizmarts/autoresponder_wishlist_items.phtml'); + } +} diff --git a/app/code/community/Ebizmarts/Autoresponder/Block/Unsubscribe.php b/app/code/community/Ebizmarts/Autoresponder/Block/Unsubscribe.php new file mode 100644 index 0000000..eb70d48 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Block/Unsubscribe.php @@ -0,0 +1,15 @@ + + * Date : 6/26/13 + * Time : 8:55 AM + * File : Unsubscribe.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Block_Unsubscribe extends Mage_Core_Block_Template +{ + public function _construct() { + parent::_construct(); + $this->setTemplate('ebizmarts/autoresponder/unsubscribe.phtml'); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Helper/Data.php b/app/code/community/Ebizmarts/Autoresponder/Helper/Data.php new file mode 100644 index 0000000..69bfa77 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Helper/Data.php @@ -0,0 +1,41 @@ + + * Date : 4/28/13 + * Time : 11:20 AM + * File : Data.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Helper_Data extends Mage_Core_Helper_Abstract { + + public function getLists() + { + $types = array(); + $storeId = Mage::app()->getStore()->getStoreId(); + $lists = Mage::getConfig()->getNode('default/ebizmarts_autoresponder')->asArray(); + $lists['abandonedcart'] = array('listname'=>'Abandoned Carts List'); + foreach ($lists as $key =>$data) { + if(isset($data['listname'])) { + if(Mage::getStoreConfig("ebizmarts_autoresponder/$key/active",$storeId)||($key=='abandonedcart'&&Mage::getStoreConfig("ebizmarts_abandonedcart/general/active",$storeId))) { + $types[$key]['listname'] = (string)$data['listname']; + $collection = Mage::getModel('ebizmarts_autoresponder/unsubscribe')->getCollection(); + $email = $this->_getEmail(); + $collection->addFieldToFilter('main_table.email',array('eq'=>$email)) + ->addFieldToFilter('main_table.list',array('eq'=>$key)) + ->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)); + if($collection->getSize() > 0) { + $types[$key]['checked'] = ""; + } + else { + $types[$key]['checked'] = "checked"; + } + } + } + } + return $types; + } + protected function _getEmail() + { + return Mage::helper('customer')->getCustomer()->getEmail(); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Config.php b/app/code/community/Ebizmarts/Autoresponder/Model/Config.php new file mode 100644 index 0000000..9ec5b49 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Config.php @@ -0,0 +1,78 @@ + + * Date : 6/14/13 + * Time : 5:10 PM + * File : Config.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Config +{ + const GENERAL_ACTIVE = 'ebizmarts_autoresponder/general/active'; + const GENERAL_SENDER = 'ebizmarts_autoresponder/general/identity'; + + const NEWORDER_ACTIVE = 'ebizmarts_autoresponder/neworder/active'; + const NEWORDER_DAYS = 'ebizmarts_autoresponder/neworder/days'; + const NEWORDER_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/neworder/customer'; + const NEWORDER_TEMPLATE = 'ebizmarts_autoresponder/neworder/template'; + const NEWORDER_MANDRILL_TAG = 'ebizmarts_autoresponder/neworder/mandrill-tag'; + const NEWORDER_SUBJECT = 'ebizmarts_autoresponder/neworder/subject'; + + const RELATED_ACTIVE = 'ebizmarts_autoresponder/related/active'; + const RELATED_DAYS = 'ebizmarts_autoresponder/related/days'; + const RELATED_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/related/customer'; + const RELATED_TEMPLATE = 'ebizmarts_autoresponder/related/template'; + const RELATED_MANDRILL_TAG = 'ebizmarts_autoresponder/related/mandrill-tag'; + const RELATED_SUBJECT = 'ebizmarts_autoresponder/related/subject'; + const RELATED_MAX = 'ebizmarts_autoresponder/related/max-related'; + + const REVIEW_ACTIVE = 'ebizmarts_autoresponder/review/active'; + const REVIEW_DAYS = 'ebizmarts_autoresponder/review/days'; + const REVIEW_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/review/customer'; + const REVIEW_TEMPLATE = 'ebizmarts_autoresponder/review/template'; + const REVIEW_MANDRILL_TAG = 'ebizmarts_autoresponder/review/mandrill-tag'; + const REVIEW_SUBJECT = 'ebizmarts_autoresponder/review/subject'; + + const BIRTHDAY_ACTIVE = 'ebizmarts_autoresponder/birthday/active'; + const BIRTHDAY_DAYS = 'ebizmarts_autoresponder/birthday/days'; + const BIRTHDAY_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/birthday/customer'; + const BIRTHDAY_TEMPLATE = 'ebizmarts_autoresponder/birthday/template'; + const BIRTHDAY_SUBJECT = 'ebizmarts_autoresponder/birthday/subject'; + const BIRTHDAY_MANDRILL_TAG = 'ebizmarts_autoresponder/birthday/mandrill-tag'; + const BIRTHDAY_COUPON = 'ebizmarts_autoresponder/birthday/coupon'; + const BIRTHDAY_CUSTOMER_COUPON = 'ebizmarts_autoresponder/birthday/customer_coupon'; + const BIRTHDAY_AUTOMATIC = 'ebizmarts_autoresponder/birthday/automatic'; + const BIRTHDAY_COUPON_CODE = 'ebizmarts_autoresponder/birthday/coupon_code'; + const BIRTHDAY_EXPIRE = 'ebizmarts_autoresponder/birthday/expire'; + const BIRTHDAY_LENGTH = 'ebizmarts_autoresponder/birthday/length'; + const BIRTHDAY_DISCOUNT_TYPE = 'ebizmarts_autoresponder/birthday/discounttype'; + const BIRTHDAY_DISCOUNT = 'ebizmarts_autoresponder/birthday/discount'; + const BIRTHDAY_COUPON_LABEL = 'ebizmarts_autoresponder/birthday/couponlabel'; + + + const NOACTIVITY_ACTIVE = 'ebizmarts_autoresponder/noactivity/active'; + const NOACTIVITY_DAYS = 'ebizmarts_autoresponder/noactivity/days'; + const NOACTIVITY_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/noactivity/customer'; + const NOACTIVITY_TEMPLATE = 'ebizmarts_autoresponder/noactivity/template'; + const NOACTIVITY_MANDRILL_TAG = 'ebizmarts_autoresponder/noactivity/mandrill-tag'; + const NOACTIVITY_SUBJECT = 'ebizmarts_autoresponder/noactivity/subject'; + + const WISHLIST_ACTIVE = 'ebizmarts_autoresponder/wishlist/active'; + const WISHLIST_DAYS = 'ebizmarts_autoresponder/wishlist/days'; + const WISHLIST_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/wishlist/customer'; + const WISHLIST_TEMPLATE = 'ebizmarts_autoresponder/wishlist/template'; + const WISHLIST_MANDRILL_TAG = 'ebizmarts_autoresponder/wishlist/mandrill-tag'; + const WISHLIST_SUBJECT = 'ebizmarts_autoresponder/wishlist/subject'; + + const VISITED_ACTIVE = 'ebizmarts_autoresponder/visitedproducts/active'; + const VISITED_DAYS = 'ebizmarts_autoresponder/visitedproducts/days'; + const VISITED_TEMPLATE = 'ebizmarts_autoresponder/visitedproducts/template'; + const VISITED_MANDRILL_TAG = 'ebizmarts_autoresponder/visitedproducts/mandrill_tag'; + const VISITED_SUBJECT = 'ebizmarts_autoresponder/visitedproducts/subject'; + const VISITED_CUSTOMER_GROUPS = 'ebizmarts_autoresponder/visitedproducts/customer'; + const VISITED_TIME = 'ebizmarts_autoresponder/visitedproducts/time'; + const VISITED_MAX = 'ebizmarts_autoresponder/visitedproducts/max_visited'; + + const COUPON_AUTOMATIC = 2; + const COUPON_MANUAL = 1; +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Cron.php b/app/code/community/Ebizmarts/Autoresponder/Model/Cron.php new file mode 100644 index 0000000..a4fd421 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Cron.php @@ -0,0 +1,494 @@ + + * Date : 6/14/13 + * Time : 5:05 PM + * File : Cron.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Cron +{ + /** + * + */ + public function process() + { + $allStores = Mage::app()->getStores(); + foreach($allStores as $storeId => $val) + { + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_ACTIVE,$storeId)) { + $this->_processStore($storeId); + } + } + } + + /** + * @param $storeId + */ + protected function _processStore($storeId) + { + Mage::app()->setCurrentStore($storeId); + + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NEWORDER_ACTIVE,$storeId)) { // done + $this->_processNewOrders($storeId); + } + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_ACTIVE,$storeId)) { // done + $this->_processRelated($storeId); + } + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_ACTIVE,$storeId)) { // done + $this->_processReview($storeId); + } + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE,$storeId)) { // done + $this->_processBirthday($storeId); + } + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NOACTIVITY_ACTIVE,$storeId)) { // done + $this->_processNoActivity($storeId); + } + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_ACTIVE,$storeId)) { // done + $this->_processWishlist($storeId); + } + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_ACTIVE,$storeId)) { // done + $this->_processVisited($storeId); + } + } + protected function _processNewOrders($storeId) + { + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NEWORDER_CUSTOMER_GROUPS, $storeId)); + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NEWORDER_DAYS,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NEWORDER_MANDRILL_TAG,$storeId)."_$storeId"; + $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NEWORDER_SUBJECT,$storeId); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NEWORDER_TEMPLATE,$storeId); + + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days-1, 'DAY')); + $to = new Zend_Db_Expr($expr); + $collection = Mage::getResourceModel('sales/order_collection'); + $collection->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)) + ->addFieldToFilter('main_table.created_at',array('from'=>$from,'to'=>$to)); + if(count($customerGroups)) { + $collection->addFieldToFilter('main_table.customer_group_id',array('in'=> $customerGroups)); + } + foreach($collection as $order) { + $translate = Mage::getSingleton('core/translate'); + $email = $order->getCustomerEmail(); + if($this->_isSubscribed($email,'neworder',$storeId)) { + $name = $order->getCustomerFirstname().' '.$order->getCustomerLastname(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=neworder&email='.$email.'&store='.$storeId; + $vars = array('tags'=>array($tags),'url'=>$url); + + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('new order',$email,$name,"",$storeId); + } + } + } + protected function _processBirthday($storeId) + { + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_DAYS,$storeId); + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_CUSTOMER_GROUPS, $storeId)); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_TEMPLATE,$storeId); + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_SUBJECT,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_MANDRILL_TAG,$storeId)."_$storeId"; + $sendCoupon = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_COUPON,$storeId); + $customerGroupsCoupon = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_CUSTOMER_COUPON, $storeId)); + + + $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days-1, 'DAY')); + $to = new Zend_Db_Expr($expr); + $collection = Mage::getModel('customer/customer')->getCollection(); + $date = date("Y-m-d H:i:s"); + $date2 = date("Y-m-d H:i:s",strtotime(" - $days days")); + $month = date("m",strtotime($date2)); + $day = date("d",strtotime($date2)); + $moreselect = "MONTH(at_dob.value) = $month AND DAY(at_dob.value) = $day"; + + + $collection->addAttributeToFilter('dob',array('neq'=>'null')) + ->addFieldToFilter('store_id',array('eq'=>$storeId)); + if(count($customerGroups)) { + $collection->addFieldToFilter('group_id',array('in'=>$customerGroups)); + } + $collection->getSelect()->where($moreselect); + foreach($collection as $customer) { + $translate = Mage::getSingleton('core/translate'); + $cust = Mage::getModel('customer/customer')->load($customer->getEntityId()); + $email = $cust->getEmail(); + $name = $cust->getFirstname().' '.$cust->getLastname(); + if($this->_isSubscribed($email,'birthday',$storeId)) { + $vars = array(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=birthday&email='.$email.'&store='.$storeId; + $couponcode = ''; + if($sendCoupon && in_array($customer->getGroupId(),$customerGroupsCoupon)) { + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_AUTOMATIC,$storeId)==Ebizmarts_Autoresponder_Model_Config::COUPON_AUTOMATIC) { + list($couponcode,$discount,$toDate) = $this->_createNewCoupon($storeId,$email); + $vars = array('couponcode'=>$couponcode,'discount' => $discount, 'todate' => $toDate, 'name' => $name,'tags'=>array($tags),'url'=>$url); + } + else { + $couponcode = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_COUPON_CODE); + $vars = array('couponcode'=>$couponcode, 'name' => $name,'tags'=>array($tags),'url'=>$url); + } + + } + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('happy birthday',$email,$name,$couponcode,$storeId); + } + } + + } + protected function _processNoActivity($storeId) + { + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NOACTIVITY_DAYS,$storeId); + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NOACTIVITY_CUSTOMER_GROUPS, $storeId)); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NOACTIVITY_TEMPLATE,$storeId); + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NOACTIVITY_SUBJECT,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::NOACTIVITY_MANDRILL_TAG,$storeId)."_$storeId"; + + $collection = Mage::getModel('customer/customer')->getCollection(); + + + if(count($customerGroups)) { + $collection->addFieldToFilter('group_id',array('in'=>$customerGroups)); + } + $collection->addFieldToFilter('store_id',array('eq'=>$storeId)); + + foreach($collection as $customer) { + $customerId = $customer->getEntityId(); + // get the orders for this customer for this store + $orderCollection = Mage::getModel('sales/order')->getCollection(); + $orderCollection->addFieldToFilter('customer_id',array('eq'=>$customerId)) + ->addFieldToFilter('store_id',array('eq'=>$storeId)); + if($orderCollection->getSize()>0) { // if the customer has any order for this store + $logCustomer = Mage::getModel('log/customer')->loadByCustomer($customer); + $lastVisited = $logCustomer->getLoginAt(); + $limit = date("Y-m-d H:i:s",strtotime(" - $days days")); + if($limit>$lastVisited) { + $translate = Mage::getSingleton('core/translate'); + $cust = Mage::getModel('customer/customer')->load($customerId); + $email = $cust->getEmail(); + $name = $cust->getFirstname().' '.$cust->getLastname(); + if($this->_isSubscribed($email,'noactivity',$storeId)) { + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=noactivity&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'lastlogin'=>$lastVisited,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('no activity',$email,$name,"",$storeId); + } + } + } + } + + } + protected function _processRelated($storeId) + { + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_CUSTOMER_GROUPS, $storeId)); + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_DAYS,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_MANDRILL_TAG,$storeId)."_$storeId"; + $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_SUBJECT,$storeId); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_TEMPLATE,$storeId); + $maxRelated = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::RELATED_MAX,$storeId); + + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days-1, 'DAY')); + $to = new Zend_Db_Expr($expr); + $collection = Mage::getResourceModel('sales/order_collection'); + $collection->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)) + ->addFieldToFilter('main_table.created_at',array('from'=>$from,'to'=>$to)); + if(count($customerGroups)) { + $collection->addFieldToFilter('main_table.customer_group_id',array('in'=> $customerGroups)); + } + foreach($collection as $order) { + $counter = 0; + $allRelated = array(); + foreach($order->getAllItems() as $itemId => $item) { + if($maxRelated && $maxRelated < $counter) { + break; + } + $product = Mage::getModel('catalog/product')->load($item->getProductId()); + foreach($product->getRelatedLinkCollection() as $related) { + if($maxRelated && $maxRelated < $counter) { + break; + } + $relatedProduct = Mage::getModel('catalog/product')->load($related->getLinkedProductId()); + $allRelated[$counter++] = $relatedProduct; + } + } + if($counter > 0) { + $translate = Mage::getSingleton('core/translate'); + if($this->_isSubscribed($email,'related',$storeId)) { + $email = $order->getCustomerEmail(); + $name = $order->getCustomerFirstname().' '.$order->getCustomerLastname(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=related&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'related'=>$allRelated,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('related products',$email,$name,"",$storeId); + } + } + } + + } + protected function _processReview($storeId) + { + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_CUSTOMER_GROUPS, $storeId)); + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_DAYS,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_MANDRILL_TAG,$storeId)."_$storeId"; + $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_SUBJECT,$storeId); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_TEMPLATE,$storeId); + + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days-1, 'DAY')); + $to = new Zend_Db_Expr($expr); + $collection = Mage::getResourceModel('sales/order_collection'); + $collection->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)) + ->addFieldToFilter('main_table.created_at',array('from'=>$from,'to'=>$to)); + if(count($customerGroups)) { + $collection->addFieldToFilter('main_table.customer_group_id',array('in'=> $customerGroups)); + } + foreach($collection as $order) { + $translate = Mage::getSingleton('core/translate'); + $email = $order->getCustomerEmail(); + if($this->_isSubscribed($email,'review',$storeId)) { + $name = $order->getCustomerFirstname().' '.$order->getCustomerLastname(); + $products = array(); + foreach($order->getAllItems() as $item) { + $product = Mage::getModel('catalog/product')->load($item->getProductId()); + if($product->isConfigurable()) { + continue; + } + $products[] = $product; + } + $orderNum = $order->getIncrementId(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=review&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'products'=>$products,'ordernum'=>$orderNum,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('product review',$email,$name,"",$storeId); + } + } + + } + protected function _processWishlist($storeId) + { + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_CUSTOMER_GROUPS, $storeId)); + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_DAYS,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_MANDRILL_TAG,$storeId)."_$storeId"; + $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_SUBJECT,$storeId); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_TEMPLATE,$storeId); + + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days-1, 'DAY')); + $to = new Zend_Db_Expr($expr); + + $collection = Mage::getModel('wishlist/item')->getCollection(); + $collection->addFieldToFilter('main_table.added_at',array('from'=>$from,'to'=>$to)) + ->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)) + ->setOrder('main_table.wishlist_id'); + $wishlist_ant = -1; + $wishlistId = $collection->getFirstItem()->getWishlistId(); + $products = array(); + foreach($collection as $item) { + if($wishlistId != $wishlist_ant) { + if($wishlist_ant != -1 && count($products) > 0) { + $translate = Mage::getSingleton('core/translate'); + $email = $customer->getEmail(); + if($this->_isSubscribed($email,'wishlist',$storeId)) { + $name = $customer->getFirstname().' '.$customer->getLastname(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=wishlist&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'products'=>$products,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('wishlist',$email,$name,"",$storeId); + } + + } + $wishlist_ant = $wishlistId; + $wishlistId = $item->getWishlistId(); + $wishlist = Mage::getModel('wishlist/wishlist')->load($wishlistId); + $customer = Mage::getModel('customer/customer')->load($wishlist->getCustomerId()); + $products = array(); + } + if(in_array($customer->getGroupId(),$customerGroups)) { + $products[] = Mage::getModel('catalog/product')->load($item->getProductId()); + } + } + if(count($products)) { + $translate = Mage::getSingleton('core/translate'); + $email = $customer->getEmail(); + if($this->_isSubscribed($email,'wishlist',$storeId)) { + $name = $customer->getFirstname().' '.$customer->getLastname(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=wishlist&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'products'=>$products,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('wishlist',$email,$name,"",$storeId); + } + } + + } + protected function _processVisited($storeId) + { + $customerGroups = explode(",",Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_CUSTOMER_GROUPS, $storeId)); + $days = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_DAYS,$storeId); + $tags = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_MANDRILL_TAG,$storeId)."_$storeId"; + $mailSubject = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_SUBJECT,$storeId); + $senderId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_SENDER,$storeId); + $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderId/name",$storeId), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderId/email",$storeId)); + $templateId = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_TEMPLATE,$storeId); + $adapter = Mage::getSingleton('core/resource')->getConnection('sales_read'); + $max = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_MAX,$storeId); + + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days, 'DAY')); + $from = new Zend_Db_Expr($expr); + $expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($days-1, 'DAY')); + $to = new Zend_Db_Expr($expr); + + $collection = Mage::getModel('ebizmarts_autoresponder/visited')->getCollection(); + $collection + ->addFieldToFilter('main_table.visited_at',array('from'=>$from,'to'=>$to)) + ->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)); + $collection->getSelect()->order('main_table.customer_id asc')->order('main_table.visited_at desc'); + + $customerIdPrev = 0; + $products = array(); + foreach($collection as $item) { + if($customerIdPrev!=$item->getCustomerId()) { + if($customerIdPrev != 0 && count($products) > 0) { + $email = $customer->getEmail(); + if($this->_isSubscribed($email,'visitedproducts',$storeId)) { + $translate = Mage::getSingleton('core/translate'); + $name = $customer->getFirstname().' '.$customer->getLastname(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=visitedproducts&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'products'=>$products,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('visitedproducts',$email,$name,"",$storeId); + } + } + $products = array(); + $customer = Mage::getModel('customer/customer')->load($item->getCustomerId()); + $customerIdPrev = $item->getCustomerId(); + } + if(count($products) > $max||!in_array($customer->getGroupId(),$customerGroups)) { + continue; + } + $itemscollection = Mage::getModel('sales/order_item')->getCollection(); + $itemscollection->addFieldToFilter('main_table.created_at',array('from'=>$from)) + ->addFieldToFilter('main_table.product_id',array('eq'=>$item->getProductId())); + if($itemscollection->getSize() == 0) { // if not orders from date which include this product + if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE,$storeId)) { // if the abandoned cart module is active + $itemscollection2 = Mage::getModel('sales/quote_item')->getCollection(); + $itemscollection2->addFieldToFilter('main_table.created_at',array('from'=>$from)) + ->addFieldToFilter('main_table.product_id',array('eq'=>$item->getProductId())); + if($itemscollection2->getSize() > 0) { // if there are an abandoned cart which include this product + continue; + } + } + $products[]= Mage::getModel('catalog/product')->load($item->getProductId()); + } + } + if(count($products)) { + $email = $customer->getEmail(); + if($this->_isSubscribed($email,'visitedproducts',$storeId)) { + $translate = Mage::getSingleton('core/translate'); + $name = $customer->getFirstname().' '.$customer->getLastname(); + $url = Mage::getModel('core/url')->setStore($storeId)->getUrl().'ebizautoresponder/autoresponder/unsubscribe?list=visitedproducts&email='.$email.'&store='.$storeId; + $vars = array('name' => $name,'tags'=>array($tags),'products'=>$products,'url'=>$url); + $mail = Mage::getModel('core/email_template')->setTemplateSubject($mailSubject)->sendTransactional($templateId,$sender,$email,$name,$vars,$storeId); + $translate->setTranslateInLine(true); + Mage::helper('ebizmarts_abandonedcart')->saveMail('visitedproducts',$email,$name,"",$storeId); + } + } + + } + protected function _createNewCoupon($store,$email) + { + $couponamount = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_DISCOUNT, $store); + $couponexpiredays = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_EXPIRE, $store); + $coupontype = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_DISCOUNT_TYPE, $store); + $couponlength = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_LENGTH, $store); + $couponlabel = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_COUPON_LABEL, $store); + $websiteid = Mage::getModel('core/store')->load($store)->getWebsiteId(); + + $fromDate = date("Y-m-d"); + $toDate = date('Y-m-d', strtotime($fromDate. " + $couponexpiredays day")); + if($coupontype == 1) { + $action = 'cart_fixed'; + $discount = Mage::app()->getStore($store)->getCurrentCurrencyCode()."$couponamount"; + } + elseif($coupontype == 2) { + $action = 'by_percent'; + $discount = "$couponamount%"; + } + $customer_group = new Mage_Customer_Model_Group(); + $allGroups = $customer_group->getCollection()->toOptionHash(); + $groups = array(); + foreach($allGroups as $groupid=>$name) { + $groups[] = $groupid; + } + $coupon_rule = Mage::getModel('salesrule/rule'); + $coupon_rule->setName("Birthday coupon $email") + ->setDescription("Birthday coupon $email") + ->setFromDate($fromDate) + ->setToDate($toDate) + ->setIsActive(1) + ->setCouponType(2) + ->setUsesPerCoupon(1) + ->setUsesPerCustomer(1) + ->setCustomerGroupIds($groups) + ->setProductIds('') + ->setLengthMin($couponlength) + ->setLengthMax($couponlength) + ->setSortOrder(0) + ->setStoreLabels(array($couponlabel)) + ->setSimpleAction($action) + ->setDiscountAmount($couponamount) + ->setDiscountQty(0) + ->setDiscountStep('0') + ->setSimpleFreeShipping('0') + ->setApplyToShipping('0') + ->setIsRss(0) + ->setWebsiteIds($websiteid); + $uniqueId = Mage::getSingleton('salesrule/coupon_codegenerator', array('length' => $couponlength))->generateCode(); + $coupon_rule->setCouponCode($uniqueId); + $coupon_rule->save(); + return array($uniqueId,$discount,$toDate); + } + + function _getIntervalUnitSql($interval, $unit) + { + return sprintf('INTERVAL %d %s', $interval, $unit); + } + protected function _isSubscribed($email,$list,$storeId) + { + $collection = Mage::getModel('ebizmarts_autoresponder/unsubscribe')->getCollection(); + $collection->addFieldtoFilter('main_table.email',array('eq'=>$email)) + ->addFieldtoFilter('main_table.list',array('eq'=>$list)) + ->addFieldtoFilter('main_table.store_id',array('eq'=>$storeId)); + return $collection->getSize() == 0; + + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/EventObserver.php b/app/code/community/Ebizmarts/Autoresponder/Model/EventObserver.php new file mode 100644 index 0000000..a5135c2 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/EventObserver.php @@ -0,0 +1,49 @@ + + * Date : 6/24/13 + * Time : 5:27 PM + * File : EventObserver.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_EventObserver +{ + /** + * @param Varien_Event_Observer $o + */ + public function saveConfig(Varien_Event_Observer $o) + { + $store = is_null($o->getEvent()->getStore()) ? 'default': $o->getEvent()->getStore(); + if(!Mage::helper('mandrill')->useTransactionalService()) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + if(!Mage::helper('mandrill')->useTransactionalService()) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + if(!Mage::getStoreConfig('customer/address/dob_show')) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + if(!Mage::getStoreConfig('customer/address/dob_show',$store)) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + if(Mage::getStoreConfig('advanced/modules_disable_output/Mage_Wishlist',$store)) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + if(Mage::getStoreConfig('advanced/modules_disable_output/Mage_Review',$store)) { + $config = new Mage_Core_Model_Config(); + $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_ACTIVE,false,"default",$store); + Mage::getConfig()->cleanCache(); + } + + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Unsubscribe.php b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Unsubscribe.php new file mode 100644 index 0000000..f2c5dcb --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Unsubscribe.php @@ -0,0 +1,16 @@ + + * Date : 6/25/13 + * Time : 5:24 PM + * File : Unsubscribe.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Resource_Unsubscribe extends Mage_Core_Model_Mysql4_Abstract +{ + public function _construct() + { + $this->_init('ebizmarts_autoresponder/unsubscribe','id'); + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Unsubscribe/Collection.php b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Unsubscribe/Collection.php new file mode 100644 index 0000000..4305a3f --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Unsubscribe/Collection.php @@ -0,0 +1,15 @@ + + * Date : 6/26/13 + * Time : 7:51 AM + * File : Collection.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Resource_Unsubscribe_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + protected function _construct() + { + $this->_init('ebizmarts_autoresponder/unsubscribe'); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Visited.php b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Visited.php new file mode 100644 index 0000000..f47ce7d --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Visited.php @@ -0,0 +1,27 @@ + + * Date : 8/15/13 + * Time : 8:05 PM + * File : Visited.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Resource_Visited extends Mage_Core_Model_Mysql4_Abstract +{ + public function _construct() + { + $this->_init('ebizmarts_autoresponder/visited','id'); + } + public function loadByCustomerProduct(Ebizmarts_Autoresponder_Model_Visited $obj,$customerId,$productId,$storeId) { + $select = $this->_getReadAdapter()->select() + ->from($this->getMainTable()) + ->where($this->getMainTable().'.'.'customer_id =?',$customerId) + ->where($this->getMainTable().'.'.'product_id =?',$productId) + ->where($this->getMainTable().'.'.'store_id =?',$storeId); + $visited_id = $this->_getReadAdapter()->fetchOne($select); + if($visited_id) { + $this->load($obj,$visited_id); + } + return $this; + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Visited/Collection.php b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Visited/Collection.php new file mode 100644 index 0000000..2c77116 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Resource/Visited/Collection.php @@ -0,0 +1,15 @@ + + * Date : 8/15/13 + * Time : 8:06 PM + * File : Collection.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Resource_Visited_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract +{ + protected function _construct() + { + $this->_init('ebizmarts_autoresponder/visited'); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Automatic.php b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Automatic.php new file mode 100644 index 0000000..ef2d887 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Automatic.php @@ -0,0 +1,22 @@ + + * Date : 6/14/13 + * Time : 4:15 PM + * File : Automatic.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_System_Config_Automatic +{ + /** + * @return array + */ + public function toOptionArray() + { + $options = array( + array('value'=> 1, 'label' => Mage::helper('ebizmarts_autoresponder')->__('Specific')), + array('value'=> 2, 'label' => Mage::helper('ebizmarts_autoresponder')->__('Automatic')) + ); + return $options; + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Customergroup.php b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Customergroup.php new file mode 100644 index 0000000..7e4e758 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Customergroup.php @@ -0,0 +1,21 @@ + + * Date : 6/14/13 + * Time : 4:21 PM + * File : Customergroup.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_System_Config_Customergroup +{ + protected $_options; + + public function toOptionArray() + { + if (!$this->_options) { + $this->_options = Mage::getResourceModel('customer/group_collection') + ->loadData()->toOptionArray(); + } + return $this->_options; + } +} diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Discounttype.php b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Discounttype.php new file mode 100644 index 0000000..33710ab --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Discounttype.php @@ -0,0 +1,22 @@ + + * Date : 6/14/13 + * Time : 4:16 PM + * File : Discounttype.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_System_Config_Discounttype +{ + /** + * @return array + */ + public function toOptionArray() + { + $options = array( + array('value'=> 1, 'label' => Mage::helper('ebizmarts_abandonedcart')->__('Fixed amount')), + array('value'=> 2, 'label' => Mage::helper('ebizmarts_abandonedcart')->__('Percentage')) + ); + return $options; + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Time.php b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Time.php new file mode 100644 index 0000000..82f1125 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/System/Config/Time.php @@ -0,0 +1,27 @@ + + * Date : 6/14/13 + * Time : 4:15 PM + * File : Automatic.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_System_Config_Time +{ + /** + * @return array + */ + public function toOptionArray() + { + $options = array( + array('value'=> 0, 'label' => Mage::helper('ebizmarts_autoresponder')->__('Immediate')), + array('value'=> 2, 'label' => Mage::helper('ebizmarts_autoresponder')->__('2 seconds')), + array('value'=> 5, 'label' => Mage::helper('ebizmarts_autoresponder')->__('5 seconds')), + array('value'=> 10, 'label' => Mage::helper('ebizmarts_autoresponder')->__('10 seconds')), + array('value'=> 20, 'label' => Mage::helper('ebizmarts_autoresponder')->__('20 seconds')), + array('value'=> 30, 'label' => Mage::helper('ebizmarts_autoresponder')->__('30 seconds')), + array('value'=> 60, 'label' => Mage::helper('ebizmarts_autoresponder')->__('1 minute')), + ); + return $options; + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Unsubscribe.php b/app/code/community/Ebizmarts/Autoresponder/Model/Unsubscribe.php new file mode 100644 index 0000000..6700605 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Unsubscribe.php @@ -0,0 +1,14 @@ + + * Date : 6/25/13 + * Time : 5:21 PM + * File : Unsubscribe.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Unsubscribe extends Mage_Core_Model_Abstract +{ + public function _construct() { + $this->_init('ebizmarts_autoresponder/unsubscribe'); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/Model/Visited.php b/app/code/community/Ebizmarts/Autoresponder/Model/Visited.php new file mode 100644 index 0000000..37b7979 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/Model/Visited.php @@ -0,0 +1,18 @@ + + * Date : 8/15/13 + * Time : 8:04 PM + * File : Visited.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_Model_Visited extends Mage_Core_Model_Abstract +{ + public function _construct() { + $this->_init('ebizmarts_autoresponder/visited'); + } + public function loadByCustomerProduct($customerId,$productId,$storeId) { + $this->_getResource()->loadByCustomerProduct($this,$customerId,$productId,$storeId); + return $this; + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/controllers/AutoresponderController.php b/app/code/community/Ebizmarts/Autoresponder/controllers/AutoresponderController.php new file mode 100644 index 0000000..d55b083 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/controllers/AutoresponderController.php @@ -0,0 +1,119 @@ + + * Date : 6/25/13 + * Time : 3:22 PM + * File : AutoresponderController.php + * Module : Ebizmarts_Magemonkey + */ +class Ebizmarts_Autoresponder_AutoresponderController extends Mage_Core_Controller_Front_Action +{ + public function indexAction() + { + if(!Mage::helper('customer')->isLoggedIn()) { + $this->_redirect('/'); + } + $this->loadLayout(); + $this->_initLayoutMessages('customer/session'); + $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation'); + $this->getLayout()->getBlock('head')->setTitle($this->__('Newsletter Subscription')); + $this->renderLayout(); + + + } + public function unsubscribeAction(){ + $params = $this->getRequest()->getParams(); + if(isset($params['email'])&&isset($params['list'])&&$params['store']) { + $collection = Mage::getModel('ebizmarts_autoresponder/unsubscribe')->getCollection(); + $collection->addFieldToFilter('main_table.email',array('eq'=>$params['email'])) + ->addFieldToFilter('main_table.list',array('eq'=>$params['list'])) + ->addFieldToFilter('main_table.store_id',array('eq'=>$params['store'])); + if($collection->getSize() == 0) { + $unsubscribe = Mage::getModel('ebizmarts_autoresponder/unsubscribe'); + $unsubscribe->setEmail($params['email']) + ->setList($params['list']) + ->setStoreId($params['store']); + $unsubscribe->save(); + } + } + $this->loadLayout(); + $this->renderLayout(); + } + public function savelistAction() + { + if(!Mage::helper('customer')->isLoggedIn()) { + $this->_redirect('/'); + } + $params = $this->getRequest()->getParams(); + $lists = Mage::helper('ebizmarts_autoresponder')->getLists(); + $email = Mage::helper('customer')->getCustomer()->getEmail(); + $storeId = Mage::app()->getStore()->getStoreId(); + + foreach($lists as $key => $list) { + $collection = Mage::getModel('ebizmarts_autoresponder/unsubscribe')->getCollection(); + $collection->addFieldToFilter('main_table.email',array('eq'=>$email)) + ->addFieldToFilter('main_table.list',array('eq'=>$key)) + ->addFieldToFilter('main_table.store_id',array('eq'=>$storeId)); + if(array_key_exists($key,$params) && $collection->getSize() > 0) { //try to remove + $collection->getFirstItem()->delete(); + } + else if(!array_key_exists($key,$params)&&$collection->getSize() == 0){ + $unsubscribe = Mage::getModel('ebizmarts_autoresponder/unsubscribe'); + $unsubscribe->setEmail($email) + ->setList($key) + ->setStoreId($storeId); + Mage::log($unsubscribe); + $unsubscribe->save(); + } + } + Mage::getSingleton('core/session') + ->addSuccess($this->__('Lists updated')); + + $this->_redirect('ebizautoresponder/autoresponder'); + } + protected function _getCustomerId() + { + if(Mage::getSingleton('customer/session')->isLoggedIn()) { + $customerData = Mage::getSingleton('customer/session')->getCustomer(); + return $customerData->getId(); + } + } + public function getVisitedProductsConfigAction() + { + $params = $this->getRequest()->getParams(); + $storeId = Mage::app()->getStore()->getStoreId(); + if(Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_ACTIVE,$storeId)&&Mage::getSingleton('customer/session')->isLoggedIn()) { + if(isset($params['product_id'])) { + $product = Mage::getModel('catalog/product')->load($params['product_id']); + $mark = $product->getAttributeText('ebizmarts_mark_visited'); + if($mark == 'Yes') { + $resp['time'] = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::VISITED_TIME,$storeId); + } + else { + $resp['time'] = -1; + } + } + } + else { + $resp['time'] = -1; + } + $this->getResponse()->setHeader('Content-type', 'application/json'); + $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($resp)); + return; + } + public function markVisitedProductsAction() + { + $params = $this->getRequest()->getParams(); + if(!isset($params['product_id'])||!Mage::getSingleton('customer/session')->isLoggedIn()) { + return; + } + $storeId = Mage::app()->getStore()->getStoreId(); + $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId(); + $visited = Mage::getModel('ebizmarts_autoresponder/visited')->loadByCustomerProduct($customerId,$params['product_id'],$storeId); + $visited->setCustomerId($customerId) + ->setProductId($params['product_id']) + ->setStoreId($storeId) + ->setVisitedAt(Mage::getModel('core/date')->gmtDate()) + ->save(); + } +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/etc/adminhtml.xml b/app/code/community/Ebizmarts/Autoresponder/etc/adminhtml.xml new file mode 100644 index 0000000..b06e0c0 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/etc/adminhtml.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + Ebizmarts Autoresponder + + + + + + + + + + + + + + Ebizmarts_Autoresponder.csv + + + + + diff --git a/app/code/community/Ebizmarts/Autoresponder/etc/config.xml b/app/code/community/Ebizmarts/Autoresponder/etc/config.xml new file mode 100644 index 0000000..9c7569c --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/etc/config.xml @@ -0,0 +1,219 @@ + + + + + + 0.1.4 + + + + + + Ebizmarts_Autoresponder_Model + ebizmarts_autoresponder_resource + + + Ebizmarts_Autoresponder_Model_Resource + ebizmarts_autoresponder_mysql4 + + + ebizmarts_autoresponder_unsubscribe
+
+ + ebizmarts_autoresponder_visited
+
+
+
+
+ + + Ebizmarts_Autoresponder_Block + + + + + Ebizmarts_Autoresponder_Helper + + + + + + Ebizmarts_Autoresponder + Mage_Eav_Model_Entity_Setup + + + + + + + + + + + + +
+ + + + + + ebizmarts_autoresponder/eventObserver + saveConfig + + + + + + + + + + ebizmarts/autoresponder.xml + + + + + + standard + + Ebizmarts_Autoresponder + ebizautoresponder + + + + + + + + + + 0 1 * * * + + + ebizmarts_autoresponder/cron::process + + + + + + + + Autoresponder_NewOrder + Thanks for your order + New Order List + + + Autoresponder_RelatedProducts + 5 + Products of your interest + Related Product List + + + Autoresponder_Review + Please review your purchased products + Review Product List + + + Autoresponder_Birthday + Happy birthday + Happy Birthday List + + + Autoresponder_NoCustomerActivity + You don't have any activity + No Activity List + + + Autoresponder_WishlistAdd + Wishlist Subject + Wishlist List + + + Autoresponder_VisitedProducts + Visited Product Subject + Visited Product List + + + +
\ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/etc/system.xml b/app/code/community/Ebizmarts/Autoresponder/etc/system.xml new file mode 100644 index 0000000..6189a59 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/etc/system.xml @@ -0,0 +1,815 @@ + + + + + + + monkey + 400 + 1 + 1 + 1 + + + ebizmarts_autoresponder/adminhtml_system_config_fieldset_hint + 0 + 1 + 1 + 1 + + + + 1 + text + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_email_identity + 20 + 1 + 1 + 1 + + 1 + + + + + + + 2 + text + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + text + 25 + 1 + 1 + 1 + + 1 + + + + + + text + 40 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + + + 3 + text + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + + text + 35 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 40 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 60 + 1 + 1 + 1 + Max related product, 0 means no max + + 1 + + + + + + + 4 + text + 1 + 1 + 1 + + + ebizmarts_autoresponder/adminhtml_system_config_review_fieldset_hint + 0 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + + text + 35 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 40 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + + + 12 + text + 1 + 1 + 1 + + + ebizmarts_autoresponder/adminhtml_system_config_birthday_fieldset_hint + 0 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + + text + 35 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 40 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + select + adminhtml/system_config_source_yesno + 100 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 110 + 1 + 1 + 1 + 0 + + + 1 + 1 + + + + + select + ebizmarts_autoresponder/system_config_automatic + 115 + 1 + 1 + 1 + + 1 + 1 + + + + + text + 120 + 1 + 1 + 1 + 0 + + + 1 + 1 + 1 + + + + + text + 120 + 1 + 1 + 1 + 0 + + + 1 + 1 + 2 + + + + + text + 130 + 1 + 1 + 1 + 0 + + 1 + 1 + 2 + + + + + select + ebizmarts_autoresponder/system_config_discounttype + 140 + 1 + 1 + 1 + 0 + + + 1 + 1 + 2 + + + + + text + 150 + 1 + 1 + 1 + 0 + + + 1 + 1 + 2 + + + + + text + 160 + 1 + 1 + 1 + 0 + + + 1 + 1 + 2 + + + + + + + 15 + text + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + + text + 35 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 40 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + + + 16 + text + 1 + 1 + 1 + + + ebizmarts_autoresponder/adminhtml_system_config_wishlist_fieldset_hint + + 0 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + + text + 35 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 40 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + + + 20 + text + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + text + 20 + 1 + 1 + 1 + + 1 + + + + + + + text + 50 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 60 + 1 + 1 + 1 + + 1 + + + + + multiselect + ebizmarts_autoresponder/system_config_customergroup + 70 + 1 + 1 + 1 + 0 + + + 1 + + + + + text + 80 + 1 + 1 + 1 + 0 means no Max + + 1 + + + + + + + + diff --git a/app/code/community/Ebizmarts/Autoresponder/sql/ebizmarts_autoresponder_setup/mysql4-install-0.1.0.php b/app/code/community/Ebizmarts/Autoresponder/sql/ebizmarts_autoresponder_setup/mysql4-install-0.1.0.php new file mode 100644 index 0000000..124fc48 --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/sql/ebizmarts_autoresponder_setup/mysql4-install-0.1.0.php @@ -0,0 +1,27 @@ + + * Date : 4/28/13 + * Time : 11:20 AM + * File : ${FILE_NAME} + * Module : ${PROJECT_NAME} + */ +/* @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; + +$installer->startSetup(); + +$installer->run(" + + CREATE TABLE IF NOT EXISTS `{$this->getTable('ebizmarts_autoresponder_unsubscribe')}` ( + `id` int(10) unsigned NOT NULL auto_increment, + `email` varchar(255), + `list` varchar(255), + `store_id` smallint(5), + `unsubscribed_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +"); + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Autoresponder/sql/ebizmarts_autoresponder_setup/mysql4-upgrade-0.1.3-0.1.4.php b/app/code/community/Ebizmarts/Autoresponder/sql/ebizmarts_autoresponder_setup/mysql4-upgrade-0.1.3-0.1.4.php new file mode 100644 index 0000000..4c0959e --- /dev/null +++ b/app/code/community/Ebizmarts/Autoresponder/sql/ebizmarts_autoresponder_setup/mysql4-upgrade-0.1.3-0.1.4.php @@ -0,0 +1,57 @@ +startSetup(); + +$installer->run(" + + CREATE TABLE IF NOT EXISTS `{$this->getTable('ebizmarts_autoresponder_visited')}` ( + `id` int(10) unsigned NOT NULL auto_increment, + `customer_id` int(10), + `product_id` int(10), + `store_id` smallint(5), + `visited_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +"); + +$applyTo = array( + Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, + Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE +); + +$installer->addAttribute( + Mage_Catalog_Model_Product::ENTITY, + 'ebizmarts_mark_visited', + array( + 'group' => 'General', + 'type' => 'int', + 'backend' => '', + 'frontend' => '', + 'label' => 'Send Browsed Product Autoresponder', + 'input' => 'select', + 'source' => 'eav/entity_attribute_source_boolean', + 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, + 'required' => false, + 'user_defined' => false, + 'default' => '0', + 'searchable' => false, + 'filterable' => false, + 'comparable' => false, + 'visible_on_front' => false, + 'unique' => false, + 'is_configurable' => false, + 'apply_to' => implode(',',$applyTo) + ) +); + +$installer->updateAttribute('catalog_product', 'ebizmarts_mark_visited', 'backend_model', ''); + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Bulksync/QueueExport/Grid.php b/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Bulksync/QueueExport/Grid.php index 0439e84..e42e53e 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Bulksync/QueueExport/Grid.php +++ b/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Bulksync/QueueExport/Grid.php @@ -87,7 +87,7 @@ protected function _prepareColumns() )); $views = Mage::getModel('core/store')->getCollection()->toOptionHash(); - array_unshift($views, Mage::helper('monkey')->__('All store views') ); + $views[0] = Mage::helper('monkey')->__('All store views'); $this->addColumn('store_id', array( diff --git a/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Ecommerce/Grid.php b/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Ecommerce/Grid.php index a9ce65d..7ea18f4 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Ecommerce/Grid.php +++ b/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/Ecommerce/Grid.php @@ -45,16 +45,16 @@ protected function _prepareColumns() 'index' => 'order_increment_id', )); - $this->addColumn('mc_campaign_id ', array( + $this->addColumn('mc_campaign_id', array( 'header'=> Mage::helper('monkey')->__('Campaign #'), 'width' => '80px', - 'index' => 'mc_campaign_id ' + 'index' => 'mc_campaign_id' )); - $this->addColumn('mc_email_id ', array( + $this->addColumn('mc_email_id', array( 'header'=> Mage::helper('monkey')->__('Email #'), 'width' => '80px', - 'index' => 'mc_email_id ' + 'index' => 'mc_email_id' )); $this->addColumn('created_at', array( @@ -76,4 +76,17 @@ public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current' => true)); } + + protected function _prepareMassaction() + { + $this->setMassactionIdField('order_id'); + $this->getMassactionBlock()->setFormFieldName('orders'); + $this->getMassactionBlock()->addItem('delete', array( + 'label'=> Mage::helper('monkey')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete', array('' => '')), + 'confirm' => Mage::helper('tax')->__('Are you sure?') + )); + return $this; + } + } diff --git a/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/System/Config/Fieldset/Hint.php b/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/System/Config/Fieldset/Hint.php index f9553d4..b5c6a08 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/System/Config/Fieldset/Hint.php +++ b/app/code/community/Ebizmarts/MageMonkey/Block/Adminhtml/System/Config/Fieldset/Hint.php @@ -27,9 +27,13 @@ public function getMageMonkeyVersion() } public function getPxParams() { - + $plan = Mage::getSingleton('monkey/api')->getAccountDetails(); + if(!is_array($plan)||!isset($plan['plan_type'])) { + $plan = array(); + $plan['plan_type'] = ''; + } $v = (string)Mage::getConfig()->getNode('modules/Ebizmarts_MageMonkey/version'); - $ext = "MageMonkey;{$v}"; + $ext = "MageMonkey;{$v} ".$plan['plan_type']; $modulesArray = (array)Mage::getConfig()->getNode('modules')->children(); $aux = (array_key_exists('Enterprise_Enterprise', $modulesArray))? 'EE' : 'CE' ; diff --git a/app/code/community/Ebizmarts/MageMonkey/Block/Checkout/Subscribe.php b/app/code/community/Ebizmarts/MageMonkey/Block/Checkout/Subscribe.php index 817a67d..2c54bbd 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Block/Checkout/Subscribe.php +++ b/app/code/community/Ebizmarts/MageMonkey/Block/Checkout/Subscribe.php @@ -20,9 +20,16 @@ protected function _toHtml() $alreadySubscribed = Mage::getModel('newsletter/subscriber') ->loadByEmail($this->getQuote()->getCustomerEmail()) ->isSubscribed(); + /** + * If you don't want to show the lists in the checkout when the user it's already subscribed. + * Replace the code below for the condition below + * + * if ( !$this->helper('monkey')->canCheckoutSubscribe() OR $alreadySubscribed ) { + * + * + * **/ - if ( !$this->helper('monkey')->canCheckoutSubscribe() OR - $alreadySubscribed ) { + if ( !$this->helper('monkey')->canCheckoutSubscribe() ) { return ''; } diff --git a/app/code/community/Ebizmarts/MageMonkey/Block/Customer/Account/Lists.php b/app/code/community/Ebizmarts/MageMonkey/Block/Customer/Account/Lists.php index 5b470a5..05073c8 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Block/Customer/Account/Lists.php +++ b/app/code/community/Ebizmarts/MageMonkey/Block/Customer/Account/Lists.php @@ -10,5 +10,4 @@ class Ebizmarts_MageMonkey_Block_Customer_Account_Lists extends Ebizmarts_MageMonkey_Block_Lists { - } diff --git a/app/code/community/Ebizmarts/MageMonkey/Block/Lists.php b/app/code/community/Ebizmarts/MageMonkey/Block/Lists.php index 43f883c..7363e2b 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Block/Lists.php +++ b/app/code/community/Ebizmarts/MageMonkey/Block/Lists.php @@ -225,7 +225,11 @@ public function renderGroup($group, $list) $fieldType = $group['form_field']; - $memberInfo = $this->_memberInfo($list['id']); + if($this->_getEmail()){ + $memberInfo = $this->_memberInfo($list['id']); + } else { + $memberInfo['success'] = 0; + } $myGroups = array(); if($memberInfo['success'] == 1){ diff --git a/app/code/community/Ebizmarts/MageMonkey/Helper/Data.php b/app/code/community/Ebizmarts/MageMonkey/Helper/Data.php index aff2d9b..4770ccf 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Helper/Data.php +++ b/app/code/community/Ebizmarts/MageMonkey/Helper/Data.php @@ -164,7 +164,9 @@ public function getApiKey($store = null) */ public function log($data, $filename = 'Monkey.log') { - return Mage::getModel('core/log_adapter', $filename)->log($data); + if($this->config('enable_log') != 0) { + return Mage::getModel('core/log_adapter', $filename)->log($data); + } } /** @@ -380,8 +382,13 @@ public function getMergeVars($customer, $includeEmail = FALSE, $websiteId = NULL $request = Mage::app()->getRequest(); //Add Customer data to Subscriber if is Newsletter_Subscriber is Customer - if($customer->getCustomerId()){ + if(!$customer->getDefaultShipping() && $customer->getEntityId()){ + $customer->addData(Mage::getModel('customer/customer')->load($customer->getEntityId()) + ->setStoreId($customer->getStoreId()) + ->toArray()); + } elseif($customer->getCustomerId()){ $customer->addData(Mage::getModel('customer/customer')->load($customer->getCustomerId()) + ->setStoreId($customer->getStoreId()) ->toArray()); } @@ -414,6 +421,11 @@ public function getMergeVars($customer, $includeEmail = FALSE, $websiteId = NULL $addr = explode('_', $customAtt); $address = $customer->{'getPrimary'.ucfirst($addr[0]).'Address'}(); + if(!$address){ + if($customer->{'getDefault' .ucfirst($addr[0])}()) { + $address = Mage::getModel('customer/address')->load($customer->{'getDefault' .ucfirst($addr[0])}()); + } + } if($address){ $merge_vars[$key] = array( 'addr1' => $address->getStreet(1), @@ -423,6 +435,14 @@ public function getMergeVars($customer, $includeEmail = FALSE, $websiteId = NULL 'zip' => $address->getPostcode(), 'country' => $address->getCountryId() ); + $telephone = $address->getTelephone(); + if($telephone){ + $merge_vars['TELEPHONE'] = $telephone; + } + $company = $address->getCompany(); + if($company){ + $merge_vars['COMPANY'] = $company; + } } break; @@ -725,10 +745,13 @@ public function handlePost($request, $guestEmail) $defaultList = $this->getDefaultList(Mage::app()->getStore()); $api = Mage::getSingleton('monkey/api'); - $customer = Mage::helper('customer')->getCustomer(); - $email = $guestEmail ? $guestEmail : $customer->getEmail(); - $loggedIn = Mage::helper('customer')->isLoggedIn(); + if($loggedIn){ + $customer = Mage::helper('customer')->getCustomer(); + }else{ + $customer = Mage::registry('mc_guest_customer'); + } + $email = $guestEmail ? $guestEmail : $customer->getEmail(); if( !empty($curlists) ){ @@ -749,7 +772,6 @@ public function handlePost($request, $guestEmail) $item->unsubscribe(); } - }else{ //Unsubscribe Email $api->listUnsubscribe($listId, $email); } @@ -795,20 +817,17 @@ public function handlePost($request, $guestEmail) $groupings = $lists[$listId]; unset($groupings['subscribed']); - + if( !Mage::helper('monkey')->isAdmin() && (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_CONFIRMATION_FLAG, Mage::app()->getStore()->getId()) == 1) ) { + $isConfirmNeed = TRUE; + } if($defaultList == $listId){ $subscriber = Mage::getModel('newsletter/subscriber'); - $subscriber->setListGroups($groupings); $subscriber->setMcListId($listId); $subscriber->setMcStoreId(Mage::app()->getStore()->getId()); - + $subscriber->setImportMode(TRUE); $subscriber->subscribe($email); }else{ - if( !Mage::helper('monkey')->isAdmin() && - (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_CONFIRMATION_FLAG, Mage::app()->getStore()->getId()) == 1) ){ - $isConfirmNeed = TRUE; - } $customer->setListGroups($groupings); $customer->setMcListId($listId); $mergeVars = Mage::helper('monkey')->getMergeVars($customer); diff --git a/app/code/community/Ebizmarts/MageMonkey/Model/Cron.php b/app/code/community/Ebizmarts/MageMonkey/Model/Cron.php index a70fe76..6a00de7 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Model/Cron.php +++ b/app/code/community/Ebizmarts/MageMonkey/Model/Cron.php @@ -140,26 +140,27 @@ protected function subscribed($member, $websiteId = null, $createCustomer = FALS { $subscriber = $this->_getSubscriberObject($member['email']); - if( $createCustomer ){ - - $customer = Mage::getModel('customer/customer')->setWebsiteId($websiteId) - ->loadByEmail($member['email']); - - //Create customer if not exists, and subscribe - if( is_null($customer->getId()) ){ + $alreadyExist = false; + $websites = Mage::getModel('core/website')->getCollection()->getData(); + foreach($websites as $website){ + $customer = Mage::getModel('customer/customer')->setWebsiteId($website['website_id']) + ->loadByEmail($member['email']); + if($customer->getId()){ + $alreadyExist = true; + } + } + + if($alreadyExist == false){ + //Create customer if not exists, and subscribe $customer = $this->_helper()->createCustomerAccount($member, $websiteId); } - $subscriber - ->setCustomerId($customer->getId()) - ->save(); - + ->setCustomerId($customer->getId()) + ->save(); }else{ - //Just subscribe email $subscriber->save(); - } } @@ -237,11 +238,11 @@ public function processExportJobs() if($jobStoreId){ $collection->addFieldToFilter('store_id', $jobStoreId); } - + if($job->getDataSourceEntity() == 'newsletter_subscriber'): $collection->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED); endif; - + $collection->load(); //Update total count on first run @@ -249,7 +250,7 @@ public function processExportJobs() $allRows = $collection->getSize(); $job->setTotalCount($allRows)->save(); } - + $batch = array(); foreach($job->lists() as $listId){ @@ -261,7 +262,6 @@ public function processExportJobs() $processedCount += 1; $batch []= $this->_helper()->getMergeVars($item, TRUE); } - if(count($batch) > 0){ $job->setStatus('chunk_running') @@ -336,8 +336,6 @@ protected function _getEntityModel($type) break; case 'customer': - //TODO: Add default Billing and Shipping address data - $model = Mage::getResourceModel('customer/customer_collection') ->addNameToSelect() ->addAttributeToSelect('gender') @@ -409,4 +407,17 @@ protected function _getJob($entity) return $job->getFirstItem(); } + + /** Send order to MailChimp Automatically by Order Status + * + * + * + */ + public function processAutoExportJobs() + { + if (Mage::helper('monkey')->config('ecommerce360') == 3 && Mage::getModel('monkey/ecommerce360')->isActive()){ + Mage::getModel('monkey/ecommerce360')->autoExportJobs(); + } + } + } diff --git a/app/code/community/Ebizmarts/MageMonkey/Model/Ecommerce360.php b/app/code/community/Ebizmarts/MageMonkey/Model/Ecommerce360.php index da79adb..ceab2fe 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Model/Ecommerce360.php +++ b/app/code/community/Ebizmarts/MageMonkey/Model/Ecommerce360.php @@ -190,6 +190,9 @@ private function setItemstoSend() $category = Mage::getModel('catalog/category')->load($category->getParentId()); $names[] = $category->getName(); } + } + if(!isset($mcitem['category_id'])) { + $mcitem['category_id'] = 0; } $mcitem['category_name'] = (count($names))? implode(" - ",array_reverse($names)) : 'None'; $mcitem['qty'] = $item->getQtyOrdered(); @@ -237,4 +240,77 @@ protected function _logCall() ->save(); } + /** Send order to MailChimp Automatically by Order Status + * + * + */ + public function autoExportJobs(){ + $allow_sent = false; + $orderIds[] = '0'; + $ecommerceOrders = Mage::getModel('monkey/ecommerce') + ->getCollection()->getData(); + if($ecommerceOrders) { + foreach($ecommerceOrders as $ecommerceOrder){ + $orderIds[] = $ecommerceOrder['order_id']; + } + } + $orders = Mage::getResourceModel('sales/order_collection'); + //Get ALL orders which has not been sent to MailChimp + $orders->getSelect()->where('main_table.entity_id NOT IN(?)', $orderIds); + //Get status options selected in the Configuration + $states = explode(',', Mage::helper('monkey')->config('order_status')); + foreach($orders as $order){ + foreach($states as $state){ + if($order->getStatus() == $state || $state == 'all_status'){ + $allow_sent = true; + } + } + + if($allow_sent == true){ + $this->_order = $order; + $api = Mage::getSingleton('monkey/api', array('store' => $this->_order->getStoreId())); + if(!$api){ + return false; + } + + $subtotal = $this->_order->getSubtotal(); + $discount = (float)$this->_order->getDiscountAmount(); + if ($discount != 0) { + $subtotal = $subtotal + ($discount); + } + + $this->_info = array( + 'id' => $this->_order->getIncrementId(), + 'total' => $subtotal, + 'shipping' => $this->_order->getShippingAmount(), + 'tax' => $this->_order->getTaxAmount(), + 'store_id' => $this->_order->getStoreId(), + 'store_name' => $this->_order->getStoreName(), + 'plugin_id' => 1215, + 'items' => array() + ); + + $email = $this->_order->getCustomerEmail(); + $campaign = $this->_order->getEbizmartsMagemonkeyCampaignId(); + $this->setItemstoSend(); + + if($email && $campaign){ + $this->_info ['email_id']= $email; + $this->_info ['campaign_id']= $campaign; + + //Send order to MailChimp + $rs = $api->campaignEcommOrderAdd($this->_info); + }else{ + $this->_info ['email']= $email; + $rs = $api->ecommOrderAdd($this->_info); + } + $allow_sent = false; + if ( $rs === TRUE ){ + $this->_logCall(); + } + } + + } + } + } diff --git a/app/code/community/Ebizmarts/MageMonkey/Model/Observer.php b/app/code/community/Ebizmarts/MageMonkey/Model/Observer.php index 3cc6f03..75ad136 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Model/Observer.php +++ b/app/code/community/Ebizmarts/MageMonkey/Model/Observer.php @@ -31,6 +31,10 @@ public function handleSubscriber(Varien_Event_Observer $observer) return $observer; } + if(Mage::getSingleton('core/session')->getMonkeyCheckout(TRUE)){ + return $observer; + } + $email = $subscriber->getSubscriberEmail(); if($subscriber->getMcStoreId()){ $listId = Mage::helper('monkey')->getDefaultList($subscriber->getMcStoreId()); @@ -48,6 +52,10 @@ public function handleSubscriber(Varien_Event_Observer $observer) $isConfirmNeed = TRUE; } + if($isConfirmNeed){ + $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED); + } + //Check if customer is not yet subscribed on MailChimp $isOnMailChimp = Mage::helper('monkey')->subscribedToList($email, $listId); @@ -63,10 +71,11 @@ public function handleSubscriber(Varien_Event_Observer $observer) Mage::getSingleton('core/session')->addSuccess(Mage::helper('monkey')->__('Confirmation request has been sent.')); } - Mage::getSingleton('monkey/api') - ->listSubscribe($listId, $email, $this->_mergeVars($subscriber), 'html', $isConfirmNeed); + Mage::getSingleton('monkey/api')->listSubscribe($listId, $email, $this->_mergeVars($subscriber), 'html', $isConfirmNeed); - }else{ + } + // This code unsubscribe users if it's on MailChimp and the status it's unconfirmed + /*else{ if(($isOnMailChimp == 1) && ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)){ $rs = Mage::getSingleton('monkey/api') ->listUnsubscribe($listId, $email); @@ -74,7 +83,7 @@ public function handleSubscriber(Varien_Event_Observer $observer) Mage::throwException($rs); } } - } + }*/ } @@ -128,15 +137,6 @@ public function loadConfig(Varien_Event_Observer $observer) return $observer; } - $myRewrite = 'Ebizmarts_MageMonkey_Model_Email_Template'; - $modelName = Mage::app()->getConfig()->getModelClassName('core/email_template'); - - if(Mage::helper('monkey')->useTransactionalService() && ($myRewrite !== $modelName)){ - Mage::getSingleton('adminhtml/session')->addError( - Mage::helper('monkey')->__('Transactional Emails via MailChimp are not working because of a conflict with: "%s"', $modelName) - ); - } - return $observer; } @@ -149,7 +149,7 @@ public function loadConfig(Varien_Event_Observer $observer) public function saveConfig(Varien_Event_Observer $observer) { - $scope = is_null($observer->getEvent()->getStore()) ? 'default' : $observer->getEvent()->getStore(); + $scope = is_null($observer->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode(): $observer->getEvent()->getStore(); $post = Mage::app()->getRequest()->getPost(); $request = Mage::app()->getRequest(); @@ -203,6 +203,12 @@ public function saveConfig(Varien_Event_Observer $observer) } if(is_array($additionalLists)){ + foreach($additionalLists as $additional) { + if($additional == $selectedLists[0]) { + $message = Mage::helper('monkey')->__('Be Careful! You have choosen the same list for "General Subscription" and "Additional Lists". Please change this values and save the configuration again'); + Mage::getSingleton('adminhtml/session')->addWarning($message); + } + } $selectedLists = array_merge($selectedLists, $additionalLists); } @@ -224,6 +230,10 @@ public function saveConfig(Varien_Event_Observer $observer) $hookUrl = Mage::getModel('core/url')->getUrl(Ebizmarts_MageMonkey_Model_Monkey::WEBHOOKS_PATH, array('wkey' => $webhooksKey)); } + if(FALSE != strstr($hookUrl, '?', true)){ + $hookUrl = strstr($hookUrl, '?', true); + } + $api = Mage::getSingleton('monkey/api', array('apikey' => $apiKey)); //Validate API KEY @@ -377,8 +387,12 @@ public function registerCheckoutSuccess(Varien_Event_Observer $observer) } if(is_object($order) && $order->getId()){ - - $sessionFlag = Mage::getSingleton('core/session')->getMonkeyCheckout(TRUE); + //Set Campaign Id if exist + $campaign_id = Mage::getModel('monkey/ecommerce360')->getCookie()->get('magemonkey_campaign_id'); + if($campaign_id){ + $order->setEbizmartsMagemonkeyCampaignId($campaign_id); + } + $sessionFlag = Mage::getSingleton('core/session')->getMonkeyCheckout(); $forceSubscription = Mage::helper('monkey')->canCheckoutSubscribe(); if($sessionFlag || $forceSubscription == 3){ //Guest Checkout @@ -388,6 +402,7 @@ public function registerCheckoutSuccess(Varien_Event_Observer $observer) try{ $subscriber = Mage::getModel('newsletter/subscriber') + ->setImportMode(TRUE) ->subscribe($order->getCustomerEmail()); }catch(Exception $e){ Mage::logException($e); @@ -469,7 +484,7 @@ public function massActionOption($observer) } $block = $observer->getEvent()->getBlock(); - if(get_class($block) == 'Mage_Adminhtml_Block_Widget_Grid_Massaction') { + if($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction || $block instanceof Enterprise_SalesArchive_Block_Adminhtml_Sales_Order_Grid_Massaction) { if($block->getRequest()->getControllerName() == 'sales_order') { diff --git a/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/Ecommerce360.php b/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/Ecommerce360.php index 72db656..5b24900 100644 --- a/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/Ecommerce360.php +++ b/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/Ecommerce360.php @@ -19,6 +19,7 @@ public function toOptionArray() return array( array('value' => 1, 'label' => Mage::helper('monkey')->__('Referred Orders')), array('value' => 2, 'label' => Mage::helper('monkey')->__('All Orders')), + array('value' => 3, 'label' => Mage::helper('monkey')->__('By Cron depending on the Orders Status')), array('value' => 0, 'label' => Mage::helper('monkey')->__('-- Disabled --')) ); } diff --git a/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/OrderStatus.php b/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/OrderStatus.php new file mode 100644 index 0000000..b114a4d --- /dev/null +++ b/app/code/community/Ebizmarts/MageMonkey/Model/System/Config/Source/OrderStatus.php @@ -0,0 +1,27 @@ + + */ +class Ebizmarts_MageMonkey_Model_System_Config_Source_OrderStatus +{ + + /** + * Options getter + * + * @return array + */ + public function toOptionArray() + { + $status = Mage::GetResourceModel('sales/order_status_collection')->toOptionArray(); + $allStateOptions = array('value' => 'all_status', 'label' => Mage::helper('monkey')->__('All Status')); + array_unshift($status, $allStateOptions); + return $status; + + } + +} \ No newline at end of file diff --git a/app/code/community/Ebizmarts/MageMonkey/controllers/Adminhtml/EcommerceController.php b/app/code/community/Ebizmarts/MageMonkey/controllers/Adminhtml/EcommerceController.php index 104b23d..c4b4a1a 100644 --- a/app/code/community/Ebizmarts/MageMonkey/controllers/Adminhtml/EcommerceController.php +++ b/app/code/community/Ebizmarts/MageMonkey/controllers/Adminhtml/EcommerceController.php @@ -81,4 +81,30 @@ public function masssendAction() $this->_redirect('adminhtml/sales_order/index'); } + /** + * Mass action remove order from ecommerce 360 grid + */ + public function massDeleteAction() + { + $orderIds = $this->getRequest()->getParam('orders'); + if(!is_array($orderIds)) { + Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('Please select Order(s).')); + } else { + try { + $ecommerce = Mage::getModel('monkey/ecommerce'); + foreach ($orderIds as $orderId) { + $ecommerce->load($orderId)->delete(); + } + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('monkey')->__( + 'Total of %d record(s) were deleted.', count($orderIds) + ) + ); + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + } + } + $this->_redirect('*/*/index'); + } + } diff --git a/app/code/community/Ebizmarts/MageMonkey/etc/adminhtml.xml b/app/code/community/Ebizmarts/MageMonkey/etc/adminhtml.xml index 7d0e1e2..5d22d38 100644 --- a/app/code/community/Ebizmarts/MageMonkey/etc/adminhtml.xml +++ b/app/code/community/Ebizmarts/MageMonkey/etc/adminhtml.xml @@ -19,19 +19,6 @@ - Bulk Sync diff --git a/app/code/community/Ebizmarts/MageMonkey/etc/config.xml b/app/code/community/Ebizmarts/MageMonkey/etc/config.xml index 44053ab..f95920b 100644 --- a/app/code/community/Ebizmarts/MageMonkey/etc/config.xml +++ b/app/code/community/Ebizmarts/MageMonkey/etc/config.xml @@ -2,7 +2,7 @@ - 1.1.0 + 1.1.19 @@ -184,7 +184,7 @@ check - + @@ -212,7 +212,7 @@ - + @@ -223,8 +223,10 @@ 0 0 false - + 1000 + all_status + 1 @@ -242,6 +244,10 @@ 0 * * * * monkey/cron::processImportJobs + + 0 * * * * + monkey/cron::processAutoExportJobs + diff --git a/app/code/community/Ebizmarts/MageMonkey/etc/system.xml b/app/code/community/Ebizmarts/MageMonkey/etc/system.xml index 5bd275e..5680fbd 100644 --- a/app/code/community/Ebizmarts/MageMonkey/etc/system.xml +++ b/app/code/community/Ebizmarts/MageMonkey/etc/system.xml @@ -1,12 +1,18 @@ + + + + 400 + + monkey-section mailchimp-header - customer - 404 + monkey + 100 1 1 1 @@ -63,7 +69,6 @@ 1 0 1 - More about MailChimp plans.]]> @@ -116,8 +121,21 @@ 1 1 1 - How do I turn on Ecommerce360 tracking on my campaigns?
How to segment your list based on your customers purchase activity]]>
+ How do I turn on Ecommerce360 tracking on my campaigns?
How to segment your list based on your customers purchase activity]]>
+ + + multiselect + adminhtml/system_config_source_order_status + 65 + 1 + 0 + 1 + IMPORTANT: By default this function run every one hour. If you want to edit this value visit our wiki]]> + + 3 + + monkey/adminhtml_system_config_form_field_mapfields @@ -156,24 +174,6 @@ 1 Show Newsletter Subscribe checkbox in the last Checkout Step (Order Review) - select @@ -204,6 +204,16 @@ 1 + + + select + adminhtml/system_config_source_yesno + 124 + 1 + 0 + 1 + File is {{base_dir}}/var/log/MageMonkey_ApiCall.log +
diff --git a/app/code/community/Ebizmarts/MageMonkey/sql/monkey_setup/mysql4-upgrade-1.1.5-1.1.6.php b/app/code/community/Ebizmarts/MageMonkey/sql/monkey_setup/mysql4-upgrade-1.1.5-1.1.6.php new file mode 100644 index 0000000..78557bc --- /dev/null +++ b/app/code/community/Ebizmarts/MageMonkey/sql/monkey_setup/mysql4-upgrade-1.1.5-1.1.6.php @@ -0,0 +1,7 @@ +getConnection()->addColumn( + $installer->getTable('sales_flat_order'), 'ebizmarts_magemonkey_campaign_id', 'varchar(10)' +); \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Mandrill/Helper/Data.php b/app/code/community/Ebizmarts/Mandrill/Helper/Data.php index 2286a7f..8554351 100644 --- a/app/code/community/Ebizmarts/Mandrill/Helper/Data.php +++ b/app/code/community/Ebizmarts/Mandrill/Helper/Data.php @@ -59,7 +59,7 @@ public function getUserAgent() { * @return Mage_Core_Model_Log_Adapter */ public function log($data, $filename = 'Ebizmarts_Mandrill.log') { - return Mage::getModel('core/log_adapter', $filename)->log($data); + //return Mage::getModel('core/log_adapter', $filename)->log($data); } } \ No newline at end of file diff --git a/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php b/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php index ff68d89..01c0c1a 100644 --- a/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php +++ b/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php @@ -98,8 +98,6 @@ public function send($email, $name = null, array $variables = array()) { try { $message = array ( - 'html' => $text, - 'text' => $text, 'subject' => $this->getProcessedTemplateSubject($variables), 'from_name' => $this->getSenderName(), 'from_email' => $this->getSenderEmail(), @@ -109,10 +107,27 @@ public function send($email, $name = null, array $variables = array()) { 'headers' => array('Reply-To' => $this->replyTo) ); - $tTags = $this->_getTemplateTags(); - if(!empty($tTags)){ - $message ['tags'] = $tTags; + if($this->isPlain()) { + $message['text'] = $text; + } else { + $message['html'] = $text; } + if(isset($variables['tags']) && count($variables['tags'])) { + $message ['tags'] = $variables['tags']; + } + else { + $templateId = (string)$this->getId(); + $templates = parent::getDefaultTemplates(); + if (isset($templates[$templateId])) { + $message ['tags'] = array(substr($templates[$templateId]['label'], 0, 50)); + } else { + if($this->getTemplateCode()){ + $message ['tags'] = array(substr($this->getTemplateCode(), 0, 50)); + } else { + $message ['tags'] = array(substr($templateId, 0, 50)); + } + } + } $sent = $mail->sendEmail($message); if($mail->errorCode){ @@ -127,30 +142,6 @@ public function send($email, $name = null, array $variables = array()) { return true; } - protected function _getTemplateTags() { - - $tags = array(); - - $templateId = (string)$this->getId(); - - $templates = parent::getDefaultTemplates(); - if (isset($templates[$templateId])) { - if(isset($templates[$templateId]['mandrill-tag'])) { - $tags = explode(',',$templates[$templateId]['mandrill-tag']); - } else { - $tags []= substr($templates[$templateId]['label'], 0, 50); - } - } else { - if($this->getTemplateCode()){ - $tags []= substr($this->getTemplateCode(), 0, 50); - } else { - $tags []= substr($templateId, 0, 50); - } - } - - return $tags; - } - public function setReplyTo($email) { if(FALSE === Mage::helper('mandrill')->useTransactionalService()) { return parent::setReplyTo($email); @@ -160,4 +151,25 @@ public function setReplyTo($email) { return $this; } + public function createAttachment($body, + $mimeType = Zend_Mime::TYPE_OCTETSTREAM, + $disposition = Zend_Mime::DISPOSITION_ATTACHMENT, + $encoding = Zend_Mime::ENCODING_BASE64, + $filename = null) + { + + } + public function addAttachment(Zend_Mime_Part $att) + { + + } + + public function addTo($email, $name = null) + { + if(FALSE === Mage::helper('mandrill')->useTransactionalService()) { + array_push($this->_bcc, $email); + return $this; + } + } + } diff --git a/app/code/community/Ebizmarts/Mandrill/etc/config.xml b/app/code/community/Ebizmarts/Mandrill/etc/config.xml index 7911c4f..689aa12 100644 --- a/app/code/community/Ebizmarts/Mandrill/etc/config.xml +++ b/app/code/community/Ebizmarts/Mandrill/etc/config.xml @@ -2,7 +2,7 @@ - 1.0.5 + 1.0.8 @@ -66,6 +66,16 @@ + + + + + ebizmarts_autoresponder/eventObserver + saveConfig + + + + diff --git a/app/code/community/Ebizmarts/Mandrill/etc/system.xml b/app/code/community/Ebizmarts/Mandrill/etc/system.xml index 1506a23..086c2e4 100644 --- a/app/code/community/Ebizmarts/Mandrill/etc/system.xml +++ b/app/code/community/Ebizmarts/Mandrill/etc/system.xml @@ -3,10 +3,10 @@ - mandrill-section + mandrill-section separator-top mandrill-header - advanced - 609 + monkey + 200 1 1 1 @@ -43,9 +43,6 @@ 1 1 1 - - 1 - @@ -56,9 +53,6 @@ 1 1 1 - - 1 - diff --git a/app/design/adminhtml/default/default/layout/ebizmarts/abandonedcart.xml b/app/design/adminhtml/default/default/layout/ebizmarts/abandonedcart.xml index e55a171..0be20bb 100644 --- a/app/design/adminhtml/default/default/layout/ebizmarts/abandonedcart.xml +++ b/app/design/adminhtml/default/default/layout/ebizmarts/abandonedcart.xml @@ -4,13 +4,24 @@ - + + + + + + + + + + + abandonedcart/abandonedcart.css + @@ -19,5 +30,4 @@ - \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/ebizmarts/abandonedcart/system/config/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/ebizmarts/abandonedcart/system/config/fieldset/hint.phtml index d43ced9..4521cdb 100644 --- a/app/design/adminhtml/default/default/template/ebizmarts/abandonedcart/system/config/fieldset/hint.phtml +++ b/app/design/adminhtml/default/default/template/ebizmarts/abandonedcart/system/config/fieldset/hint.phtml @@ -1,6 +1,11 @@


- __('Ebizmarts Abandoned Cart v%s (Beta)
Need help? Got feedback? Email us', $this->getVersion())?> + __('Ebizmarts Abandoned Cart v%s
Need help? See our Wiki or browse our support forums Got feedback? Email us', $this->getVersion(),$this->getVersion())?> + useTransactionalService()): ?> +
+ You must setup getUrl("adminhtml/system_config/edit/section/mandrill"); ?>" >Mandrill extension to use this extension +
+

\ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/birthday/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/birthday/fieldset/hint.phtml new file mode 100644 index 0000000..433488d --- /dev/null +++ b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/birthday/fieldset/hint.phtml @@ -0,0 +1,5 @@ + +
+ You must activate Show Date of Birth in System->Configuration->Customer Configuration->Name and Address Options to use this facility +
+ \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/fieldset/hint.phtml new file mode 100644 index 0000000..b8a7065 --- /dev/null +++ b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/fieldset/hint.phtml @@ -0,0 +1,12 @@ +
+

+
+ __('Ebizmarts Autoresponder v%s
Need help? See our Wiki or browse our support forums Got feedback? Email us', $this->getVersion(),$this->getVersion())?> + + useTransactionalService()): ?> +
+ You must setup getUrl("adminhtml/system_config/edit/section/mandrill"); ?>" >Mandrill extension to use this extension +
+ +

+
\ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/review/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/review/fieldset/hint.phtml new file mode 100644 index 0000000..bd64c3e --- /dev/null +++ b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/review/fieldset/hint.phtml @@ -0,0 +1,5 @@ + +
+ You must activate the output of the module Mage_Review on System->Configuration->Advanced->Advanced->Disable Module output to use this feature +
+ \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/wishlist/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/wishlist/fieldset/hint.phtml new file mode 100644 index 0000000..361a50c --- /dev/null +++ b/app/design/adminhtml/default/default/template/ebizmarts/autoresponder/system/config/wishlist/fieldset/hint.phtml @@ -0,0 +1,5 @@ + +
+ You must activate the output of the module Mage_Wishlist on System->Configuration->Advanced->Advanced->Disable Module output to use this feature +
+ \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/magemonkey/system/config/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/magemonkey/system/config/fieldset/hint.phtml index 88443d5..edb429b 100644 --- a/app/design/adminhtml/default/default/template/magemonkey/system/config/fieldset/hint.phtml +++ b/app/design/adminhtml/default/default/template/magemonkey/system/config/fieldset/hint.phtml @@ -7,6 +7,7 @@

__('MageMonkey v%s by ebizmarts', $this->getMageMonkeyVersion())?> +
+ __('Need help? See our Wiki or browse our support forums Got feedback? Email us', $this->getMageMonkeyVersion())?>

-

Need help? Got feedback? Browse ebizmarts' support forums

\ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/mandrill/system/config/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/mandrill/system/config/fieldset/hint.phtml index b0c6848..51dfaf3 100644 --- a/app/design/adminhtml/default/default/template/mandrill/system/config/fieldset/hint.phtml +++ b/app/design/adminhtml/default/default/template/mandrill/system/config/fieldset/hint.phtml @@ -2,6 +2,7 @@

__('Mandrill v%s by ebizmarts', $this->getMandrillVersion())?> +
+ __('Need help? See our Wiki or browse our support forums Got feedback? Email us', $this->getMandrillVersion())?>

-

__('Need help? Got feedback? Browse ebizmarts\' support forums'); ?>

\ No newline at end of file diff --git a/app/design/frontend/base/default/layout/ebizmarts_abandonedcart.xml b/app/design/frontend/base/default/layout/ebizmarts/abandonedcart.xml similarity index 100% rename from app/design/frontend/base/default/layout/ebizmarts_abandonedcart.xml rename to app/design/frontend/base/default/layout/ebizmarts/abandonedcart.xml diff --git a/app/design/frontend/base/default/layout/ebizmarts/autoresponder.xml b/app/design/frontend/base/default/layout/ebizmarts/autoresponder.xml new file mode 100644 index 0000000..8ce818c --- /dev/null +++ b/app/design/frontend/base/default/layout/ebizmarts/autoresponder.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + autoresponderlists + ebizautoresponder/autoresponder/index + + + + + + + + + + \ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts/autoresponder/customer/list.phtml b/app/design/frontend/base/default/template/ebizmarts/autoresponder/customer/list.phtml new file mode 100644 index 0000000..ee7e88b --- /dev/null +++ b/app/design/frontend/base/default/template/ebizmarts/autoresponder/customer/list.phtml @@ -0,0 +1,24 @@ +getLists(); +?> +
+
+

__('Autoresponders Subscription'); ?>

+
+
+
+
    + $list): ?> +
  • + /> + +
  • + + +
+
+ +
+
+
+
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts/autoresponder/related/items.phtml b/app/design/frontend/base/default/template/ebizmarts/autoresponder/related/items.phtml new file mode 100644 index 0000000..e017d5b --- /dev/null +++ b/app/design/frontend/base/default/template/ebizmarts/autoresponder/related/items.phtml @@ -0,0 +1,9 @@ +getProducts(); ?> + + + + + + + +
<?php echo $product->getName(); ?>

getName(); ?>

getShortDescription(); ?>
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts/autoresponder/review/items.phtml b/app/design/frontend/base/default/template/ebizmarts/autoresponder/review/items.phtml new file mode 100644 index 0000000..c9b22d1 --- /dev/null +++ b/app/design/frontend/base/default/template/ebizmarts/autoresponder/review/items.phtml @@ -0,0 +1,15 @@ +getProducts(); ?> + + + + getParentIdsByChild($product->getId()); + if(isset($parentId[0])) { + $product = Mage::getModel('catalog/product')->load($parentId[0]); + } + ?> + + + + + +
<?php echo $product->getName(); ?>

Rate getName(); ?>

getShortDescription(); ?>
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts/autoresponder/unsubscribe.phtml b/app/design/frontend/base/default/template/ebizmarts/autoresponder/unsubscribe.phtml new file mode 100644 index 0000000..0cafc1a --- /dev/null +++ b/app/design/frontend/base/default/template/ebizmarts/autoresponder/unsubscribe.phtml @@ -0,0 +1,8 @@ +
+

__('You successfully removed from list.') ?>

+
+getMessagesBlock()->getGroupedHtml() ?> +

__('Thank you') ?>

+
+ +
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts/autoresponder/wishlist/items.phtml b/app/design/frontend/base/default/template/ebizmarts/autoresponder/wishlist/items.phtml new file mode 100644 index 0000000..26431ba --- /dev/null +++ b/app/design/frontend/base/default/template/ebizmarts/autoresponder/wishlist/items.phtml @@ -0,0 +1,9 @@ +getProducts(); ?> + + + + + + + +
<?php echo $product->getName(); ?>

getName(); ?>

getShortDescription(); ?>
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items.phtml b/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items.phtml index 1874a05..72ff6ac 100644 --- a/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items.phtml +++ b/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items.phtml @@ -8,15 +8,62 @@ __('Subtotal') ?> + + getAllItems() as $_item):?> + getParentItemId()) continue; else $i++; ?> + getProductType() == 'configurable' || $_item->getProductType() == 'bundle') : + $finalResult = array(); + $result = array(); + $options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct()); + // Check for options + if ($options) { + if (isset($options['options'])) { + $result = array_merge($result, $options['options']); + } + if (isset($options['additional_options'])) { + $result = array_merge($result, $options['additional_options']); + } + if (!empty($options['attributes_info'])) { + $result = array_merge($options['attributes_info'], $result); + } + if(isset($options['bundle_options'])) { - getAllItems() as $_item): ?> - getParentItem()) continue; else $i++; ?> - > - getItemHtml($_item) ?> - - - - getChildHtml('order_totals') ?> - - + $bundled_product = new Mage_Catalog_Model_Product(); + $bundled_product->load($_item->getProduct()->getId()); + $selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection( + $bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product + ); + + $bundled_items = array(); + $label = ''; + $qty = ''; + foreach($selectionCollection as $option) + { + foreach($options['bundle_options'] as $bundle){ + if($bundle['value'][0]['title'] == $option->getName()){ + $label = $bundle['label']; + $qty = $bundle['value'][0]['qty']; + $aux_options[] = array('label' => $label, 'value' => $qty .' x '. $option->getName() .' '. Mage::helper('checkout')->formatPrice($option->getPrice()), 'sku' => $option->getSku()); + } + + } + } + + $result = array_merge($result, $aux_options); + } + } + $options = array_merge($finalResult, $result); + endif; ?> + > + + '. $_item['name'] .''; ?> + '. $_item['sku'] .''; ?> + '. $_item['qty'] .''; ?> + ' . $this->getTax($_item) .''; ?> + '.$option['label'].''.''.$option['value'].''; if(isset($option['sku'])) : echo '' . $option['sku'] . ''; else: echo ''; endif; endforeach; $options = null; endif; '' ?> + + + + + \ No newline at end of file diff --git a/app/design/frontend/base/default/template/magemonkey/checkout/subscribe.phtml b/app/design/frontend/base/default/template/magemonkey/checkout/subscribe.phtml index 22cf2db..52a4d5e 100644 --- a/app/design/frontend/base/default/template/magemonkey/checkout/subscribe.phtml +++ b/app/design/frontend/base/default/template/magemonkey/checkout/subscribe.phtml @@ -1,6 +1,8 @@ getLists(); $check = $this->checkStatus(); + $myLists = $this->getSubscribedLists(); + $generalList = $this->getGeneralList(); $auto = (($check === 1) OR ($check === 3)); ?>
style="display:none;"> - checked="checked" type="checkbox" onchange="addSubscribeToPost(this);" name="magemonkey_trigger" id="magemonkey-trigger" value="1" title="htmlEscape($this->__('Sign Up for Newsletter')) ?>" class="checkbox" /> - + +
+

__('Newsletter Subscription'); ?>

+
+getBlockHtml('formkey'); ?> +
    +
  • + checked="checked" type="checkbox" onchange="addSubscribeToPost(this);" name="list[][subscribed]" id="magemonkey-trigger" value="" title="" class="monkey-list-subscriber" /> + +
    + + +
    + + renderGroup($group, $generalList); ?> +
    + + +
    + + +
  • +
+ + + +
+
    + notInMyAccount() && in_array($list['id'], $myLists)){ + continue; + } + + $igroups = $list['interest_groupings']; + ?> +
  • listLabel($list); ?> + +
    + + +
    + + renderGroup($group, $list); ?> +
    + + +
    + + +
  • + +
+
+
0): - echo $this->getChildHtml('left.monkeysignup'); + //echo $this->getChildHtml('left.monkeysignup'); endif; ?> +} +//Handle newsletter subscribe/unsubscribe checkbox events +$$('.interest-groupings input').each(function(group){ + group.observe('change', function(){ + if(group.checked){ + addGroupToPost(group); + } + }); +}); + \ No newline at end of file diff --git a/app/design/frontend/base/default/template/magemonkey/lists.phtml b/app/design/frontend/base/default/template/magemonkey/lists.phtml index 7ab5a03..f338ad4 100644 --- a/app/design/frontend/base/default/template/magemonkey/lists.phtml +++ b/app/design/frontend/base/default/template/magemonkey/lists.phtml @@ -19,12 +19,15 @@ $canShowButton = $this->getCanShowButton();
  • listLabel($generalList); ?> +
    -
    - - renderGroup($group, $generalList); ?> -
    + +
    + + renderGroup($group, $generalList); ?> +
    +
    @@ -48,10 +51,12 @@ $canShowButton = $this->getCanShowButton();
    -
    - - renderGroup($group, $list); ?> -
    + +
    + + renderGroup($group, $list); ?> +
    +
    diff --git a/app/etc/modules/Ebizmarts_Autoresponder.xml b/app/etc/modules/Ebizmarts_Autoresponder.xml new file mode 100644 index 0000000..8313592 --- /dev/null +++ b/app/etc/modules/Ebizmarts_Autoresponder.xml @@ -0,0 +1,9 @@ + + + + + true + community + + + \ No newline at end of file diff --git a/app/locale/en_US/Ebizmarts_AbandonedCart.csv b/app/locale/en_US/Ebizmarts_AbandonedCart.csv new file mode 100644 index 0000000..bc3a5b1 --- /dev/null +++ b/app/locale/en_US/Ebizmarts_AbandonedCart.csv @@ -0,0 +1,45 @@ +;Config settings +"Enabled","Enabled" +"Sender","Sender" +"Email Template","Email Template" +"Email Template With Coupon","Email Template With Coupon" +"Send email after","Send email after" +"Max number of email to send","Max number of email to send" +"Create Coupon?","Create Coupon?" +"On email number?","On email number?" +"Expire on","Expire on" +"Coupon length","Coupon length" +"Discount type","Discount type" +"Discount amount","Discount amount" +"Label for coupon","Label for coupon" +"Days","Days" +"Max","Max", +"The coupon will be created on the email number","The coupon will be created on the email number" +"The coupon expiration in days","The coupon expiration in days" +"Select percentage or fixed discount","Select percentage or fixed discount" +;Config values +"Fixed amount","Fixed amount" +"Percentage","Percentage" + +;Dashboard +"Lifetime Generate Revenue","Lifetime Generate Revenue" +"Average Orders","Average Orders" +"Generated","Generated" +"Generated Revenue","Generated Revenue" +"Generated Tax","Generated Tax" +"Generated Shipping","Generated Shipping" +"Generated Orders","Generated Orders" +"Generated Conv. Rate","Generated Conv. Rate" +"Emails","Emails" +"Emails Sent","Emails Sent" +"Emails Received","Emails Received" +"Emails Opened","Emails Opened" +"Emails Clicked","Emails Clicked" +"Abandoned Cart Dashboard (Ebizmarts)","Abandoned Cart Dashboard (Ebizmarts)" +"You may obtain more statistics if enable and configure","You may obtain more statistics if enable and configure" +"extension","extension" + +;Menus +"Abandoned Cart Dashboard","Abandoned Cart Dashboard" +"Abandoned Cart Orders","Abandoned Cart Orders" +"Ebizmarts Abandoned Cart","Ebizmarts Abandoned Cart" diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/birthday.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/birthday.html new file mode 100644 index 0000000..a8b92ca --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/birthday.html @@ -0,0 +1,37 @@ + +
    + + + + +
    + + + + + + + + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + + On behalf of {{var store.getFrontendName()}}, we wish a happy birthday. + {{depend couponcode}} +
    We have the pleasure of giving a coupon with code {{var couponcode}} + {{/depend}} + {{depend discount}} + and obtain a discount of {{var discount}} only until {{var todate}} + {{/depend}} +

    +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/neworder.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/neworder.html new file mode 100644 index 0000000..3f36c50 --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/neworder.html @@ -0,0 +1,36 @@ + +
    + + + + +
    + + + + + + + + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + + On behalf of {{var store.getFrontendName()}}, I'd like to personally thank you for your business. + + +
    If you have any questions about your order please contact us at {{config path='trans_email/ident_support/email'}} or call us at {{config path='general/store_information/phone'}} Monday - Friday, 8am - 5pm PST. + + Thanks again, +

    +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/noactivity.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/noactivity.html new file mode 100644 index 0000000..4ad5e7c --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/noactivity.html @@ -0,0 +1,33 @@ + +
    + + + + +
    + + + + + + + + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + Our system detect you have no activity since {{var lastlogin}} + We have a lot of opportunities for you + +
    If you have any questions please contact us at {{config path='trans_email/ident_support/email'}} or call us at {{config path='general/store_information/phone'}} Monday - Friday, 8am - 5pm PST. +

    +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/relatedproducts.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/relatedproducts.html new file mode 100644 index 0000000..557957b --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/relatedproducts.html @@ -0,0 +1,36 @@ + +
    + + + + +
    + + + + + + + + + + + + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + You may like to know about the following products +

    +
    + {{block type='ebizmarts_autoresponder/email_related_items' area='frontend' template='ebizmarts/autoresponder/related/items.phtml' products=$related}} +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/review.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/review.html new file mode 100644 index 0000000..f0e519e --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/review.html @@ -0,0 +1,37 @@ + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + We appreciate you taking the time to review your purchased products with order {{var ordernum}} and look forward to doing business again with your very soon +

    +
    + {{block type='ebizmarts_autoresponder/email_review_items' area='frontend' template='ebizmarts/autoresponder/review/items.phtml' products=$products}} +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/visitedproducts.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/visitedproducts.html new file mode 100644 index 0000000..3f34a3c --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/visitedproducts.html @@ -0,0 +1,37 @@ + +
    + + + + +
    + + + + + + + + + + + +
    If you have any questions please contact us at {{config path='trans_email/ident_support/email'}} or call us at {{config path='general/store_information/phone'}} Monday - Friday, 8am - 5pm PST. +

    + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + Browsed products. +

    + {{block type='ebizmarts_autoresponder/email_wishlist_items' area='frontend' template='ebizmarts/autoresponder/wishlist/items.phtml' products=$products}} +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/ebizmarts/autoresponder/wishlist.html b/app/locale/en_US/template/email/ebizmarts/autoresponder/wishlist.html new file mode 100644 index 0000000..116dce0 --- /dev/null +++ b/app/locale/en_US/template/email/ebizmarts/autoresponder/wishlist.html @@ -0,0 +1,37 @@ + +
    + + + + +
    + + + + + + + + + + + +
    If you have any questions please contact us at {{config path='trans_email/ident_support/email'}} or call us at {{config path='general/store_information/phone'}} Monday - Friday, 8am - 5pm PST. +

    + + + + + + + +
    {{var store.getFrontendName()}}
    +

    Hello, {{htmlescape var=$name}}

    +

    + Thanks for adding new products to your wishlist. +

    + {{block type='ebizmarts_autoresponder/email_wishlist_items' area='frontend' template='ebizmarts/autoresponder/wishlist/items.phtml' products=$products}} +

    Thank you, {{var store.getFrontendName()}}

    You can unsubscribe from this email clicking here.
    +
    +
    + \ No newline at end of file diff --git a/app/locale/en_US/template/email/sales/abandoned_cart.html b/app/locale/en_US/template/email/sales/abandoned_cart.html index 1f01629..a3cea96 100644 --- a/app/locale/en_US/template/email/sales/abandoned_cart.html +++ b/app/locale/en_US/template/email/sales/abandoned_cart.html @@ -11,25 +11,30 @@ -

    Hello, {{htmlescape var=$order.getCustomerName()}}

    +

    Hello, {{htmlescape var=$name}}

    You have an abandoned cart at {{var store.getFrontendName()}}. You can access your cart here. - {{depend couponcode}} -
    You can use this coupon code {{var couponcode}} and obtain a discount of {{var discount}} only until {{var todate}}.
    + {{depend couponcode}} +
    You can use this coupon code {{var couponcode}} {{/depend}} - If you have any questions about your order please contact us at {{config path='trans_email/ident_support/email'}} or call us at {{config path='general/store_information/phone'}} Monday - Friday, 8am - 5pm PST. + {{depend discount}} + and obtain a discount of {{var discount}} only until {{var todate}} + {{/depend}} +
    If you have any questions about your order please contact us at {{config path='trans_email/ident_support/email'}} or call us at {{config path='general/store_information/phone'}} Monday - Friday, 8am - 5pm PST.

    - {{layout handle="ebizmarts_abandonedcart_email_order_items" quote=$quote}} - + {{block type='ebizmarts_abandonedcart/email_order_items' area='frontend' template='ebizmarts_abandonedcart/email/order/items.phtml' quote=$quote}}

    Thank you, {{var store.getFrontendName()}}

    + + You can unsubscribe from this email clicking here. + diff --git a/js/ebizmarts/autoresponders/visitedproducts.js b/js/ebizmarts/autoresponders/visitedproducts.js new file mode 100644 index 0000000..1556241 --- /dev/null +++ b/js/ebizmarts/autoresponders/visitedproducts.js @@ -0,0 +1,21 @@ +function markVisited(productID) { + new Ajax.Request('../index.php/ebizautoresponder/autoresponder/markVisitedProducts?product_id='+productID, { method:'get', onSuccess: function(transport){ + } + }); +} +(function() { + var cb = function() { + var productID = $$('input[name^=product]').first().value; + new Ajax.Request('../index.php/ebizautoresponder/autoresponder/getVisitedProductsConfig?product_id='+productID, { method:'get', onSuccess: function(transport){ + if(transport.responseJSON.time > -1) { + markVisited.delay(transport.responseJSON.time,productID); + } + } + }); + }; + if (document.loaded) { + cb(); + } else { + document.observe('dom:loaded', cb); + } +})(); \ No newline at end of file diff --git a/lib/Mandrill/API.php b/lib/Mandrill/API.php index 6c3a9c0..0f7aeec 100644 --- a/lib/Mandrill/API.php +++ b/lib/Mandrill/API.php @@ -51,6 +51,8 @@ class Mandrill_API { */ protected $_output = 'json'; + protected $_attachments = array(); + /** * Setup data * @@ -159,7 +161,6 @@ public function verifyEmailAddress($email) { * array tags an array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an understore are reserved for internal use and will cause errors. */ public function messagesSend($message) { - $to = array(); foreach($message['to_email'] as $pos => $email){ @@ -168,7 +169,9 @@ public function messagesSend($message) { 'name' => $message['to_name'][$pos] ); } - + if(count($this->_attachments)) { + $message['attachments'] = $this->_attachments; + } $message['to'] = $to; unset($message['to_email'], $message['to_name']); @@ -339,5 +342,26 @@ public function tagsInfo($tag) { return $this->_callServer("tags/info", $params); } + public function createAttachment($body, + $mimeType = Zend_Mime::TYPE_OCTETSTREAM, + $disposition = Zend_Mime::DISPOSITION_ATTACHMENT, + $encoding = Zend_Mime::ENCODING_BASE64, + $filename = null) + { + $att = array(); + $att['type'] = $mimeType; + $att['name'] = $filename; + $att['content'] = base64_encode($body); + $this->_attachments[] = $att; + return $att; + } + public function addAttachment(Zend_Mime_Part $attachment) + { + $att = array(); + $att['type'] = $attachment->type; + $att['name'] = $attachment->filename; + $this->_attachments[] = $att; + return $this; + } } \ No newline at end of file diff --git a/modman b/modman index 8ad1afa..06d4a37 100644 --- a/modman +++ b/modman @@ -1,20 +1,37 @@ -app/code/community/Ebizmarts/AbandonedCart/ app/code/community/Ebizmarts/AbandonedCart/ -app/code/community/Ebizmarts/MageMonkey/ app/code/community/Ebizmarts/MageMonkey/ -app/code/community/Ebizmarts/Mandrill/ app/code/community/Ebizmarts/Mandrill/ -app/etc/modules/Ebizmarts_AbandonedCart.xml app/etc/modules/Ebizmarts_AbandonedCart.xml -app/etc/modules/Ebizmarts_MageMonkey.xml app/etc/modules/Ebizmarts_MageMonkey.xml -app/design/adminhtml/default/default/layout/ebizmarts/ app/design/adminhtml/default/default/layout/ebizmarts/ -app/design/adminhtml/default/default/layout/magemonkey.xml app/design/adminhtml/default/default/layout/magemonkey.xml -app/design/adminhtml/default/default/template/ebizmarts/ app/design/adminhtml/default/default/template/ebizmarts/ -app/design/adminhtml/default/default/template/magemonkey/ app/design/adminhtml/default/default/template/magemonkey/ -app/design/adminhtml/default/default/template/mandrill/ app/design/adminhtml/default/default/template/mandrill/ -app/design/frontend/base/default/layout/ebizmarts_abandonedcart.xml app/design/frontend/base/default/layout/ebizmarts_abandonedcart.xml -app/design/frontend/base/default/layout/magemonkey.xml app/design/frontend/base/default/layout/magemonkey.xml -app/design/frontend/base/default/template/magemonkey/ app/design/frontend/base/default/template/magemonkey/ -app/design/frontend/base/default/template/ebizmarts_abandonedcart/ app/design/frontend/base/default/template/ebizmarts_abandonedcart/ -app/locale/en_US/template/ app/locale/en_US/template/ -app/locale/en_US/Ebizmarts_MageMonkey.csv app/locale/en_US/Ebizmarts_MageMonkey.csv -lib/Mandrill/ lib/Mandrill/ -skin/adminhtml/default/default/magemonkey/ skin/adminhtml/default/default/magemonkey/ -skin/adminhtml/default/default/mandrill/ skin/adminhtml/default/default/mandrill/ -skin/frontend/base/default/magemonkey/ skin/frontend/base/default/magemonkey/ +app/code/community/Ebizmarts/AbandonedCart app/code/community/Ebizmarts/AbandonedCart +app/code/community/Ebizmarts/Autoresponder app/code/community/Ebizmarts/Autoresponder +app/code/community/Ebizmarts/MageMonkey app/code/community/Ebizmarts/MageMonkey +app/code/community/Ebizmarts/Mandrill app/code/community/Ebizmarts/Mandrill + +app/design/adminhtml/default/default/layout/ebizmarts/abandonedcart.xml app/design/adminhtml/default/default/layout/ebizmarts/abandonedcart.xml +app/design/adminhtml/default/default/layout/magemonkey.xml app/design/adminhtml/default/default/layout/magemonkey.xml +app/design/adminhtml/default/default/layout/mandrill.xml app/design/adminhtml/default/default/layout/mandrill.xml +app/design/adminhtml/default/default/template/ebizmarts app/design/adminhtml/default/default/template/ebizmarts +app/design/adminhtml/default/default/template/magemonkey app/design/adminhtml/default/default/template/magemonkey +app/design/adminhtml/default/default/template/mandrill app/design/adminhtml/default/default/template/mandrill + +app/design/frontend/base/default/layout/ebizmarts app/design/frontend/base/default/layout/ebizmarts +app/design/frontend/base/default/layout/magemonkey.xml app/design/frontend/base/default/layout/magemonkey.xml +app/design/frontend/base/default/template/ebizmarts app/design/frontend/base/default/template/ebizmarts +app/design/frontend/base/default/template/ebizmarts_abandonedcart app/design/frontend/base/default/template/ebizmarts_abandonedcart +app/design/frontend/base/default/template/magemonkey app/design/frontend/base/default/template/magemonkey + +app/etc/modules/Ebizmarts_AbandonedCart.xml app/etc/modules/Ebizmarts_AbandonedCart.xml +app/etc/modules/Ebizmarts_Autoresponder.xml app/etc/modules/Ebizmarts_Autoresponder.xml +app/etc/modules/Ebizmarts_MageMonkey.xml app/etc/modules/Ebizmarts_MageMonkey.xml +app/etc/modules/Ebizmarts_Mandrill.xml app/etc/modules/Ebizmarts_Mandrill.xml + +app/locale/en_US/Ebizmarts_AbandonedCart.csv app/locale/en_US/Ebizmarts_AbandonedCart.csv +app/locale/en_US/Ebizmarts_MageMonkey.csv app/locale/en_US/Ebizmarts_MageMonkey.csv +app/locale/en_US/Ebizmarts_Mandrill.csv app/locale/en_US/Ebizmarts_Mandrill.csv +app/locale/en_US/template/email/ebizmarts app/locale/en_US/template/email/ebizmarts +app/locale/en_US/template/email/sales/abandoned_cart.html app/locale/en_US/template/email/sales/abandoned_cart.html + +js/ebizmarts/ js/ebizmarts/ + +lib/Mandrill/API.php lib/Mandrill/API.php + +skin/adminhtml/default/default/magemonkey/ skin/adminhtml/default/default/magemonkey/ +skin/adminhtml/default/default/mandrill/ skin/adminhtml/default/default/mandrill/ + +skin/frontend/base/default/magemonkey/ skin/frontend/base/default/magemonkey/ diff --git a/package.xml b/package.xml index 82918a7..9d3ffe3 100644 --- a/package.xml +++ b/package.xml @@ -1,14 +1,100 @@ Ebizmarts_MageMonkey - 1.1.0 + 1.1.19 stable OSL v3.0 community MailChimp integration for Magento by Ebizmarts Full MailChimp integration, automatic webhooks, multiple lists, interest groups - -- version 1.1.0 stable + -- version 1.1.19 stable +- add browsed products autoresponder + +-- version 1.1.18 stable +- new facility to redirect abandoned cart to cms page +- fix for autoresonders, configurable products in review email + +-- version 1.1.17 stable +- add token to abandoned cart url for security + +-- version 1.1.16 stable +- fix for abandoned cart when a logged customer abandon an order and make this order as guess +- introduce autologin feature for abandoned carts + +-- version 1.1.15 stable +- fix for abandoned cart cron configuration + +-- version 1.1.14 stable +- Add grid for sent email (autoresponder and abandoned carts) +- Minor fix for mandrill tags + +-- version 1.1.13 stable +- Fix for mandrill tags +- Fix for autoresponders admin configuration + +-- version 1.1.12 stable +- Fix for autoresponders + +-- version 1.1.11 stable +- fix for abandoned carts + -- fix for multistore templates +- first release of autoresponders + + +-- version 1.1.10 stable +- fix for abandondedcart dashboard + +-- version 1.1.9 stable +- Fix for mandrill tags + +-- version 1.1.8 stable +- Fix render group errors when user it's guest +- Improve merge var to get address fields +- Fix Bulk Sync import functionality when we create new customers in case doesn't exist +- Fix dashboard in abandoned cart +- Fix database definition in abandoned cart +- Add logs in abandoned cart settings +- Fix for tags in abandoned carts mandrill +- Add subject email to the admin in abandoned cart + +-- version 1.17 stable +- Add customer groups to abandoned cart +- Fix abandoned cart orders grid +- Fix for unsuscribe + +-- version 1.1.6 stable +- Improve Abandoned Cart template (add tax, skus in configurable/bundle products) +- Add option to send abandoned cart emails By Days/Hours +- Add new Ecommerce360 option to send orders to MailChimp (By Cron depending on the Orders Status) +- Fix Wrong Store Name display error on BulkSync exports +- Posibility to Delete Ecommerce360 Orders in Magento (Not in MailChimp) +- Improve data Sync between Magento -> MailChimp (add telephone and company) Send Billing and Shipping address on Exports +- Show interest groups on Checkout in case has enable the subscribe on checkout +- Add createAtachment and addTo in the Emails functionality + +-- version 1.1.5 stable +- Fix for abandoned cart, enable to put a specific coupon created on magento + +-- version 1.1.4 stable +- Fix for abandoned cart multi store management +- Fix for abandoned cart not send email for a quote who has an order posterior from the same customer + +-- version 1.1.3 stable +- Support for mandrill attachments + +-- version 1.1.2 stable +- Fix for abandoned cart, coupon qty > 1 for the same product +- Fix for abandoned cart, customer name in email +- Fix for abandoned cart, cart content in email +- Fix for database with prefix + +-- version 1.1.1 stable +- Adding configuration field to Start Date for abandoned carts +- Add abandonedflag to sales_flat_order +- Change for magento 1.4.2 and 1.5.* + +-- version 1.1.0 stable - Adding abandoned order manager (beta) @@ -107,9 +193,9 @@ Don't display additional lists newsletter block on checkout when there are no ad First public release 0.0.9, January 2012 Ebizmarts Development Teamauto-convertedinfo@ebizmarts.com - 2013-02-19 - - + 2013-08-21 + + diff --git a/skin/adminhtml/default/default/magemonkey/magemonkey.css b/skin/adminhtml/default/default/magemonkey/magemonkey.css index 66fd872..5c055e9 100644 --- a/skin/adminhtml/default/default/magemonkey/magemonkey.css +++ b/skin/adminhtml/default/default/magemonkey/magemonkey.css @@ -1,10 +1,10 @@ -ul.tabs a.monkey-section:hover { background-color:#D8E6E6; background-image:url(images/tabs_link_over_bg.gif); } -ul.tabs a.monkey-section, -ul.tabs a.monkey-section:hover { padding:0.5em 0.5em 0 1.5em; text-indent:-9999px; border-bottom:1px solid #BEBEBE; } +ul.tabs a.monkey-section:hover { background-color:#D8E6E6; background-image:url(../images/tabs_link_over_bg.gif); } +ul.tabs a.monkey-section {border-bottom: 1px; border-bottom-style: dotted;text-indent:-9999px;} +ul.tabs a.monkey-section:hover { border-bottom: 1px; border-bottom-style: dotted;text-indent:-9999px;} ul.tabs a.monkey-section span, -ul.tabs a.monkey-section:hover span { background:url(mailchimp-tab.png) no-repeat 0 0; overflow:hidden; padding:0; width:120px; height:22px;} -ul.tabs a.monkey-section.active, ul.tabs a.monkey-section.active:hover { background:white; } -h3.mailchimp-header { background:url(mailchimp-tab.png) no-repeat 0 0; height: 22px; overflow:hidden; padding:0; width:120px; text-indent:-9999px; } +ul.tabs a.monkey-section:hover span { background:url(mailchimp-tab.png) no-repeat 20px 0; overflow:hidden; padding-left:20px;; width:120px; height:22px;} +ul.tabs a.monkey-section.active, ul.tabs a.monkey-section.active:hover { background:white; border-bottom-color: #8BA5A5;} +h3.mailchimp-header { background:url(mailchimp-tab.png) no-repeat 0 0; height: 22px; overflow:hidden; padding-left:20px;; width:120px; text-indent:-9999px; } fieldset#monkey_general p.note a {background:url(mailchimp-ico.png) no-repeat left top; padding-left:18px; padding-bottom: 4px;} .mailchimp-nowarp {white-space:nowrap;} button.add span span, button.cancel span span, button.delete span span {background-image: none; padding-left: 0;} diff --git a/skin/adminhtml/default/default/mandrill/mandrill.css b/skin/adminhtml/default/default/mandrill/mandrill.css index 46a3535..00c7aa1 100644 --- a/skin/adminhtml/default/default/mandrill/mandrill.css +++ b/skin/adminhtml/default/default/mandrill/mandrill.css @@ -1,9 +1,9 @@ ul.tabs a.mandrill-section:hover { background-color:#D8E6E6; background-image:url(images/tabs_link_over_bg.gif); } -ul.tabs a.mandrill-section, -ul.tabs a.mandrill-section:hover {border-bottom:none; padding:0.5em 0.5em 0 1.5em; } +ul.tabs a.mandrill-section {border-bottom: 1px; border-bottom-style: dotted;} +ul.tabs a.mandrill-section:hover {border-bottom: 1px; border-bottom-style: dotted;} ul.tabs a.mandrill-section span, -ul.tabs a.mandrill-section:hover span { background:url(mandrill-tab.png) no-repeat 0 0; overflow:hidden; padding:0; padding-left:25px; width:120px; height:22px;} -ul.tabs a.mandrill-section.active, ul.tabs a.mandrill-section.active:hover {background-color: white;} +ul.tabs a.mandrill-section:hover span { background:url(mandrill-tab.png) no-repeat 20px 0; overflow:hidden; padding:0; padding-left:45px; width:120px; height:22px;} +ul.tabs a.mandrill-section.active, ul.tabs a.mandrill-section.active:hover {background-color: white;border-bottom-color: #8BA5A5;} small { font-size: 9px; }