diff --git a/README.md b/README.md index cb510b3..bf146e6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ All rights belong to EbizMarts and the only changes we are making are: ## Version -1.1.0 as of 2013-02-25 +1.1.5 as of 2013-03-20 Please always check http://ebizmarts.com for the latest version and do let us know if we fall behind. 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..9bae456 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(); } 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..60f3f06 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); } } } 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..d684477 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Block/Email/Order/Items.php @@ -0,0 +1,9 @@ +setTemplate('ebizmarts_abandonedcart/email_order_items.phtml'); + } +} \ 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..587d0f2 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Config.php @@ -0,0 +1,26 @@ +getStores(); foreach($allStores as $storeid => $val) { - $this->_proccess($storeid); + if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE,$storeid)) { + $this->_proccess($storeid); + } } } @@ -21,14 +23,14 @@ public function abandoned() */ protected function _proccess($store) { - Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $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); if(!$days) { return; @@ -38,29 +40,38 @@ protected function _proccess($store) // 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') + ->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.updated_at', array('to' => $from,'from' => $firstdate)) ->addFieldToFilter('main_table.ebizmarts_abandonedcart_counter',array('lt' => $maxtimes)); $collection->addFieldToFilter('main_table.customer_email', array('neq' => '')); -// Mage::log((string)$collection->getSelect()); // for each cart foreach($collection as $quote) { + // ckeck 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(); $data = array('AbandonedURL'=>$url, 'AbandonedDate' => $quote->getUpdatedAt()); // send email $mailsubject = 'Abandoned Cart'; - $senderid = Mage::getStoreConfig("ebizmarts_abandonedcart/general/identity", $store); + $senderid = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::SENDER, $store); $sender = array('name'=>Mage::getStoreConfig("trans_email/ident_$senderid/name"), 'email'=> Mage::getStoreConfig("trans_email/ident_$senderid/email")); $email = $quote->getCustomerEmail(); @@ -69,20 +80,24 @@ protected function _proccess($store) $quote2 = Mage::getModel('sales/quote')->loadByIdWithoutStore($quote->getId()); if($sendcoupon && $quote2->getEbizmartsAbandonedcartCounter() + 1 == $sendcoupondays) { + $templateId = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::EMAIL_TEMPLATE_XML_PATH); // 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); + 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); + } + else { + $couponcode = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_CODE); + $vars = array('quote'=>$quote,'url'=>$url, 'couponcode'=>$couponcode, 'name' => $name); + } } else { - $templateId = Mage::getStoreConfig(self::EMAIL_TEMPLATE_XML_PATH); + $templateId = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::EMAIL_TEMPLATE_XML_PATH); $vars = array('quote'=>$quote,'url'=>$url); } $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); + $mail = 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 +112,11 @@ 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); $fromDate = date("Y-m-d"); $toDate = date('Y-m-d', strtotime($fromDate. " + $couponexpiredays day")); @@ -131,7 +146,7 @@ protected function _createNewCoupon($store,$email) ->setStoreLabels(array($couponlabel)) ->setSimpleAction($action) ->setDiscountAmount($couponamount) - ->setDiscountQty(1) + ->setDiscountQty(0) ->setDiscountStep('0') ->setSimpleFreeShipping('0') ->setApplyToShipping('0') 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..bf0e642 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Order/Collection.php +++ b/app/code/community/Ebizmarts/AbandonedCart/Model/Resource/Order/Collection.php @@ -6,7 +6,7 @@ * 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 { /** * @param string $period @@ -67,15 +67,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/etc/config.xml b/app/code/community/Ebizmarts/AbandonedCart/etc/config.xml index 678fae6..791dd15 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.10 @@ -14,11 +14,6 @@ sales/abandoned_cart.html html - @@ -47,6 +42,11 @@ + + + * + + @@ -69,6 +69,15 @@ + + + + + Ebizmarts_AbandonedCart.csv + + + + diff --git a/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml b/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml index 388a01e..a8fd079 100644 --- a/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml +++ b/app/code/community/Ebizmarts/AbandonedCart/etc/system.xml @@ -33,6 +33,20 @@ 1 1 + + + date + ebizmarts_abandonedcart/adminhtml_system_config_date + 12 + 1 + 1 + 1 + + + 1 + + + select @@ -130,6 +144,29 @@ 1 + + + select + ebizmarts_abandonedcart/system_config_automatic + 115 + 1 + 1 + 1 + + + + text + 120 + 1 + 1 + 1 + 0 + + + 1 + 1 + + text @@ -141,6 +178,7 @@ 1 + 2 @@ -154,6 +192,7 @@ 1 + 2 @@ -168,6 +207,7 @@ 1 + 2 @@ -181,6 +221,7 @@ 1 + 2 @@ -194,6 +235,7 @@ 1 + 2 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..4a823f1 --- /dev/null +++ b/app/code/community/Ebizmarts/AbandonedCart/sql/ebizmarts_abandonedcart_setup/mysql4-upgrade-0.1.6-0.1.7.php @@ -0,0 +1,19 @@ +startSetup(); + +$installer->run(" + + ALTER TABLE `{$this->getTable('sales_flat_order')}` + add column ebizmarts_abandonedcart_flag int(1) default '0' + "); + +$installer->endSetup(); \ No newline at end of file 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..9b2e65c 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( diff --git a/app/code/community/Ebizmarts/MageMonkey/etc/config.xml b/app/code/community/Ebizmarts/MageMonkey/etc/config.xml index 44053ab..d5b17d0 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.5 diff --git a/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php b/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php index ff68d89..ac68317 100644 --- a/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php +++ b/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php @@ -159,5 +159,12 @@ public function setReplyTo($email) { $this->replyTo = $email; return $this; } + public function createAttachment($body, + $mimeType = Zend_Mime::TYPE_OCTETSTREAM, + $disposition = Zend_Mime::DISPOSITION_ATTACHMENT, + $encoding = Zend_Mime::ENCODING_BASE64, + $filename = null) + { + } } 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..72e748d 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 @@ -1,4 +1,6 @@ -getQuote() ?> +getQuote(); +$currency = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); +?> @@ -8,15 +10,41 @@ - - getAllItems() as $_item): ?> - getParentItem()) continue; else $i++; ?> - > - getItemHtml($_item) ?> - - - - getChildHtml('order_totals') ?> + getAllItems() as $_item):?> + getParentItemId()): continue; endif;?> + 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'])) { + foreach($options['bundle_options'] as $bundle) + { + $aux_options[] = array('label' => $bundle['label'], 'value' => $bundle['value'][0]['qty'] .' x '. $bundle['value'][0]['title'] .' '. Mage::helper('checkout')->formatPrice($bundle['value'][0]['price'])); + } + $result = array_merge($result, $aux_options); + } + } + $options = array_merge($finalResult, $result); + endif; ?> + + '. $_item['name']; ?> +
'.$option['label'].'
'.'
'.$option['value'].'
'; endforeach; $options = null; endif; '' ?> + '. $_item['sku'] .''; ?> + '. $_item['qty'] .''; ?> + ' .Mage::helper('checkout')->formatPrice($_item['row_total']) .''; ?> + + -
__('Subtotal') ?>
+ \ No newline at end of file diff --git a/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items/order/default.phtml b/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items/order/default.phtml deleted file mode 100644 index 2904c8c..0000000 --- a/app/design/frontend/base/default/template/ebizmarts_abandonedcart/email/order/items/order/default.phtml +++ /dev/null @@ -1,111 +0,0 @@ -getItem() ?> -getItem()->getQuote() ?> - - - htmlEscape($_item->getName()) ?> - getItemOptions()): ?> -
- getItemOptions() as $option): ?> -
-
- escapeHtml($option['value'])) ?> -
- -
- - getProductAdditionalInformationBlock(); ?> - - setItem($_item)->toHtml(); ?> - - escapeHtml($_item->getDescription()) ?> - - htmlEscape($this->getSku($_item)) ?> - getQtyOrdered()*1 ?> - - helper('tax')->displaySalesPriceExclTax($_quote->getStoreId()) || $this->helper('tax')->displaySalesBothPrices($_quote->getStore())): ?> - helper('tax')->displaySalesBothPrices($_quote->getStoreId())): ?> - __('Excl. Tax'); ?>: - - typeOfDisplay($_item, array(0, 1, 4), 'email', $_quote->getStore())): ?> - getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - - getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_item->getRowTotal()) ?> - - - - getApplied($_item)): ?> -
- typeOfDisplay($_item, 1, 'email', $_quote->getStore())): ?> - - getApplied($_item) as $tax): ?> - : getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount'],true,true); ?>
- -
- typeOfDisplay($_item, 2, 'email', $_quote->getStoreId())): ?> - getApplied($_item) as $tax): ?> - : getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?>
- - typeOfDisplay($_item, 4, 'email', $_quote->getStoreId())): ?> - - getApplied($_item) as $tax): ?> - : getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?>
- -
- - - typeOfDisplay($_item, 2, 'email', $_quote->getStore())): ?> -
- __('Total'); ?>:
getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
- - - - - - helper('tax')->displaySalesPriceInclTax($_quote->getStoreId()) || $this->helper('tax')->displaySalesBothPrices($_quote->getStoreId())): ?> - helper('tax')->displaySalesBothPrices($_quote->getStoreId())): ?> -
__('Incl. Tax'); ?>: - - helper('checkout')->getSubtotalInclTax($_item); ?> - typeOfDisplay($_item, array(0, 1, 4), 'email', $_quote->getStoreId())): ?> - getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - - getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_incl-$_item->getWeeeTaxRowDisposition()) ?> - - getApplied($_item)): ?> -
- typeOfDisplay($_item, 1, 'email', $_quote->getStore())): ?> - - getApplied($_item) as $tax): ?> - : getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount'],true,true); ?>
- -
- typeOfDisplay($_item, 2, 'email', $_quote->getStoreId())): ?> - getApplied($_item) as $tax): ?> - : getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?>
- - typeOfDisplay($_item, 4, 'email', $_quote->getStoreId())): ?> - - getApplied($_item) as $tax): ?> - : getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($tax['row_amount_incl_tax'],true,true); ?>
- -
- - - typeOfDisplay($_item, 2, 'email', $_quote->getStoreId())): ?> - __('Total incl. tax'); ?>:
getLocale()->currency($_quote->getQuoteCurrencyCode())->toCurrency($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
- - - - - -getGiftMessageId() && $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_item->getGiftMessageId())): ?> - - - __('Gift Message') ?> - __('From:'); ?> htmlEscape($_giftMessage->getSender()) ?>
- __('To:'); ?> htmlEscape($_giftMessage->getRecipient()) ?>
- __('Message:'); ?>
htmlEscape($_giftMessage->getMessage()) ?> - - - 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/sales/abandoned_cart.html b/app/locale/en_US/template/email/sales/abandoned_cart.html index 1f01629..ce8daa3 100644 --- a/app/locale/en_US/template/email/sales/abandoned_cart.html +++ b/app/locale/en_US/template/email/sales/abandoned_cart.html @@ -11,20 +11,22 @@ -

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}} diff --git a/lib/Mandrill/API.php b/lib/Mandrill/API.php index 6c3a9c0..416233e 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,17 @@ 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; + } } \ No newline at end of file diff --git a/modman b/modman index 8ad1afa..f997ed6 100644 --- a/modman +++ b/modman @@ -3,6 +3,7 @@ app/code/community/Ebizmarts/MageMonkey/ app/cod 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/etc/modules/Ebizmarts_Mandrill.xml app/etc/modules/Ebizmarts_Mandrill.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/ @@ -12,8 +13,10 @@ app/design/frontend/base/default/layout/ebizmarts_abandonedcart.xml app/des 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/template/email/sales/abandoned_cart.html app/locale/en_US/template/email/sales/abandoned_cart.html +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 lib/Mandrill/ lib/Mandrill/ skin/adminhtml/default/default/magemonkey/ skin/adminhtml/default/default/magemonkey/ skin/adminhtml/default/default/mandrill/ skin/adminhtml/default/default/mandrill/