Cartin24_Clearcart - Version 1.0.0

Version Notes

Cartin24 creates an extension for Magento which clears the customer's cart via admin. The extension provides an easy way to clear the cart items which have been in the cart of customer's for long time. “Clear All Guest Carts” Button removes all products from guest’s cart. By using this extension admin can clear all cart items added by the users by clicking "Clear All Carts" Button. We have also another option to clear the cart items of selected customers. The extension is only having backend settings.

Download this release

Release Info

Developer Cartin24
Extension Cartin24_Clearcart
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Cartin24/Clearcart/Block/Adminhtml/Clearcart.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Cartin24_Clearcart_Block_Adminhtml_Clearcart extends Mage_Adminhtml_Block_Widget_Grid_Container
11
+ {
12
+ public function __construct()
13
+ {
14
+ $this->_controller = 'adminhtml_clearcart';
15
+ $this->_blockGroup = 'clearcart';
16
+ $this->_headerText = Mage::helper('clearcart')->__('Manage Carts');
17
+
18
+ $this->_addButton('clearcar_guest', array(
19
+ 'label' => $this->__('Clear All Guest Carts'),
20
+ 'onclick' => "setLocation('".$this->getUrl('*/*/clearguest')."')",
21
+ ));
22
+
23
+ $this->_addButton('clearcart_controller', array(
24
+ 'label' => $this->__('Clear All Carts'),
25
+ 'onclick' => "setLocation('".$this->getUrl('*/*/clearall')."')",
26
+ ));
27
+
28
+ parent::__construct();
29
+ $this->_removeButton('add');
30
+ }
31
+ }
app/code/community/Cartin24/Clearcart/Block/Adminhtml/Clearcart/Grid.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Cartin24_Clearcart_Block_Adminhtml_Clearcart_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('clearcartGrid');
16
+ $this->setDefaultSort('clearcart_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setSaveParametersInSession(true);
19
+ }
20
+
21
+ protected function _prepareCollection()
22
+ {
23
+
24
+ $collection = Mage::getModel('checkout/cart')->getQuote()
25
+ ->getCollection()
26
+ ->addFieldToFilter('items_count',array('gt' => 0))
27
+ ->addFieldToFilter('customer_id',array('gt' => 0));
28
+ $this->setCollection($collection);
29
+ return parent::_prepareCollection();
30
+ }
31
+
32
+ protected function _prepareColumns()
33
+ {
34
+ $this->addColumn('customer_firstname', array(
35
+ 'header' => Mage::helper('clearcart')->__('Name'),
36
+ 'align' => 'left',
37
+ 'width' => '100px',
38
+ 'index' => 'customer_firstname',
39
+ 'renderer' => new Cartin24_Clearcart_Block_Adminhtml_Renderer_CustomerName(),
40
+
41
+ ));
42
+
43
+ $this->addColumn('customer_email', array(
44
+ 'header' => Mage::helper('clearcart')->__('Email'),
45
+ 'align' =>'right',
46
+ 'width' => '50px',
47
+ 'index' => 'customer_email',
48
+
49
+ ));
50
+ $this->addColumn('items_count', array(
51
+ 'header' => Mage::helper('clearcart')->__('No of Cart Items'),
52
+ 'align' => 'left',
53
+ 'width' => '120px',
54
+ 'default' => '--',
55
+ 'index' => 'items_count',
56
+
57
+ ));
58
+ $this->addColumn('created_at', array(
59
+ 'header' => Mage::helper('clearcart')->__('Date'),
60
+ 'align' => 'left',
61
+ 'width' => '120px',
62
+ 'default' => '--',
63
+ 'sortable' => true,
64
+ 'index' => 'created_at',
65
+
66
+ ));
67
+ $this->addColumn('Clear',
68
+ array(
69
+ 'header' => Mage::helper('clearcart')->__('Clear'),
70
+ 'width' => '50px',
71
+ 'type' => 'action',
72
+ 'getter' => 'getId',
73
+ 'actions' => array(
74
+ array(
75
+ 'caption' => Mage::helper('clearcart')->__('Clear'),
76
+ 'url' => array(
77
+ 'base'=>'*/*/clear',
78
+ 'params'=>array('store'=>$this->getRequest()->getParam('store'))
79
+ ),
80
+ 'field' => 'id'
81
+ )
82
+ ),
83
+ 'filter' => false,
84
+ 'sortable' => false,
85
+ 'index' => 'stores',
86
+ ));
87
+
88
+ return parent::_prepareColumns();
89
+ }
90
+
91
+ protected function _prepareMassaction()
92
+ {
93
+ $this->setMassactionIdField('entity_id');
94
+ $this->getMassactionBlock()->setFormFieldName('quoteId');
95
+ $this->getMassactionBlock()->addItem('clear', array(
96
+ 'label' => Mage::helper('clearcart')->__('Clear'),
97
+ 'url' => $this->getUrl('*/*/massDelete'),
98
+ 'confirm' => Mage::helper('clearcart')->__('Are you sure, you want to clear the selected carts?')
99
+ ));
100
+ return $this;
101
+ }
102
+
103
+ public function getRowUrl($row)
104
+ {
105
+ return false;
106
+ }
107
+ }
app/code/community/Cartin24/Clearcart/Block/Adminhtml/Renderer/CustomerName.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Cartin24_Clearcart_Block_Adminhtml_Renderer_CustomerName extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
10
+ {
11
+ # Merge customer's first name and last name in a single admin grid field
12
+
13
+ public function render(Varien_Object $row) {
14
+ if ($row->getData('customer_firstname') != NULL || $row->getData('customer_lastname') != NULL){
15
+
16
+ $firstName = $row->getData('customer_firstname');
17
+ $lastName = $row->getData('customer_lastname');
18
+
19
+ if ($lastName != NULL) {
20
+ return $firstName . ' ' . $lastName;
21
+ }else {
22
+ return $firstName;
23
+ }
24
+
25
+ } else {
26
+ return Mage::helper('clearcart')->__('UNKNOWN USER');
27
+ }
28
+
29
+ }
30
+ }
31
+ ?>
app/code/community/Cartin24/Clearcart/Helper/Data.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Cartin24_Clearcart_Helper_Data extends Mage_Core_Helper_Abstract {
11
+
12
+ }
app/code/community/Cartin24/Clearcart/controllers/Adminhtml/ClearcartController.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Cartin24_Clearcart_Adminhtml_ClearcartController extends Mage_Adminhtml_Controller_action
11
+ {
12
+ protected function _initAction(){
13
+ $this->loadLayout()
14
+ ->_setActiveMenu('clearcart/items')
15
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Carts'), Mage::helper('adminhtml')->__('Manage Carts'));
16
+ return $this;
17
+
18
+ }
19
+
20
+ public function indexAction() {
21
+
22
+ $this->_initAction();
23
+ $this->renderLayout();
24
+ }
25
+
26
+ # clear cart of a specific customer
27
+
28
+ public function clearAction(){
29
+ if( $this->getRequest()->getParam('id') > 0 ) {
30
+ try {
31
+ $idval = $this->getRequest()->getParam('id');
32
+
33
+ $quoteItems = Mage::getModel('checkout/cart')->getQuote()
34
+ ->getCollection()
35
+ ->addFieldToFilter('entity_id',$idval);
36
+ $quoteItems->walk("delete");
37
+
38
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Cart is successfully cleared.'));
39
+ $this->_redirect('*/*/');
40
+ } catch (Exception $e) {
41
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
42
+ }
43
+ }
44
+ $this->_redirect('*/*/');
45
+ }
46
+
47
+
48
+ # clearing all carts
49
+
50
+ public function clearallAction(){
51
+ try {
52
+ $quoteCollection = Mage::getModel('sales/quote')
53
+ ->getCollection();
54
+ foreach ($quoteCollection as $item) {
55
+ $item->delete();
56
+ }
57
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Successfully cleared all cart items.'));
58
+ } catch (Exception $e) {
59
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
60
+ }
61
+
62
+ $this->_redirect('*/*/');
63
+ }
64
+
65
+
66
+ # clearing all guest cart items
67
+
68
+ public function clearguestAction(){
69
+ try {
70
+ $quoteCollection = Mage::getModel('sales/quote')
71
+ ->getCollection()
72
+ ->addFieldToFilter('customer_id', array('null' => true));
73
+ foreach ($quoteCollection as $item) {
74
+ $item->delete();
75
+ }
76
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__("All guest cart items are successfully cleared."));
77
+ } catch (Exception $e) {
78
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
79
+ }
80
+ $this->_redirect('*/*/');
81
+ }
82
+
83
+
84
+ # clearing selected customer's cart
85
+
86
+ public function massDeleteAction(){
87
+ $ids = $this->getRequest()->getParam('quoteId');
88
+ if(!is_array($ids)) {
89
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Item(s)'));
90
+ } else {
91
+ try {
92
+ foreach ($ids as $id) {
93
+ $banners = Mage::getModel('sales/quote')->getCollection()->addFieldToFilter('entity_id',$id);
94
+ $banners->walk("delete");
95
+ }
96
+ Mage::getSingleton('adminhtml/session')->addSuccess(
97
+ Mage::helper('adminhtml')->__(
98
+ 'Total of %d record(s) are successfully deleted', count($ids)
99
+ )
100
+ );
101
+ } catch (Exception $e) {
102
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
103
+ }
104
+ }
105
+ $this->_redirect('*/*/index');
106
+ }
107
+
108
+ # Permission Allowed
109
+
110
+ protected function _isAllowed(){
111
+ return true;
112
+ }
113
+
114
+ }
app/code/community/Cartin24/Clearcart/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ -->
9
+
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <clearcart translate="title" module="clearcart">
20
+ <title>Clear Cart</title>
21
+ </clearcart>
22
+ </children>
23
+ </config>
24
+ </children>
25
+ </system>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>
app/code/community/Cartin24/Clearcart/etc/config.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ -->
9
+
10
+ <config>
11
+ <modules>
12
+ <Cartin24_Clearcart>
13
+ <version>1.0.0</version>
14
+ </Cartin24_Clearcart>
15
+ </modules>
16
+ <admin>
17
+ <routers>
18
+ <adminhtml>
19
+ <args>
20
+ <modules>
21
+ <Cartin24_Clearcart after="Mage_Adminhtml">Cartin24_Clearcart_Adminhtml</Cartin24_Clearcart>
22
+ </modules>
23
+ </args>
24
+ </adminhtml>
25
+ </routers>
26
+ </admin>
27
+ <adminhtml>
28
+ <menu>
29
+ <clearcart module="clearcart">
30
+ <title>Clear Cart</title>
31
+ <sort_order>85</sort_order>
32
+ <action>adminhtml/clearcart</action>
33
+ </clearcart>
34
+ </menu>
35
+ <acl>
36
+ <resources>
37
+ <all>
38
+ <title>Allow Everything</title>
39
+ </all>
40
+ <admin>
41
+ <children>
42
+ <clearcart module="clearcart">
43
+ <title>Clear Cart</title>
44
+ <sort_order>85</sort_order>
45
+ </clearcart>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ <layout>
51
+ <updates>
52
+ <clearcart>
53
+ <file>clearcart.xml</file>
54
+ </clearcart>
55
+ </updates>
56
+ </layout>
57
+ </adminhtml>
58
+ <global>
59
+ <models>
60
+ <clearcart>
61
+ <class>Cartin24_Clearcart_Model</class>
62
+ </clearcart>
63
+ </models>
64
+ <blocks>
65
+ <clearcart>
66
+ <class>Cartin24_Clearcart_Block</class>
67
+ </clearcart>
68
+ </blocks>
69
+ <helpers>
70
+ <clearcart>
71
+ <class>Cartin24_Clearcart_Helper</class>
72
+ </clearcart>
73
+ </helpers>
74
+ </global>
75
+ </config>
app/design/adminhtml/default/default/layout/clearcart.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ -->
9
+
10
+ <layout>
11
+ <adminhtml_clearcart_index>
12
+ <reference name="content">
13
+ <block type="clearcart/adminhtml_clearcart" name="clearcart" />
14
+ </reference>
15
+ </adminhtml_clearcart_index>
16
+ </layout>
app/etc/modules/Cartin24_Clearcart.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Cartin24
5
+ * @package Cartin24_Clearcart
6
+ * @copyright Copyright (c) 2015-2016 Cartin24. (http://www.cartin24.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ -->
9
+
10
+ <config>
11
+ <modules>
12
+ <Cartin24_Clearcart>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Cartin24_Clearcart>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Cartin24_Clearcart</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Cartin24 creates an extension for Magento which clears the customer's cart via admin.</summary>
10
+ <description>Cartin24 creates an extension for Magento which clears the customer's cart via admin. The extension provides an easy way to clear the cart items which have been in the cart of customer's for long time. &#x201C;Clear All Guest Carts&#x201D; Button removes all products from guest&#x2019;s cart. By using this extension admin can clear all cart items added by the users by clicking "Clear All Carts" Button. We have also another option to clear the cart items of selected customers. The extension is only having backend settings.</description>
11
+ <notes>Cartin24 creates an extension for Magento which clears the customer's cart via admin. The extension provides an easy way to clear the cart items which have been in the cart of customer's for long time. &#x201C;Clear All Guest Carts&#x201D; Button removes all products from guest&#x2019;s cart. By using this extension admin can clear all cart items added by the users by clicking "Clear All Carts" Button. We have also another option to clear the cart items of selected customers. The extension is only having backend settings.</notes>
12
+ <authors><author><name>Cartin24</name><user>Cartin24</user><email>developer@cartin24.com</email></author></authors>
13
+ <date>2016-08-16</date>
14
+ <time>09:19:09</time>
15
+ <contents><target name="magecommunity"><dir name="Cartin24"><dir name="Clearcart"><dir name="Block"><dir name="Adminhtml"><dir name="Clearcart"><file name="Grid.php" hash="ed23e1e80dc5522fe1daec0153663698"/></dir><file name="Clearcart.php" hash="66d8f347e6d1b2d8d2e620588b3f5d63"/><dir name="Renderer"><file name="CustomerName.php" hash="1fad3b38932f89507446148c1d6f0b5e"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="09988c01d3c9f05fb0cfd78a70e2d773"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ClearcartController.php" hash="50aa7ec0716c11120d3e48c6b877e710"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e1a3a67a5b2cfeb1688296874ae7cb75"/><file name="config.xml" hash="b0e6479333ef997ca7f15adf6fce22e1"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cartin24_Clearcart.xml" hash="f318253bf5a44e7b8bbbbc85a761d25f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="clearcart.xml" hash="5579028a03f13474f4c0ca66754c8036"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>