Smasoft_Oneclickorder - Version 0.1.0

Version Notes

Add extension code

Download this release

Release Info

Developer Slabko Michail
Extension Smasoft_Oneclickorder
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (43) hide show
  1. app/code/community/Smasoft/Oneclickorder/Block/Abstract.php +42 -0
  2. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders.php +34 -0
  3. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/Grid.php +165 -0
  4. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/Grid/Filter/Filter.php +25 -0
  5. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/Grid/Renderer/Customer.php +38 -0
  6. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View.php +60 -0
  7. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Tab/Cart.php +185 -0
  8. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Tab/View.php +101 -0
  9. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Tabs.php +26 -0
  10. app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Totals.php +71 -0
  11. app/code/community/Smasoft/Oneclickorder/Block/Email/Items.php +19 -0
  12. app/code/community/Smasoft/Oneclickorder/Block/Form.php +56 -0
  13. app/code/community/Smasoft/Oneclickorder/Block/Success.php +69 -0
  14. app/code/community/Smasoft/Oneclickorder/Helper/Data.php +101 -0
  15. app/code/community/Smasoft/Oneclickorder/Helper/Email.php +57 -0
  16. app/code/community/Smasoft/Oneclickorder/Model/Country.php +29 -0
  17. app/code/community/Smasoft/Oneclickorder/Model/Observer.php +82 -0
  18. app/code/community/Smasoft/Oneclickorder/Model/Order.php +108 -0
  19. app/code/community/Smasoft/Oneclickorder/Model/Payment/Method/Oneclick.php +42 -0
  20. app/code/community/Smasoft/Oneclickorder/Model/Resource/Country.php +30 -0
  21. app/code/community/Smasoft/Oneclickorder/Model/Resource/Country/Collection.php +46 -0
  22. app/code/community/Smasoft/Oneclickorder/Model/Resource/Order.php +33 -0
  23. app/code/community/Smasoft/Oneclickorder/Model/Resource/Order/Collection.php +54 -0
  24. app/code/community/Smasoft/Oneclickorder/Model/ServiceQuote.php +26 -0
  25. app/code/community/Smasoft/Oneclickorder/Model/System/Config/Source/Country.php +35 -0
  26. app/code/community/Smasoft/Oneclickorder/controllers/Adminhtml/OneclickorderController.php +93 -0
  27. app/code/community/Smasoft/Oneclickorder/controllers/IndexController.php +221 -0
  28. app/code/community/Smasoft/Oneclickorder/etc/adminhtml.xml +49 -0
  29. app/code/community/Smasoft/Oneclickorder/etc/config.xml +188 -0
  30. app/code/community/Smasoft/Oneclickorder/etc/system.xml +138 -0
  31. app/code/community/Smasoft/Oneclickorder/sql/oneclickorder_setup/mysql4-install-0.1.0.php +55 -0
  32. app/design/adminhtml/default/default/layout/smasoft/oneclickorder.xml +34 -0
  33. app/design/adminhtml/default/default/template/smasoft/oneclickorder/view.phtml +205 -0
  34. app/design/frontend/base/default/layout/smasoft/oneclickorder.xml +46 -0
  35. app/design/frontend/base/default/template/smasoft/oneclickorder/email/items.phtml +24 -0
  36. app/design/frontend/base/default/template/smasoft/oneclickorder/form.phtml +103 -0
  37. app/design/frontend/base/default/template/smasoft/oneclickorder/success.phtml +26 -0
  38. app/etc/modules/Smasoft_Oneclickorder.xml +15 -0
  39. app/locale/ru_RU/Smasoft_Oneclickorder.csv +26 -0
  40. package.xml +29 -0
  41. skin/frontend/default/default/css/oneclickorder.css +96 -0
  42. skin/frontend/default/default/images/oneclickorder/comment.png +0 -0
  43. skin/frontend/default/default/images/oneclickorder/telephone.png +0 -0
app/code/community/Smasoft/Oneclickorder/Block/Abstract.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+
18
+ class Smasoft_Oneclickorder_Block_Abstract extends Mage_Core_Block_Template
19
+ {
20
+
21
+ /**
22
+ * @return Smasoft_Oneclickorder_Helper_Data
23
+ */
24
+ public function getModuleHelper()
25
+ {
26
+ return Mage::helper('smasoft_oneclickorder');
27
+ }
28
+
29
+ protected function _toHtml()
30
+ {
31
+ if (!$this->getModuleHelper()->isEnabled()) {
32
+ return '';
33
+ }
34
+ return parent::_toHtml();
35
+ }
36
+
37
+ public function isGuest()
38
+ {
39
+ return !(bool)Mage::getSingleton('customer/session')->getCustomerId();
40
+ }
41
+
42
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders extends Mage_Adminhtml_Block_Widget_Grid_Container
18
+ {
19
+ /**
20
+ * Block constructor
21
+ */
22
+ public function __construct()
23
+ {
24
+ $this->_blockGroup = 'smasoft_oneclickorder';
25
+ $this->_controller = 'adminhtml_orders';
26
+ $this->_headerText = Mage::helper('smasoft_oneclickorder')->__('Manage OneClick Orders');
27
+
28
+ parent::__construct();
29
+
30
+ $this->_removeButton('add');
31
+
32
+ }
33
+
34
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/Grid.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_Grid extends Mage_Adminhtml_Block_Widget_Grid
18
+ {
19
+
20
+
21
+ /**
22
+ * Init Grid default properties
23
+ *
24
+ */
25
+ public function __construct()
26
+ {
27
+ parent::__construct();
28
+ $this->setId('oneclickorder_list_grid');
29
+ $this->setDefaultSort('entity_id');
30
+ $this->setDefaultDir('DESC');
31
+ $this->setSaveParametersInSession(true);
32
+ $this->setUseAjax(true);
33
+
34
+ }
35
+
36
+ protected function _prepareCollectionBefore()
37
+ {
38
+ /** @var $collection Smasoft_Oneclickorder_Model_Resource_Order_Collection */
39
+ $collection = Mage::getModel('smasoft_oneclickorder/order')->getCollection();
40
+ $collection->getSelect()->joinLeft(
41
+ array('country' => Mage::getModel('smasoft_oneclickorder/country')->getResource()
42
+ ->getTable('smasoft_oneclickorder/country')),
43
+ 'country.country_code = main_table.country',
44
+ array('country.country_code', 'country.phone_code')
45
+ );
46
+ $collection->joinCustomerAttribute('firstname');
47
+ $collection->joinCustomerAttribute('lastname');
48
+
49
+ return $collection;
50
+ }
51
+
52
+
53
+ /**
54
+ * @return this
55
+ */
56
+ protected function _prepareCollection()
57
+ {
58
+ $collection = $this->_prepareCollectionBefore();
59
+ $this->setCollection($collection);
60
+ return parent::_prepareCollection();
61
+ }
62
+
63
+
64
+ /**
65
+ * Prepare Grid columns
66
+ *
67
+ * @return Mage_Adminhtml_Block_Widget_Grid
68
+ */
69
+ protected function _prepareColumns()
70
+ {
71
+ $this->_customFieldsOptions();
72
+ return parent::_prepareColumns();
73
+ }
74
+
75
+ protected function _customFieldsOptions()
76
+ {
77
+ /** @var $helper Smasoft_Oneclickorder_Helper_Data */
78
+ $helper = Mage::helper('smasoft_oneclickorder');
79
+ $this->addColumn('entity_id', array(
80
+ 'header' => $helper->__('#'),
81
+ 'width' => '10px',
82
+ 'index' => 'entity_id',
83
+ 'filter_index' => 'main_table.entity_id',
84
+ ));
85
+
86
+
87
+ $this->addColumn('customer_id', array(
88
+ 'header' => $helper->__('Customer Name'),
89
+ 'index' => 'customer_id',
90
+ 'getter' => 'getGridCustomerName',
91
+ 'renderer' => 'smasoft_oneclickorder/adminhtml_orders_grid_renderer_customer',
92
+ ));
93
+ $this->addColumn('phone', array(
94
+ 'header' => $helper->__('Phone'),
95
+ 'index' => 'phone',
96
+ 'getter' => 'getFullPhoneNumber',
97
+ 'filter_index' => 'main_table.phone',
98
+ ));
99
+
100
+ $this->addColumn('country', array(
101
+ 'header' => $helper->__('country'),
102
+ 'index' => 'country',
103
+ 'width' => '155px',
104
+ 'empty_option' => $helper->__('All Codes'),
105
+ 'filter' => 'smasoft_oneclickorder/adminhtml_orders_grid_filter_filter',
106
+ 'options' => $helper->getPhoneCodes()->toOptionArray(),
107
+ 'filter_index' => 'main_table.country',
108
+ ));
109
+
110
+ $this->addColumn('create_date', array(
111
+ 'header' => $helper->__('Create Date'),
112
+ 'index' => 'create_date',
113
+ 'filter_index' => 'create_date',
114
+ 'type' => 'datetime',
115
+ 'width' => '220px',
116
+ ));
117
+
118
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/oneclick_order/view')) {
119
+ $this->addColumn('action',
120
+ array(
121
+ 'header' => $helper->__('Action'),
122
+ 'type' => 'action',
123
+ 'actions' => array(
124
+ array(
125
+ 'caption' => $helper->__('View'),
126
+ 'url' => $this->getUrl('*/oneclickorder/view', array('id' => '$entity_id')),
127
+ 'field' => 'entity_id'
128
+ ),
129
+ ),
130
+ 'filter' => false,
131
+ 'sortable' => false,
132
+ 'index' => 'smasoft_oneclickorder',
133
+ 'is_system' => true,
134
+ 'width' => 100
135
+ ));
136
+ }
137
+
138
+ }
139
+
140
+ /**
141
+ * Return row URL for js event handlers
142
+ *
143
+ * @param null $row
144
+ * @return string
145
+ */
146
+ public function getRowUrl($row)
147
+ {
148
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/oneclick_order/view')) {
149
+ return $this->getUrl('*/oneclickorder/view', array('id' => $row->getEntityId()));
150
+ }
151
+ return null;
152
+ }
153
+
154
+ /**
155
+ * Grid url getter
156
+ *
157
+ * @return string current grid url
158
+ */
159
+ public function getGridUrl()
160
+ {
161
+ return $this->getUrl('adminhtml/oneclickorder/grid', array('_current' => true));
162
+ }
163
+
164
+
165
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/Grid/Filter/Filter.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_Grid_Filter_Filter extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
17
+ {
18
+
19
+ protected function _getOptions()
20
+ {
21
+ $options = $this->getColumn()->getOptions();
22
+ array_unshift($options, array('value' => '', 'label' => $this->getColumn()->getEmptyOption()));
23
+ return $options;
24
+ }
25
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/Grid/Renderer/Customer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+
18
+ /**
19
+ * Сustomer field grid renderer
20
+ */
21
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_Grid_Renderer_Customer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
22
+ {
23
+ /**
24
+ * @param Varien_Object $row
25
+ * @return string
26
+ */
27
+ public function render(Varien_Object $row)
28
+ {
29
+ if ($row->getCustomerId()) {
30
+ $name = $row->getFirstname() . ' ' . $row->getLastname();
31
+ $result = sprintf('<a href="%s">%s</a>', Mage::getUrl('adminhtml/customer/edit', array('id' => $row->getCustomerId())), $name);
32
+ } else {
33
+ $result = 'Guest';
34
+ }
35
+
36
+ return $result;
37
+ }
38
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_View extends Mage_Adminhtml_Block_Widget_Form_Container
18
+ {
19
+
20
+ public function __construct()
21
+ {
22
+ $this->_objectId = 'order_id';
23
+ $this->_controller = 'sales_order';
24
+ $this->_mode = 'view';
25
+ parent::__construct();
26
+
27
+ $this->_removeButton('delete');
28
+ $this->_removeButton('reset');
29
+ $this->_removeButton('save');
30
+ $this->setId('sales_order_view');
31
+
32
+ }
33
+
34
+ /**
35
+ * Retrieve order model object
36
+ *
37
+ * @return Smasoft_Oneclickorder_Model_Order
38
+ */
39
+ public function getOrder()
40
+ {
41
+ return Mage::registry('order');
42
+ }
43
+
44
+ /**
45
+ * Return back url for view grid
46
+ *
47
+ * @return string
48
+ */
49
+ public function getBackUrl()
50
+ {
51
+ return $this->getUrl('*/*/index');
52
+ }
53
+
54
+
55
+ public function getHeaderText()
56
+ {
57
+ return Mage::helper('sales')->__('Order # %s | %s', $this->getOrder()->getEntityId(), $this->formatDate($this->getOrder()->getCreateDate(), 'medium', true));
58
+ }
59
+
60
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Tab/Cart.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+
18
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_View_Tab_Cart
19
+ extends Mage_Adminhtml_Block_Widget_Grid
20
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
21
+ {
22
+
23
+
24
+ public function __construct($attributes = array())
25
+ {
26
+ parent::__construct($attributes);
27
+ $this->setUseAjax(true);
28
+ $this->setFilterVisibility(false);
29
+ $this->_parentTemplate = $this->getTemplate();
30
+ $this->setTemplate('customer/tab/cart.phtml');
31
+ }
32
+
33
+ /**
34
+ * Retrieve order model instance
35
+ *
36
+ * @return Smasoft_Oneclickorder_Model_Order
37
+ */
38
+ public function getOrder()
39
+ {
40
+ return Mage::registry('order');
41
+ }
42
+
43
+ /**
44
+ * Prepare grid
45
+ *
46
+ * @return void
47
+ */
48
+ protected function _prepareGrid()
49
+ {
50
+ $this->setId('customer_cart_grid');
51
+ parent::_prepareGrid();
52
+ }
53
+
54
+
55
+ protected function _prepareCollection()
56
+ {
57
+ $quote = $this->getOrder()->getQuote();
58
+ if ($quote) {
59
+ $collection = $quote->getItemsCollection(false);
60
+ } else {
61
+ $collection = new Varien_Data_Collection();
62
+ }
63
+ $collection->addFieldToFilter('parent_item_id', array('null' => true));
64
+ $this->setCollection($collection);
65
+
66
+ return parent::_prepareCollection();
67
+ }
68
+
69
+ /**
70
+ * Gets customer assigned to this block
71
+ *
72
+ * @return Mage_Customer_Model_Customer
73
+ */
74
+ public function getCustomer()
75
+ {
76
+ return $this->getOrder()->getCustomer();
77
+ }
78
+
79
+
80
+ protected function _prepareColumns()
81
+ {
82
+ $this->addColumn('product_id', array(
83
+ 'header' => Mage::helper('catalog')->__('Product ID'),
84
+ 'index' => 'product_id',
85
+ 'width' => '100px',
86
+ ));
87
+
88
+ $this->addColumn('name', array(
89
+ 'header' => Mage::helper('catalog')->__('Product Name'),
90
+ 'index' => 'name',
91
+ 'renderer' => 'adminhtml/customer_edit_tab_view_grid_renderer_item'
92
+ ));
93
+
94
+ $this->addColumn('sku', array(
95
+ 'header' => Mage::helper('catalog')->__('SKU'),
96
+ 'index' => 'sku',
97
+ 'width' => '100px',
98
+ ));
99
+
100
+ $this->addColumn('qty', array(
101
+ 'header' => Mage::helper('catalog')->__('Qty'),
102
+ 'index' => 'qty',
103
+ 'type' => 'number',
104
+ 'width' => '60px',
105
+ ));
106
+
107
+ $this->addColumn('price', array(
108
+ 'header' => Mage::helper('catalog')->__('Price'),
109
+ 'index' => 'price',
110
+ 'type' => 'currency',
111
+ 'currency_code' => (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
112
+ ));
113
+
114
+ $this->addColumn('total', array(
115
+ 'header' => Mage::helper('sales')->__('Total'),
116
+ 'index' => 'row_total',
117
+ 'type' => 'currency',
118
+ 'currency_code' => (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
119
+ ));
120
+
121
+ $this->addColumn('action', array(
122
+ 'header' => Mage::helper('customer')->__('Action'),
123
+ 'index' => 'quote_item_id',
124
+ 'renderer' => 'adminhtml/customer_grid_renderer_multiaction',
125
+ 'filter' => false,
126
+ 'sortable' => false,
127
+ 'actions' => array(
128
+ array(
129
+ 'caption' => Mage::helper('customer')->__('View'),
130
+ 'url' => $this->getUrl('*/catalog_product/edit', array('id' => '$product_id')),
131
+ 'field' => '$product_id'
132
+ ),
133
+
134
+ )
135
+ ));
136
+
137
+ return parent::_prepareColumns();
138
+ }
139
+
140
+
141
+ public function getGridParentHtml()
142
+ {
143
+ $templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, array('_relative' => true));
144
+ return $this->fetchView($templateName);
145
+ }
146
+
147
+ public function getRowUrl($row)
148
+ {
149
+ return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
150
+ }
151
+
152
+
153
+ /**
154
+ * Grid url getter
155
+ *
156
+ * @return string current grid url
157
+ */
158
+ public function getGridUrl()
159
+ {
160
+ return $this->getUrl('adminhtml/oneclickorder/cartgrid', array('_current' => true));
161
+ }
162
+
163
+ /**
164
+ * ######################## TAB settings #################################
165
+ */
166
+ public function getTabLabel()
167
+ {
168
+ return Mage::helper('customer')->__('Shopping Cart');
169
+ }
170
+
171
+ public function getTabTitle()
172
+ {
173
+ return Mage::helper('sales')->__('Order Information');
174
+ }
175
+
176
+ public function canShowTab()
177
+ {
178
+ return true;
179
+ }
180
+
181
+ public function isHidden()
182
+ {
183
+ return false;
184
+ }
185
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Tab/View.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_View_Tab_View
18
+ extends Mage_Adminhtml_Block_Sales_Order_Abstract
19
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
20
+ {
21
+ /**
22
+ * Retrieve order model instance
23
+ *
24
+ * @return Smasoft_Oneclickorder_Model_Order
25
+ */
26
+ public function getOrder()
27
+ {
28
+ return Mage::registry('order');
29
+ }
30
+
31
+ /**
32
+ * @return Smasoft_Oneclickorder_Helper_Data
33
+ */
34
+ public function getHelper()
35
+ {
36
+ return Mage::helper('smasoft_oneclickorder');
37
+ }
38
+
39
+
40
+ public function getCustomerViewUrl()
41
+ {
42
+ }
43
+
44
+ /**
45
+ * Retrieve source model instance
46
+ *
47
+ * @return Mage_Sales_Model_Order
48
+ */
49
+ public function getSource()
50
+ {
51
+ return $this->getOrder();
52
+ }
53
+
54
+ public function getMagentoOrderUrl($orderId)
55
+ {
56
+ return $this->getUrl('*/sales_order/view/', array('order_id' => $orderId));
57
+ }
58
+
59
+
60
+ public function getOrderStoreName()
61
+ {
62
+ if ($this->getOrder()) {
63
+ $storeId = $this->getOrder()->getStoreId();
64
+ if (is_null($storeId)) {
65
+ $deleted = Mage::helper('adminhtml')->__(' [deleted]');
66
+ return nl2br($this->getOrder()->getStoreName()) . $deleted;
67
+ }
68
+ $store = Mage::app()->getStore($storeId);
69
+ $name = array(
70
+ $store->getWebsite()->getName(),
71
+ $store->getGroup()->getName(),
72
+ $store->getName()
73
+ );
74
+ return implode('<br/>', $name);
75
+ }
76
+ return null;
77
+ }
78
+
79
+ /**
80
+ * ######################## TAB settings #################################
81
+ */
82
+ public function getTabLabel()
83
+ {
84
+ return Mage::helper('sales')->__('Information');
85
+ }
86
+
87
+ public function getTabTitle()
88
+ {
89
+ return Mage::helper('sales')->__('Order Information');
90
+ }
91
+
92
+ public function canShowTab()
93
+ {
94
+ return true;
95
+ }
96
+
97
+ public function isHidden()
98
+ {
99
+ return false;
100
+ }
101
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Tabs.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_View_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
18
+ {
19
+ public function __construct()
20
+ {
21
+ parent::__construct();
22
+ $this->setId('sales_order_view_tabs');
23
+ $this->setDestElementId('sales_order_view');
24
+ $this->setTitle(Mage::helper('sales')->__('Order View'));
25
+ }
26
+ }
app/code/community/Smasoft/Oneclickorder/Block/Adminhtml/Orders/View/Totals.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Adminhtml_Orders_View_Totals extends Mage_Adminhtml_Block_Sales_Totals //Mage_Adminhtml_Block_Sales_Order_Abstract
18
+ {
19
+
20
+
21
+ /**
22
+ * Retrieve order model object
23
+ *
24
+ * @return Smasoft_Oneclickorder_Model_Order
25
+ */
26
+ public function getOrder()
27
+ {
28
+ return Mage::registry('order');
29
+ }
30
+
31
+ /**
32
+ * @return Mage_Sales_Model_Quote
33
+ */
34
+ public function getSource()
35
+ {
36
+ return $this->getOrder()->getQuote();
37
+ }
38
+
39
+ /**
40
+ * Initialize order totals array
41
+ *
42
+ * @return Mage_Sales_Block_Order_Totals
43
+ */
44
+ protected function _initTotals()
45
+ {
46
+ parent::_initTotals();
47
+ $this->_totals['count'] = new Varien_Object(array(
48
+ 'code' => 'count',
49
+ 'strong' => true,
50
+ 'is_formated' => true,
51
+ 'value' => $this->getSource()->getItemsCount(),
52
+ 'base_value' => $this->getSource()->getItemsCount(),
53
+ 'label' => $this->helper('smasoft_oneclickorder')->__('Total items'),
54
+ 'area' => 'footer'
55
+ ));
56
+
57
+ $magentoOrder = $this->getOrder()->getMagentoOrder();
58
+
59
+ if ($magentoOrder) {
60
+ $this->_totals['paid'] = new Varien_Object(array(
61
+ 'code' => 'paid',
62
+ 'strong' => true,
63
+ 'value' => $magentoOrder->getTotalPaid(),
64
+ 'base_value' => $magentoOrder->getBaseTotalPaid(),
65
+ 'label' => $this->helper('sales')->__('Total Paid'),
66
+ 'area' => 'footer'
67
+ ));
68
+ }
69
+ return $this;
70
+ }
71
+ }
app/code/community/Smasoft/Oneclickorder/Block/Email/Items.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Smasoft_Oneclickorder_Block_Email_Items extends Mage_Core_Block_Template
17
+ {
18
+
19
+ }
app/code/community/Smasoft/Oneclickorder/Block/Form.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Block_Form extends Smasoft_Oneclickorder_Block_Abstract
18
+ {
19
+ public function getPhoneCodeHtml($name, $class = '', $withCountryName = true, $emptyLabel = 'Code')
20
+ {
21
+ $codesCollection = $this->getModuleHelper()->getPhoneCodes();
22
+ $codes = $codesCollection->toOptionArray($withCountryName);
23
+
24
+ if (count($codes) > 1) {
25
+ $options = array_merge(
26
+ array(array(
27
+ 'value' => '',
28
+ 'label' => $emptyLabel,
29
+ )),
30
+ $codes
31
+ );
32
+
33
+ $selectedValue = '';
34
+
35
+ $html = $this->getLayout()->createBlock('core/html_select')
36
+ ->setName($name)
37
+ ->setId('oneclickorder-phone-code')
38
+ ->setClass($class)
39
+ ->setValue($selectedValue)
40
+ ->setOptions($options)
41
+ ->getHtml();
42
+ } else {
43
+ $item = $codesCollection->getFirstItem();
44
+ $html = "<input type=\"hidden\" name=\"$name\" value=\"{$item->getCountryCode()}\" /><span class=\"$class\">+{$item->getPhoneCode()}</span> ";
45
+ }
46
+ return $html;
47
+ }
48
+
49
+ /**
50
+ * need o render email field. Only for guest and if magento order is enabled
51
+ */
52
+ public function isShowEmailField()
53
+ {
54
+ return $this->getModuleHelper()->isSaveMagentoOrder() && $this->isGuest();
55
+ }
56
+ }
app/code/community/Smasoft/Oneclickorder/Block/Success.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Smasoft_Oneclickorder_Block_Success extends Smasoft_Oneclickorder_Block_Abstract
17
+ {
18
+
19
+ /**
20
+ * @return null|string
21
+ */
22
+ public function getOrderId()
23
+ {
24
+ $id = $this->_getData('order_id');
25
+ return $id ? str_pad($id, 6, '0', STR_PAD_LEFT) : null;
26
+ }
27
+
28
+ /**
29
+ * @return null|string
30
+ */
31
+ public function getPhoneNumber()
32
+ {
33
+ return $this->_getData('phone');
34
+ }
35
+
36
+ /**
37
+ * @return bool
38
+ */
39
+ public function isShowMagentoOrderSuccess()
40
+ {
41
+ if (Mage::helper('smasoft_oneclickorder')->isSaveMagentoOrder() && $this->_getData('magento_order_id')) {
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+
47
+ protected function _prepareData()
48
+ {
49
+ $orderId = Mage::getSingleton('checkout/session')->getOneclickOrderId();
50
+ if ($orderId) {
51
+ /** @var $order Smasoft_Oneclickorder_Model_Order */
52
+ $order = Mage::getModel('smasoft_oneclickorder/order')->load($orderId);
53
+ if ($order->getId()) {
54
+ $this->addData(array(
55
+ 'order_id' => $orderId,
56
+ 'phone' => $order->getFullPhoneNumber(),
57
+ 'magento_order_id' => $order->getMagentoOrderId(),
58
+ ));
59
+ }
60
+ }
61
+
62
+ }
63
+
64
+ protected function _beforeToHtml()
65
+ {
66
+ $this->_prepareData();
67
+ parent::_beforeToHtml();
68
+ }
69
+ }
app/code/community/Smasoft/Oneclickorder/Helper/Data.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Smasoft_Oneclickorder_Helper_Data extends Mage_Core_Helper_Abstract
17
+ {
18
+ const XML_PATH_ENABLED = 'smasoft_oneclickorder/general/enabled';
19
+ const XML_PATH_CREATE_MAGENTO_ORDER = 'smasoft_oneclickorder/general/create_magento_order';
20
+ const XML_PATH_SEND_EMAIL = 'smasoft_oneclickorder/general/send_email';
21
+ const XML_PATH_EMAIL = 'smasoft_oneclickorder/general/email';
22
+ const XML_PATH_CHANGE_ONEPAGE_CHECKOUT = 'smasoft_oneclickorder/checkout/change_onepage';
23
+ const XML_PATH_ALLOW_COUNTRIES = 'smasoft_oneclickorder/general/allow_countries';
24
+
25
+ /**
26
+ * Is OneClick Order functionality enabled
27
+ * @return bool
28
+ */
29
+ public function isEnabled()
30
+ {
31
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED);
32
+ }
33
+
34
+ /**
35
+ * change onepage checkout with OneClick Order
36
+ * @return bool
37
+ */
38
+ public function isChangeOnepageCheckout()
39
+ {
40
+ return Mage::getStoreConfigFlag(self::XML_PATH_CHANGE_ONEPAGE_CHECKOUT);
41
+ }
42
+
43
+ /**
44
+ * Save OneClick Order in Magento
45
+ * @return bool
46
+ */
47
+ public function isSaveMagentoOrder()
48
+ {
49
+ return Mage::getStoreConfigFlag(self::XML_PATH_CREATE_MAGENTO_ORDER);
50
+ }
51
+
52
+
53
+ /**
54
+ * Send email address to admin
55
+ * @return bool
56
+ */
57
+ public function isSendEmail()
58
+ {
59
+ return Mage::getStoreConfigFlag(self::XML_PATH_SEND_EMAIL);
60
+ }
61
+
62
+ /**
63
+ * get admin email address for send
64
+ * @return bool|string
65
+ */
66
+ public function getOrderNotificationEmail()
67
+ {
68
+ $email = false;
69
+ if ($this->isSendEmail()) {
70
+ $email = Mage::getStoreConfig(self::XML_PATH_EMAIL);
71
+ if (!$email) {
72
+ $email = Mage::getStoreConfig('trans_email/ident_general/email');
73
+ }
74
+ }
75
+ return $email;
76
+ }
77
+
78
+ /**
79
+ * @return array
80
+ */
81
+ public function getAllowCountries()
82
+ {
83
+ $codes = Mage::getStoreConfig(self::XML_PATH_ALLOW_COUNTRIES);
84
+ return explode(',', $codes);
85
+ }
86
+
87
+ /**
88
+ * @return Smasoft_Oneclickorder_Model_Resource_Country_Collection
89
+ */
90
+ public function getPhoneCodes()
91
+ {
92
+ /** @var $collection Smasoft_Oneclickorder_Model_Resource_Country_Collection */
93
+ $collection = Mage::getResourceModel('smasoft_oneclickorder/country_collection');
94
+ $collection->addFieldToFilter('country_code', array('in' => $this->getAllowCountries()));
95
+ $collection->setOrder('main_table.order', Varien_Data_Collection::SORT_ORDER_ASC);
96
+ return $collection;
97
+ }
98
+
99
+
100
+ }
101
+
app/code/community/Smasoft/Oneclickorder/Helper/Email.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Helper_Email extends Mage_Core_Helper_Abstract
18
+ {
19
+ const XML_PATH_ADMIN_EMAIL_TEMPLATE = 'smasoft_oneclickorder/general/template_admin';
20
+
21
+ /**
22
+ * @param Smasoft_Oneclickorder_Model_Order $order
23
+ * @return Smasoft_Oneclickorder_Helper_Email
24
+ */
25
+ public function sendOrderEmailToAdmin($order)
26
+ {
27
+ /** @var $helper Smasoft_Oneclickorder_Helper_Data */
28
+ $helper = Mage::helper('smasoft_oneclickorder');
29
+ $translate = Mage::getSingleton('core/translate');
30
+ /* @var $translate Mage_Core_Model_Translate */
31
+ $translate->setTranslateInline(false);
32
+
33
+ $mailTemplate = Mage::getModel('core/email_template');
34
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
35
+
36
+ $template = Mage::getStoreConfig(self::XML_PATH_ADMIN_EMAIL_TEMPLATE);
37
+ $recipientEmail = $helper->getOrderNotificationEmail();
38
+ $recipientName = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME);
39
+ $customer = $order->getCustomer();
40
+
41
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
42
+ ->sendTransactional(
43
+ $template,
44
+ 'general',
45
+ $recipientEmail,
46
+ $recipientName,
47
+ array(
48
+ 'customer' => $customer,
49
+ 'order' => $order,
50
+ 'invoice' => $order->getQuote()
51
+ )
52
+ );
53
+
54
+ $translate->setTranslateInline(true);
55
+ return $this;
56
+ }
57
+ }
app/code/community/Smasoft/Oneclickorder/Model/Country.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Model_Country extends Mage_Core_Model_Abstract
18
+ {
19
+
20
+ /**
21
+ * Initialize resources
22
+ */
23
+ protected function _construct()
24
+ {
25
+ $this->_init('smasoft_oneclickorder/country');
26
+ }
27
+
28
+
29
+ }
app/code/community/Smasoft/Oneclickorder/Model/Observer.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Smasoft_Oneclickorder_Model_Observer
17
+ {
18
+
19
+ /**
20
+ * @return Smasoft_Oneclickorder_Helper_Data
21
+ */
22
+ protected function _helper()
23
+ {
24
+ return Mage::helper('smasoft_oneclickorder');
25
+ }
26
+
27
+ /**
28
+ * @dispatch checkout_type_onepage_save_order_after
29
+ * @param Varien_Event_Observer $observer
30
+ */
31
+ public function saveMagentoOrderId(Varien_Event_Observer $observer)
32
+ {
33
+ if ($this->_helper()->isSaveMagentoOrder()) {
34
+ $model = Mage::registry('oneclickorder_order_instance');
35
+ if ($model && $model instanceof Smasoft_Oneclickorder_Model_Order && $model->getId()) {
36
+ $order = $observer->getEvent()->getOrder();
37
+ $model->setMagentoOrderId($order->getId())->save();
38
+ }
39
+ Mage::unregister('oneclickorder_order_instance');
40
+ }
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Change standard OnePage checkout with One Click Order checkout
46
+ * @param Varien_Event_Observer $observer
47
+ * @return Smasoft_Oneclickorder_Model_Observer
48
+ */
49
+ public function changeOnepageCheckout(Varien_Event_Observer $observer)
50
+ {
51
+ switch ($observer->getEvent()->getName()) {
52
+ case 'controller_action_layout_generate_blocks_after':
53
+ /** @var $action Mage_Core_Controller_Varien_Action */
54
+ $action = $observer->getEvent()->getAction();
55
+ /** @var $layout Mage_Core_Model_Layout */
56
+ $layout = $observer->getEvent()->getLayout();
57
+ if ($action->getFullActionName() == 'checkout_cart_index' && $this->_helper()->isEnabled() && $this->_helper()->isChangeOnepageCheckout()) {
58
+ $block = $layout->getBlock('checkout.cart.methods');
59
+ if ($block && $block instanceof Mage_Core_Block_Abstract) {
60
+ $block->unsetChild('checkout.cart.methods.onepage');
61
+ }
62
+ $block = $layout->getBlock('checkout.cart.top_methods');
63
+ if ($block && $block instanceof Mage_Core_Block_Abstract) {
64
+ $block->unsetChild('checkout.cart.methods.onepage');
65
+ }
66
+ }
67
+
68
+ break;
69
+ case 'controller_action_predispatch_checkout_onepage_index':
70
+ if ($this->_helper()->isEnabled() && $this->_helper()->isChangeOnepageCheckout()) {
71
+ /** @var $action Mage_Core_Controller_Varien_Action */
72
+ $action = $observer->getEvent()->getControllerAction();
73
+ if ($action) {
74
+ $action->getResponse()->setRedirect(Mage::getUrl('checkout/cart/index'));
75
+ }
76
+ }
77
+
78
+ break;
79
+ }
80
+ return $this;
81
+ }
82
+ }
app/code/community/Smasoft/Oneclickorder/Model/Order.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ /**
18
+ * @method int getQuoteId
19
+ * @method int getCustomerId
20
+ * @method int getMagentoOrderId
21
+ * @method int getStoreId
22
+ * @method string getPhone
23
+ * @method string getComment
24
+ * @method string getCountry
25
+ * @method string getCreateDate
26
+
27
+ */
28
+ class Smasoft_Oneclickorder_Model_Order extends Mage_Core_Model_Abstract
29
+ {
30
+
31
+ /**
32
+ * Initialize resources
33
+ */
34
+ protected function _construct()
35
+ {
36
+ $this->_init('smasoft_oneclickorder/order');
37
+ }
38
+
39
+ /**
40
+ * @return string
41
+ */
42
+ public function getFullPhoneNumber()
43
+ {
44
+ if ($this->getPhoneCode()) {
45
+ return '+' . $this->getPhoneCode() . ' ' . $this->getPhone();
46
+ }
47
+ return '+' . $this->getCountryModel()->getPhoneCode() . ' ' . $this->getPhone();
48
+ }
49
+
50
+ /**
51
+ * get customer for order
52
+ *
53
+ * @return Mage_Customer_Model_Customer
54
+ */
55
+ public function getCustomer()
56
+ {
57
+ $customer = Mage::getModel('customer/customer')->load($this->getCustomerId());
58
+ if (!$customer->getId()) {
59
+ $customer->setIsGuest(true);
60
+ }
61
+ return $customer;
62
+ }
63
+
64
+ /**
65
+ * @return Mage_Sales_Model_Quote
66
+ */
67
+ public function getQuote()
68
+ {
69
+ return Mage::getModel('sales/quote')->getCollection()
70
+ ->addFieldToFilter('entity_id', $this->getQuoteId())
71
+ ->getFirstItem();
72
+ }
73
+
74
+
75
+ /**
76
+ * @return Mage_Sales_Model_Quote
77
+ */
78
+ public function getMagentoOrder()
79
+ {
80
+ return $this->getMagentoOrderId() ?
81
+ Mage::getModel('sales/order')->load($this->getMagentoOrderId())
82
+ : null;
83
+ }
84
+
85
+ /**
86
+ * @return Smasoft_Oneclickorder_Model_Country
87
+ */
88
+ public function getCountryModel()
89
+ {
90
+ return Mage::getModel('smasoft_oneclickorder/country')->load($this->getCountry(), 'country_code');
91
+ }
92
+
93
+ /**
94
+ * Get object created at date affected with object store timezone
95
+ *
96
+ * @return Zend_Date
97
+ */
98
+ public function getCreatedAtStoreDate()
99
+ {
100
+ return Mage::app()->getLocale()->storeDate(
101
+ $this->getStoreId(),
102
+ strtotime($this->getCreateDate()),
103
+ true
104
+ );
105
+ }
106
+
107
+
108
+ }
app/code/community/Smasoft/Oneclickorder/Model/Payment/Method/Oneclick.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ /**
18
+ * Dummy oneclick order payment method model
19
+ */
20
+ class Smasoft_Oneclickorder_Model_Payment_Method_Oneclick extends Mage_Payment_Model_Method_Abstract
21
+ {
22
+
23
+ protected $_canUseCheckout = false;
24
+
25
+ /**
26
+ * Payment method code
27
+ *
28
+ * @var string
29
+ */
30
+ protected $_code = 'smasoft_oneclickorder';
31
+
32
+ public function canUseForCountry($country)
33
+ {
34
+ return true;
35
+ }
36
+
37
+ public function isAvailable($quote = null)
38
+ {
39
+ return true;
40
+ }
41
+
42
+ }
app/code/community/Smasoft/Oneclickorder/Model/Resource/Country.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Model_Resource_Country extends Mage_Core_Model_Mysql4_Abstract
18
+ {
19
+
20
+ /**
21
+ * Initialize resource model
22
+ *
23
+ */
24
+ protected function _construct()
25
+ {
26
+ $this->_init('smasoft_oneclickorder/country', 'entity_id');
27
+ }
28
+
29
+
30
+ }
app/code/community/Smasoft/Oneclickorder/Model/Resource/Country/Collection.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ /**
17
+ * extend Mage_Core_Model_Mysql4_Collection_Abstract for compatibility with old version
18
+ */
19
+ class Smasoft_Oneclickorder_Model_Resource_Country_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
20
+ {
21
+ /**
22
+ * Define resource model
23
+ *
24
+ */
25
+ protected function _construct()
26
+ {
27
+ $this->_init('smasoft_oneclickorder/country');
28
+ }
29
+
30
+ public function toOptionArray($withCountryName = true)
31
+ {
32
+ $res = array();
33
+
34
+ foreach ($this as $item) {
35
+ $label = '+' . $item->getPhoneCode();
36
+ if ($withCountryName) {
37
+ $label .= ' (' . Mage::app()->getLocale()->getCountryTranslation($item->getCountryCode()) . ')';
38
+ }
39
+ $res[] = array(
40
+ 'value' => $item->getCountryCode(),
41
+ 'label' => $label
42
+ );
43
+ }
44
+ return $res;
45
+ }
46
+ }
app/code/community/Smasoft/Oneclickorder/Model/Resource/Order.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ /**
18
+ * use Mage_Core_Model_Mysql4_Abstract for compatibility with old versions
19
+ */
20
+ class Smasoft_Oneclickorder_Model_Resource_Order extends Mage_Core_Model_Mysql4_Abstract
21
+ {
22
+
23
+ /**
24
+ * Initialize resource model
25
+ *
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('smasoft_oneclickorder/order', 'entity_id');
30
+ }
31
+
32
+
33
+ }
app/code/community/Smasoft/Oneclickorder/Model/Resource/Order/Collection.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Model_Resource_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
18
+ {
19
+ /**
20
+ * Define resource model
21
+ *
22
+ */
23
+ protected function _construct()
24
+ {
25
+ $this->_init('smasoft_oneclickorder/order');
26
+ }
27
+
28
+
29
+ /**
30
+ * Join Eav table
31
+ * @param $attributeCode
32
+ * @return Smasoft_Oneclickorder_Model_Resource_Order_Collection
33
+ */
34
+ public function joinCustomerAttribute($attributeCode)
35
+ {
36
+ //join that attribute table using attribute id and customer id
37
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
38
+ if ($attribute) {
39
+ $entityType = Mage::getModel('eav/entity_type')->loadByCode('customer');
40
+ $entityTable = $this->getTable($entityType->getEntityTable()); //customer_entity
41
+ if ($attribute->getBackendType() == 'static') {
42
+ $table = $entityTable;
43
+ } else {
44
+ $table = $entityTable . '_' . $attribute->getBackendType(); //customer_entity_varchar
45
+ }
46
+ $tableAlias = "$table";
47
+ $this->getSelect()->joinLeft($table,
48
+ 'main_table.customer_id = ' . $tableAlias . '.entity_id and ' . $tableAlias . '.attribute_id = ' . $attribute->getAttributeId(),
49
+ array($attributeCode => $tableAlias . '.value')
50
+ );
51
+ }
52
+ return $this;
53
+ }
54
+ }
app/code/community/Smasoft/Oneclickorder/Model/ServiceQuote.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Smasoft_Oneclickorder_Model_ServiceQuote extends Mage_Sales_Model_Service_Quote
17
+ {
18
+
19
+ protected function _validate()
20
+ {
21
+ if (Mage::registry('oneclickorder_ignore_quote_validation')) {
22
+ return $this;
23
+ }
24
+ return parent::_validate();
25
+ }
26
+ }
app/code/community/Smasoft/Oneclickorder/Model/System/Config/Source/Country.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Model_System_Config_Source_Country
18
+ {
19
+ protected $_options;
20
+
21
+ public function toOptionArray()
22
+ {
23
+ if (!$this->_options) {
24
+ /** @var $codesCollection Smasoft_Oneclickorder_Model_System_Config_Source_Country */
25
+ // comp for < 1.6
26
+ $alias = '`directory/country`';
27
+ $codesCollection = Mage::getResourceModel('smasoft_oneclickorder/country_collection');
28
+ $codesCollection->join('directory/country', "$alias.country_id = main_table.country_code");
29
+ $codesCollection->setOrder('main_table.order', Varien_Data_Collection::SORT_ORDER_ASC);
30
+ $this->_options = $codesCollection->toOptionArray();
31
+ }
32
+ $options = $this->_options;
33
+ return $options;
34
+ }
35
+ }
app/code/community/Smasoft/Oneclickorder/controllers/Adminhtml/OneclickorderController.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class Smasoft_Oneclickorder_Adminhtml_OneclickorderController extends Mage_Adminhtml_Controller_Action
18
+ {
19
+
20
+ protected function _isActionAllowed($action)
21
+ {
22
+ return Mage::getSingleton('admin/session')->isAllowed('sales/oneclick_order/' . $action);
23
+ }
24
+
25
+ public function indexAction()
26
+ {
27
+ $this->loadLayout();
28
+ $this->_initLayoutMessages('adminhtml/session');
29
+ $this->_setActiveMenu('sales/oneclickorder');
30
+ $this->renderLayout();
31
+ }
32
+
33
+ /**
34
+ * grid
35
+ */
36
+ public function gridAction()
37
+ {
38
+ $block = $this->getLayout()->createBlock('smasoft_oneclickorder/adminhtml_orders_grid');
39
+ $this->getResponse()->setBody($block->toHtml());
40
+ }
41
+
42
+ /**
43
+ * grid
44
+ */
45
+ public function cartgridAction()
46
+ {
47
+ $order = Mage::getModel('smasoft_oneclickorder/order')->load(
48
+ $this->getRequest()->getParam('id')
49
+ );
50
+ Mage::register('order', $order);
51
+ $block = $this->getLayout()->createBlock('smasoft_oneclickorder/adminhtml_orders_view_tab_cart');
52
+ $this->getResponse()->setBody($block->toHtml());
53
+ }
54
+
55
+ public function viewAction()
56
+ {
57
+ $order = Mage::getModel('smasoft_oneclickorder/order')->load(
58
+ $this->getRequest()->getParam('id')
59
+ );
60
+ Mage::register('order', $order);
61
+ if (!$order->getId()) {
62
+ return $this->_redirect('*/*/index');
63
+ }
64
+ $this->loadLayout();
65
+ $this->_initLayoutMessages('adminhtml/session');
66
+ $this->_setActiveMenu('sales/oneclickorder');
67
+
68
+
69
+ $this->renderLayout();
70
+ }
71
+
72
+ /**
73
+ * check permissions
74
+ * @return bool
75
+ */
76
+ protected function _isAllowed()
77
+ {
78
+ switch ($this->getRequest()->getActionName()) {
79
+ case 'index':
80
+ case 'grid':
81
+ case 'cartgrid':
82
+ return $this->_isActionAllowed('grid');
83
+ break;
84
+ case 'view':
85
+ return $this->_isActionAllowed('view');
86
+ break;
87
+ case 'delete':
88
+ return $this->_isActionAllowed('delete');
89
+ break;
90
+ }
91
+ return false;
92
+ }
93
+ }
app/code/community/Smasoft/Oneclickorder/controllers/IndexController.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ /**
18
+ * IndexController.php model
19
+ *
20
+ */
21
+ class Smasoft_Oneclickorder_IndexController extends Mage_Core_Controller_Front_Action
22
+ {
23
+
24
+ protected $_errors = array();
25
+
26
+
27
+ /**
28
+ * @return Mage_Checkout_OnepageController
29
+ */
30
+ public function preDispatch()
31
+ {
32
+ parent::preDispatch();
33
+ /** @var $helper Smasoft_Oneclickorder_Helper_Data */
34
+ $helper = Mage::helper('smasoft_oneclickorder');
35
+ if (!$helper->isEnabled()) {
36
+ return $this->_ajaxEnd(array(
37
+ 'error' => $helper->__('Please, use standard checkout for order product.')
38
+ ));
39
+ }
40
+
41
+ }
42
+
43
+ /**
44
+ * Save order in Magento
45
+ * @return bool
46
+ */
47
+ protected function _saveMagentoOrder()
48
+ {
49
+ /** @var $onepage Mage_Checkout_Model_Type_Onepage */
50
+ $onepage = $this->getOnepage();
51
+ try {
52
+ $onepage->savePayment(array(
53
+ 'method' => 'smasoft_oneclickorder',
54
+ ));
55
+ $onepage->getQuote()->collectTotals()->save();
56
+ Mage::register('oneclickorder_ignore_quote_validation', true, true);
57
+ $onepage->saveOrder();
58
+ Mage::unregister('oneclickorder_ignore_quote_validation');
59
+ return true;
60
+ } catch (Exception $e) {
61
+ $this->_errors[] = $message = $e->getMessage();
62
+ }
63
+ return false;
64
+ }
65
+
66
+ /**
67
+ * @param $data
68
+ * @return Smasoft_Oneclickorder_Model_Order
69
+ */
70
+ protected function _saveOrderInfo($data)
71
+ {
72
+ /** @var $model Smasoft_Oneclickorder_Model_Order */
73
+ $model = Mage::getModel('smasoft_oneclickorder/order');
74
+ $model->setData($data);
75
+ $model->setCustomerId($this->_getCustomer()->getId());
76
+ $model->setQuoteId($this->getOnepage()->getQuote()->getId());
77
+ $model->setStoreId(Mage::app()->getStore()->getId());
78
+ $model->setCreateDate(date('Y-m-d h:i:s'));
79
+ $model->save();
80
+ Mage::register('oneclickorder_order_instance', $model, true);
81
+ // save for Guest
82
+ if (isset($data['email'])) {
83
+ $newBillingAddress = Mage::getModel('sales/quote_address');
84
+ $newBillingAddress->setEmail($data['email']);
85
+ $this->getOnepage()->getQuote()->setBillingAddress($newBillingAddress)->save();
86
+ }
87
+ return $model;
88
+ }
89
+
90
+ /**
91
+ * @return Mage_Customer_Model_Customer
92
+ */
93
+ protected function _getCustomer()
94
+ {
95
+ return Mage::getSingleton('customer/session')->getCustomer();
96
+ }
97
+
98
+ /**
99
+ * Is current customer guest
100
+ * @return bool
101
+ */
102
+ protected function _isGuest()
103
+ {
104
+ return !(bool)Mage::getSingleton('customer/session')->getCustomerId();
105
+ }
106
+
107
+ protected function _ajaxEnd($data)
108
+ {
109
+ return $this->getResponse()->setBody(
110
+ Mage::helper('core')->jsonEncode($data)
111
+ );
112
+ }
113
+
114
+ /**
115
+ * @return string
116
+ */
117
+ protected function _getErrors()
118
+ {
119
+ return implode("\n", $this->_errors);
120
+ }
121
+
122
+ /**
123
+ * @param $data
124
+ * @return bool
125
+ */
126
+ protected function _validateData($data)
127
+ {
128
+ /** @var $helper Smasoft_Oneclickorder_Helper_Data */
129
+ $helper = Mage::helper('smasoft_oneclickorder');
130
+
131
+ $this->_filterInput($data);
132
+ if (!$data['phone'] || !$data['country'] || ($this->_isGuest() && $helper->isSaveMagentoOrder() && !$data['email'])) {
133
+ $this->_errors[] = $helper->__('Please, fill required fields');
134
+ }
135
+ if (isset($data['email']) && !Zend_Validate::is($data['email'], 'Zend_Validate_EmailAddress')) {
136
+ $this->_errors[] = $helper->__('Please enter a valid email address.');
137
+ }
138
+ return !(bool)count($this->_errors);
139
+ }
140
+
141
+ protected function _filterInput($data)
142
+ {
143
+ foreach ($data as &$v) {
144
+ $v = trim(strip_tags($v));
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Get one page checkout model
150
+ *
151
+ * @return Mage_Checkout_Model_Type_Onepage
152
+ */
153
+ public function getOnepage()
154
+ {
155
+ return Mage::getSingleton('checkout/type_onepage');
156
+ }
157
+
158
+
159
+ public function saveOrderAction()
160
+ {
161
+ Mage::getSingleton('checkout/session')->unsOneclickOrderId();
162
+
163
+ /** @var $helper Smasoft_Oneclickorder_Helper_Data */
164
+ $helper = Mage::helper('smasoft_oneclickorder');
165
+
166
+ $checkoutSessionQuote = Mage::getSingleton('checkout/session')->getQuote();
167
+ if ($checkoutSessionQuote->getIsMultiShipping()) {
168
+ $checkoutSessionQuote->setIsMultiShipping(false);
169
+ $checkoutSessionQuote->removeAllAddresses();
170
+ }
171
+
172
+ if (!$this->getOnepage()->getQuote()->hasItems() || $this->getOnepage()->getQuote()->getHasError()) {
173
+ return $this->_ajaxEnd(array(
174
+ 'error' => $helper->__('Please, add item to Cart before order.')
175
+ ));
176
+ }
177
+ $data = $this->getRequest()->getPost('oneclickorder');
178
+ if (!$this->_validateData($data)) {
179
+ return $this->_ajaxEnd(array(
180
+ 'error' => $this->_getErrors()
181
+ ));
182
+ }
183
+
184
+ $order = $this->_saveOrderInfo($data);
185
+ //add comment to customer phone... save order if id
186
+ if ($helper->isSaveMagentoOrder()) {
187
+ $this->_saveMagentoOrder();
188
+ }
189
+
190
+ if ($this->_getErrors()) {
191
+ if ($order->getId()) {
192
+ $order->delete();
193
+ }
194
+ return $this->_ajaxEnd(array(
195
+ 'error' => $this->_getErrors()
196
+ ));
197
+ }
198
+
199
+ $this->getOnepage()->getQuote()->setIsActive(0)->save();
200
+ if ($helper->isSendEmail()) {
201
+ Mage::helper('smasoft_oneclickorder/email')->sendOrderEmailToAdmin($order);
202
+ }
203
+
204
+ Mage::getSingleton('checkout/session')->setOneclickOrderId($order->getId());
205
+ return $this->_ajaxEnd(array(
206
+ 'success' => true,
207
+ 'redirect' => Mage::getUrl('smasoft_oneclickorder/index/success')
208
+ ));
209
+ }
210
+
211
+ public function successAction()
212
+ {
213
+ if (!Mage::getSingleton('checkout/session')->getOneclickOrderId()) {
214
+ return $this->_redirect('checkout/cart/index');
215
+ }
216
+ $this->loadLayout();
217
+
218
+ $this->_initLayoutMessages('checkout/session');
219
+ $this->renderLayout();
220
+ }
221
+ }
app/code/community/Smasoft/Oneclickorder/etc/adminhtml.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <menu>
5
+ <sales>
6
+ <children>
7
+ <oneclick_order translate="title" module="smasoft_oneclickorder">
8
+ <title>One Click Order</title>
9
+ <action>adminhtml/oneclickorder/index</action>
10
+ <sort_order>11</sort_order>
11
+ </oneclick_order>
12
+ </children>
13
+ </sales>
14
+ </menu>
15
+ <acl>
16
+ <resources>
17
+ <admin>
18
+ <children>
19
+ <sales>
20
+ <children>
21
+ <oneclick_order translate="title">
22
+ <title>One Click Order</title>
23
+ <children>
24
+ <grid translate="title">
25
+ <title>Grid</title>
26
+ </grid>
27
+ <view translate="title">
28
+ <title>View</title>
29
+ </view>
30
+ </children>
31
+ </oneclick_order>
32
+ </children>
33
+ </sales>
34
+ <system>
35
+ <children>
36
+ <config>
37
+ <children>
38
+ <smasoft_oneclickorder translate="title" module="smasoft_oneclickorder">
39
+ <title>One Click Order Settings</title>
40
+ </smasoft_oneclickorder>
41
+ </children>
42
+ </config>
43
+ </children>
44
+ </system>
45
+ </children>
46
+ </admin>
47
+ </resources>
48
+ </acl>
49
+ </config>
app/code/community/Smasoft/Oneclickorder/etc/config.xml ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Smasoft_Oneclickorder>
6
+ <version>0.1.0</version>
7
+ </Smasoft_Oneclickorder>
8
+ </modules>
9
+ <global>
10
+ <helpers>
11
+ <smasoft_oneclickorder>
12
+ <class>Smasoft_Oneclickorder_Helper</class>
13
+ </smasoft_oneclickorder>
14
+ </helpers>
15
+ <models>
16
+ <smasoft_oneclickorder>
17
+ <class>Smasoft_Oneclickorder_Model</class>
18
+ <resourceModel>smasoft_oneclickorder_resources</resourceModel>
19
+ </smasoft_oneclickorder>
20
+ <smasoft_oneclickorder_resources>
21
+ <class>Smasoft_Oneclickorder_Model_Resource</class>
22
+ <entities>
23
+ <order>
24
+ <table>smasoft_oneclickorder_orders</table>
25
+ </order>
26
+ <country>
27
+ <table>smasoft_oneclickorder_country</table>
28
+ </country>
29
+ </entities>
30
+ </smasoft_oneclickorder_resources>
31
+ <sales>
32
+ <rewrite>
33
+ <service_quote>Smasoft_Oneclickorder_Model_ServiceQuote</service_quote>
34
+ </rewrite>
35
+ </sales>
36
+ </models>
37
+ <blocks>
38
+ <smasoft_oneclickorder>
39
+ <class>Smasoft_Oneclickorder_Block</class>
40
+ </smasoft_oneclickorder>
41
+ </blocks>
42
+ <resources>
43
+ <oneclickorder_setup>
44
+ <setup>
45
+ <module>Smasoft_Oneclickorder</module>
46
+ </setup>
47
+ <connection>
48
+ <use>core_setup</use>
49
+ </connection>
50
+ </oneclickorder_setup>
51
+ <oneclickorder_write>
52
+ <connection>
53
+ <use>core_write</use>
54
+ </connection>
55
+ </oneclickorder_write>
56
+ <oneclickorder_read>
57
+ <connection>
58
+ <use>core_read</use>
59
+ </connection>
60
+ </oneclickorder_read>
61
+ </resources>
62
+ <events>
63
+
64
+ <checkout_type_onepage_save_order_after>
65
+ <observers>
66
+ <smasoft_events>
67
+ <class>smasoft_oneclickorder/observer</class>
68
+ <method>saveMagentoOrderId</method>
69
+ </smasoft_events>
70
+ </observers>
71
+ </checkout_type_onepage_save_order_after>
72
+
73
+ <controller_action_layout_generate_blocks_after>
74
+ <observers>
75
+ <smasoft_events>
76
+ <class>smasoft_oneclickorder/observer</class>
77
+ <method>changeOnepageCheckout</method>
78
+ </smasoft_events>
79
+ </observers>
80
+ </controller_action_layout_generate_blocks_after>
81
+
82
+ <controller_action_predispatch_checkout_onepage_index>
83
+ <observers>
84
+ <smasoft_events>
85
+ <class>smasoft_oneclickorder/observer</class>
86
+ <method>changeOnepageCheckout</method>
87
+ </smasoft_events>
88
+ </observers>
89
+ </controller_action_predispatch_checkout_onepage_index>
90
+ </events>
91
+ <template>
92
+ <email>
93
+ <smasoft_oneclickorder_general_template_admin translate="label" module="smasoft_oneclickorder">
94
+ <label>OneClick Order Admin Email template</label>
95
+ <file>oneclickorder/admin_order.html</file>
96
+ <type>html</type>
97
+ </smasoft_oneclickorder_general_template_admin>
98
+ </email>
99
+ </template>
100
+ </global>
101
+
102
+ <frontend>
103
+ <routers>
104
+ <smasoft_oneclickorder>
105
+ <use>standard</use>
106
+ <args>
107
+ <module>Smasoft_Oneclickorder</module>
108
+ <frontName>oneclickorder</frontName>
109
+ </args>
110
+ </smasoft_oneclickorder>
111
+ </routers>
112
+ <translate>
113
+ <modules>
114
+ <Smasoft_Oneclickorder>
115
+ <files>
116
+ <default>Smasoft_Oneclickorder.csv</default>
117
+ </files>
118
+ </Smasoft_Oneclickorder>
119
+ </modules>
120
+ </translate>
121
+ <layout>
122
+ <updates>
123
+ <smasoft_oneclickorder>
124
+ <file>smasoft/oneclickorder.xml</file>
125
+ </smasoft_oneclickorder>
126
+ </updates>
127
+ </layout>
128
+ </frontend>
129
+
130
+ <adminhtml>
131
+ <layout>
132
+ <updates>
133
+ <smasoft_oneclickorder>
134
+ <file>smasoft/oneclickorder.xml</file>
135
+ </smasoft_oneclickorder>
136
+ </updates>
137
+ </layout>
138
+ <translate>
139
+ <modules>
140
+ <Smasoft_Oneclickorder>
141
+ <files>
142
+ <default>Smasoft_Oneclickorder.csv</default>
143
+ </files>
144
+ </Smasoft_Oneclickorder>
145
+ </modules>
146
+ </translate>
147
+ </adminhtml>
148
+
149
+ <admin>
150
+ <routers>
151
+ <adminhtml>
152
+ <args>
153
+ <modules>
154
+ <smasoft_oneclickorder before="Mage_Adminhtml">Smasoft_Oneclickorder_Adminhtml</smasoft_oneclickorder>
155
+ </modules>
156
+ </args>
157
+ </adminhtml>
158
+
159
+ </routers>
160
+ </admin>
161
+
162
+ <default>
163
+ <smasoft_oneclickorder>
164
+ <general>
165
+ <create_magento_order>1</create_magento_order>
166
+ <enabled>1</enabled>
167
+ <send_email>0</send_email>
168
+ <template_admin>smasoft_oneclickorder_general_template_admin</template_admin>
169
+ <allow_countries>US,GB,UA,RU</allow_countries>
170
+ </general>
171
+ <checkout>
172
+ <change_onepage>0</change_onepage>
173
+ </checkout>
174
+ </smasoft_oneclickorder>
175
+
176
+ <payment>
177
+ <smasoft_oneclickorder>
178
+ <active>1</active>
179
+ <model>smasoft_oneclickorder/payment_method_oneclick</model>
180
+ <order_status>pending</order_status>
181
+ <title>OneClick Order Dummy Payment Method</title>
182
+ <allowspecific>0</allowspecific>
183
+ <group>offline</group>
184
+ </smasoft_oneclickorder>
185
+ </payment>
186
+ </default>
187
+
188
+ </config>
app/code/community/Smasoft/Oneclickorder/etc/system.xml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <sections>
5
+ <smasoft_oneclickorder translate="label" module="smasoft_oneclickorder">
6
+ <class>separator-top</class>
7
+ <label>One Click Order</label>
8
+ <tab>sales</tab>
9
+ <frontend_type>text</frontend_type>
10
+ <sort_order>1000</sort_order>
11
+ <show_in_default>1</show_in_default>
12
+ <show_in_website>1</show_in_website>
13
+ <show_in_store>1</show_in_store>
14
+ <groups>
15
+ <general translate="label">
16
+ <label>One Click Order General Settings</label>
17
+ <frontend_type>text</frontend_type>
18
+ <expanded>1</expanded>
19
+ <sort_order>5</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>1</show_in_store>
23
+ <fields>
24
+ <enabled translate="label">
25
+ <label>Enabled</label>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>adminhtml/system_config_source_yesno</source_model>
28
+ <sort_order>1</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ </enabled>
33
+ <create_magento_order translate="label comment">
34
+ <label>Create Magento Order</label>
35
+ <comment>Controls whether create Magento Order if possible.</comment>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>2</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </create_magento_order>
43
+ <send_email translate="label">
44
+ <label>Send Email with order info</label>
45
+ <frontend_type>select</frontend_type>
46
+ <source_model>adminhtml/system_config_source_yesno</source_model>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </send_email>
52
+ <email translate="label comment">
53
+ <label>Email Address</label>
54
+ <comment>By default uses General Store Email [General=>Store Email Addresses=>General Contact]</comment>
55
+ <depends>
56
+ <send_email>1</send_email>
57
+ </depends>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>4</sort_order>
60
+ <validate>validate-email</validate>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </email>
65
+ <template_admin translate="label">
66
+ <label>Admin Email Template</label>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>adminhtml/system_config_source_email_template</source_model>
69
+ <sort_order>5</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </template_admin>
74
+ <allow_countries translate="label comment">
75
+ <label>Allow Countries</label>
76
+ <frontend_type>multiselect</frontend_type>
77
+ <source_model>smasoft_oneclickorder/system_config_source_country</source_model>
78
+ <comment>If select more, than one option, on frontend will be shown select-box with selected phone codes</comment>
79
+ <sort_order>6</sort_order>
80
+ <validate>required-entry</validate>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <can_be_empty>0</can_be_empty>
85
+ </allow_countries>
86
+ </fields>
87
+ </general>
88
+ <checkout translate="label">
89
+ <label>One Click Order Checkout Settings</label>
90
+ <frontend_type>text</frontend_type>
91
+ <expanded>1</expanded>
92
+ <sort_order>10</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <fields>
97
+ <change_onepage translate="label comment">
98
+ <label>Change standard One Page Checkout</label>
99
+ <comment>If yes, than standard One Page Checkout will be replaced by One Click Order</comment>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>1</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </change_onepage>
107
+ </fields>
108
+ </checkout>
109
+ </groups>
110
+ </smasoft_oneclickorder>
111
+ <payment>
112
+ <groups>
113
+
114
+ <smasoft_oneclickorder translate="label">
115
+ <label>OneClick Order Payment</label>
116
+ <comment>This is a system payment method for One Click Order, that cannot be use on front-end</comment>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>30</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ <fields>
123
+ <order_status translate="label">
124
+ <label>New Order Status</label>
125
+ <frontend_type>select</frontend_type>
126
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
127
+ <sort_order>20</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>0</show_in_store>
131
+ </order_status>
132
+ </fields>
133
+ </smasoft_oneclickorder>
134
+ </groups>
135
+ </payment>
136
+
137
+ </sections>
138
+ </config>
app/code/community/Smasoft/Oneclickorder/sql/oneclickorder_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Smasoft
11
+ * @package Smasoft_Oneclikorder
12
+ * @copyright Copyright (c) 2013 Slabko Michail. <l.nagash@gmail.com>
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ $installer = $this;
17
+ /* @var $installer Mage_Core_Model_Resource_Setup */
18
+
19
+ $installer->startSetup();
20
+
21
+ $installer->run("
22
+ DROP TABLE IF EXISTS `{$installer->getTable('smasoft_oneclickorder/country')}`;
23
+ CREATE TABLE `{$installer->getTable('smasoft_oneclickorder/country')}` (
24
+ `entity_id` int(10) unsigned NOT NULL auto_increment,
25
+ `phone_code` varchar(9) NOT NULL default '',
26
+ `country_code` varchar(9) NOT NULL default '',
27
+ `order` tinyint(4) default '0',
28
+ PRIMARY KEY (`entity_id`)
29
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30
+
31
+ INSERT INTO `{$installer->getTable('smasoft_oneclickorder/country')}` (`phone_code`, `country_code`,`order`)
32
+ VALUES ('380', 'UA', 1);
33
+ INSERT INTO `{$installer->getTable('smasoft_oneclickorder/country')}` (`phone_code`, `country_code`, `order`)
34
+ VALUES ('7', 'RU', 2);
35
+ INSERT INTO `{$installer->getTable('smasoft_oneclickorder/country')}` (`phone_code`, `country_code`, `order`)
36
+ VALUES ('1', 'US', 3);
37
+ INSERT INTO `{$installer->getTable('smasoft_oneclickorder/country')}` (`phone_code`, `country_code`,`order`)
38
+ VALUES ('44', 'GB', 4);
39
+
40
+ DROP TABLE IF EXISTS `{$installer->getTable('smasoft_oneclickorder/order')}`;
41
+ CREATE TABLE `{$installer->getTable('smasoft_oneclickorder/order')}` (
42
+ `entity_id` int(10) unsigned NOT NULL auto_increment,
43
+ `magento_order_id` int(10) unsigned,
44
+ `customer_id` int(10) unsigned,
45
+ `quote_id` int(10) unsigned,
46
+ `store_id` int(10) unsigned NOT NULL,
47
+ `phone` varchar(40) NOT NULL default '',
48
+ `country` varchar(4) NOT NULL default '',
49
+ `comment` text,
50
+ `create_date` datetime NOT NULL,
51
+ PRIMARY KEY (`entity_id`)
52
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
53
+ ");
54
+
55
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/smasoft/oneclickorder.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout>
4
+
5
+ <adminhtml_oneclickorder_index>
6
+ <reference name="content">
7
+ <block type="smasoft_oneclickorder/adminhtml_orders" name="oneclickorder_orders_index"/>
8
+ </reference>
9
+ </adminhtml_oneclickorder_index>
10
+
11
+ <adminhtml_oneclickorder_view>
12
+ <reference name="content">
13
+ <block type="smasoft_oneclickorder/adminhtml_orders_view" name="sales_order_edit"/>
14
+ </reference>
15
+ <reference name="left">
16
+ <block type="smasoft_oneclickorder/adminhtml_orders_view_tabs" name="sales_order_tabs">
17
+ <block type="smasoft_oneclickorder/adminhtml_orders_view_tab_view" name="order_tab_info"
18
+ template="smasoft/oneclickorder/view.phtml">
19
+ <block type="smasoft_oneclickorder/adminhtml_orders_view_totals" name="order_totals"
20
+ template="sales/order/totals.phtml"/>
21
+ </block>
22
+ <action method="addTab">
23
+ <name>order_info</name>
24
+ <block>order_tab_info</block>
25
+ </action>
26
+ <action method="addTab">
27
+ <name>order_items</name>
28
+ <block>smasoft_oneclickorder/adminhtml_orders_view_tab_cart</block>
29
+ </action>
30
+ </block>
31
+ </reference>
32
+ </adminhtml_oneclickorder_view>
33
+
34
+ </layout>
app/design/adminhtml/default/default/template/smasoft/oneclickorder/view.phtml ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php /** @var $this Smasoft_Oneclickorder_Block_Adminhtml_Orders_View_Tab_View */ ?>
3
+ <?php
4
+ $_order = $this->getOrder();
5
+ $helper = $this->getHelper();
6
+ $customer = $_order->getCustomer();
7
+ ?>
8
+ <?php
9
+ $orderAdminDate = $this->formatDate($_order->getCreateDate(), 'medium', true);
10
+ $orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true);
11
+ ?>
12
+ <div class="box-left">
13
+ <!--Order Information-->
14
+ <div class="entry-edit">
15
+
16
+ <div class="entry-edit-head">
17
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getEntityId()) ?></h4>
18
+ </div>
19
+ <div class="fieldset">
20
+ <table cellspacing="0" class="form-list">
21
+ <?php if ($_order->getMagentoOrderId()):?>
22
+ <tr>
23
+ <td class="label"><label><?php echo $helper->__('View Magento Order') ?></label></td>
24
+ <td class="value"><strong>
25
+ <a href="<?php echo $this->getMagentoOrderUrl($_order->getMagentoOrderId()) ?>"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getMagentoOrderId()) ?></a>
26
+ </strong></td>
27
+ </tr>
28
+ <?php endif;?>
29
+ <tr>
30
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date') ?></label></td>
31
+ <td class="value"><strong><?php echo $orderAdminDate ?></strong></td>
32
+ </tr>
33
+ <?php if ($orderAdminDate != $orderStoreDate):?>
34
+ <tr>
35
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date (%s)', $_order->getCreatedAtStoreDate()->getTimezone()) ?></label></td>
36
+ <td class="value"><strong><?php echo $orderStoreDate ?></strong></td>
37
+ </tr>
38
+ <?php endif;?>
39
+ <!-- <tr>-->
40
+ <!-- <td class="label"><label>--><?php //echo Mage::helper('sales')->__('Order Status') ?><!--</label></td>-->
41
+ <!-- <td class="value"><strong><span id="order_status">--><?php //echo $_order->getStatusLabel() ?><!--</span></strong></td>-->
42
+ <!-- </tr>-->
43
+ <tr>
44
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Purchased From') ?></label></td>
45
+ <td class="value"><strong><?php echo $this->getOrderStoreName() ?></strong></td>
46
+ </tr>
47
+ </table>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <div class="box-right">
52
+ <!--Account Information-->
53
+ <div class="entry-edit">
54
+ <div class="entry-edit-head">
55
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Account Information') ?></h4>
56
+ </div>
57
+ <div class="fieldset">
58
+ <div class="hor-scroll">
59
+ <table cellspacing="0" class="form-list">
60
+ <tr>
61
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Name') ?></label></td>
62
+ <td class="value">
63
+ <?php if (!$customer->getIsGuest() && ($_customerUrl=$this->getUrl('*/customer/edit', array('id' => $customer->getId())))) : ?>
64
+ <a href="<?php echo $_customerUrl ?>" target="_blank"><strong><?php echo $customer->getName() ?></strong></a>
65
+ <?php else: ?>
66
+ <strong><?php echo Mage::helper('customer')->__('Guest') ?></strong>
67
+ <?php endif; ?>
68
+ </td>
69
+ </tr>
70
+ <?php if (!$customer->getIsGuest()):?>
71
+ <tr>
72
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Email') ?></label></td>
73
+ <td class="value"><a href="mailto:<?php echo $customer->getEmail() ?>"><strong><?php echo $customer->getEmail() ?></strong></a></td>
74
+ </tr>
75
+ <?php endif; ?>
76
+ <tr>
77
+ <td class="label"><label><?php echo $helper->__('Phone') ?></label></td>
78
+ <td class="value"><strong><?php echo $_order->getFullPhoneNumber()?></strong></td>
79
+ </tr>
80
+ <tr>
81
+ <td class="label"><label><?php echo $helper->__('Comment') ?></label></td>
82
+ <td class="value"><strong><?php echo $this->escapeHtml($_order->getComment())?></strong></td>
83
+ </tr>
84
+ </table>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ <div class="clear"></div>
90
+
91
+ <div class="box-right entry-edit">
92
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
93
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
94
+ </div>
95
+ <?php
96
+
97
+ //$this->getChildHtml('order_items');
98
+ /* ?>
99
+
100
+
101
+ <div>
102
+ <div id="order-messages">
103
+ <?php echo $this->getChildHtml('order_messages') ?>
104
+ </div>
105
+ <?php echo $this->getChildHtml('order_info') ?>
106
+ <input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
107
+ <?php if ($_order->getIsVirtual()): ?>
108
+ <div class="box-right">
109
+ <?php else: ?>
110
+ <div class="box-left">
111
+ <?php endif; ?>
112
+ <!--Payment Method-->
113
+ <div class="entry-edit">
114
+ <div class="entry-edit-head">
115
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
116
+ </div>
117
+ <fieldset>
118
+ <?php echo $this->getPaymentHtml() ?>
119
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
120
+ </fieldset>
121
+ </div>
122
+ </div>
123
+ <?php if (!$_order->getIsVirtual()): ?>
124
+ <div class="box-right">
125
+ <!--Shipping Method-->
126
+ <div class="entry-edit">
127
+ <div class="entry-edit-head">
128
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping &amp; Handling Information') ?></h4>
129
+ </div>
130
+ <fieldset>
131
+ <?php if ($_order->getTracksCollection()->count()) : ?>
132
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
133
+ <br/>
134
+ <?php endif; ?>
135
+ <?php if ($_order->getShippingDescription()): ?>
136
+ <strong><?php echo $this->escapeHtml($_order->getShippingDescription()) ?></strong>
137
+
138
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
139
+ <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
140
+ <?php else: ?>
141
+ <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
142
+ <?php endif; ?>
143
+ <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
144
+
145
+ <?php echo $_excl; ?>
146
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
147
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
148
+ <?php endif; ?>
149
+ <?php else: ?>
150
+ <?php echo $this->helper('sales')->__('No shipping information available'); ?>
151
+ <?php endif; ?>
152
+ </fieldset>
153
+ </div>
154
+ </div>
155
+ <?php endif; ?>
156
+ <div class="clear"></div>
157
+ <?php echo $this->getGiftOptionsHtml() ?>
158
+ <div class="clear"></div>
159
+ <div class="entry-edit">
160
+ <div class="entry-edit-head">
161
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
162
+ </div>
163
+ </div>
164
+ <?php echo $this->getItemsHtml() ?>
165
+ <div class="clear"></div>
166
+
167
+ <div class="box-left">
168
+ <div class="entry-edit">
169
+ <div class="entry-edit-head">
170
+ <h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
171
+ </div>
172
+ <fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
173
+ </div>
174
+ </div>
175
+ <div class="box-right entry-edit">
176
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
177
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
178
+ </div>
179
+ <div class="clear"></div>
180
+ </div>
181
+
182
+ <?php echo $this->getChildHtml('popup_window');?>
183
+ <script type="text/javascript">
184
+
185
+ function getGiftOptionsTooltipContent(itemId) {
186
+ var contentLines = [];
187
+ var headerLine = null;
188
+ var contentLine = null;
189
+
190
+ $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
191
+ if (element.down(0)) {
192
+ headerLine = element.down(0).innerHTML;
193
+ contentLine = element.down(0).next().innerHTML;
194
+ if (contentLine.length > 30) {
195
+ contentLine = contentLine.slice(0,30) + '...';
196
+ }
197
+ contentLines.push(headerLine + ' ' + contentLine);
198
+ }
199
+ });
200
+ return contentLines.join('<br/>');
201
+ }
202
+ giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
203
+ //]]>
204
+ </script>
205
+ */
app/design/frontend/base/default/layout/smasoft/oneclickorder.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <checkout_cart_index>
5
+ <reference name="head">
6
+ <action method="addCss"><stylesheet>css/oneclickorder.css</stylesheet></action>
7
+ </reference>
8
+
9
+ <reference name="checkout.cart.methods">
10
+ <block type="smasoft_oneclickorder/form" name="checkout.cart.methods.oneclickorder" template="smasoft/oneclickorder/form.phtml"/>
11
+ </reference>
12
+ </checkout_cart_index>
13
+
14
+ <!-- Show OneOrderClick form on product view page -->
15
+ <catalog_product_view>
16
+ <reference name="head">
17
+ <action method="addCss"><stylesheet>css/oneclickorder.css</stylesheet></action>
18
+ </reference>
19
+ <reference name="right">
20
+ <block type="smasoft_oneclickorder/form" before="-" name="catalog.product.oneclickorder" template="smasoft/oneclickorder/form.phtml"/>
21
+ </reference>
22
+
23
+ </catalog_product_view>
24
+
25
+ <smasoft_oneclickorder_index_success translate="label">
26
+ <label>One Click Order Checkout Success</label>
27
+ <reference name="root">
28
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
29
+ </reference>
30
+ <reference name="content">
31
+ <block type="smasoft_oneclickorder/success" name="checkout.success" template="smasoft/oneclickorder/success.phtml">
32
+ <block type="checkout/onepage_success" name="checkout.magento.success" as="magento_order_success" template="checkout/success.phtml"/>
33
+ </block>
34
+ </reference>
35
+ </smasoft_oneclickorder_index_success>
36
+
37
+ <oneclickorder_email_order_items>
38
+ <block type="smasoft_oneclickorder/email_items" name="items" template="smasoft/oneclickorder/email/items.phtml">
39
+ <block type="sales/order_invoice_totals" name="invoice_totals" template="sales/order/totals.phtml">
40
+ <action method="setLabelProperties"><value>colspan="3" align="right" style="padding:3px 9px"</value></action>
41
+ <action method="setValueProperties"><value>align="right" style="padding:3px 9px"</value></action>
42
+ </block>
43
+ </block>
44
+ </oneclickorder_email_order_items>
45
+
46
+ </layout>
app/design/frontend/base/default/template/smasoft/oneclickorder/email/items.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_order = $this->getOrder() ?>
2
+ <?php $_quote = $this->getOrder()->getQuote() ?>
3
+ <?php if ($_quote && $_order): ?>
4
+ <table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
5
+ <thead>
6
+ <tr>
7
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item') ?></th>
8
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Sku') ?></th>
9
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Qty') ?></th>
10
+ <th align="right" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <?php $i=0; foreach ($_quote->getAllItems() as $_item): ?>
15
+ <tr<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
16
+ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getName()?></td>
17
+ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getSku()?></td>
18
+ <td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getQty()?></td>
19
+ <td align="right" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo Mage::app()->getStore()->formatPrice($_item->getRowTotal())?></td>
20
+ </tr>
21
+ <?php endforeach; ?>
22
+ </tbody>
23
+ </table>
24
+ <?php endif; ?>
app/design/frontend/base/default/template/smasoft/oneclickorder/form.phtml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Smasoft_Oneclickorder_Block_Form */
3
+ /** @var $helper Smasoft_Oneclickorder_Helper_Data */
4
+ $helper = Mage::helper('smasoft_oneclickorder');
5
+ $action = $this->getAction()->getFullActionName();
6
+
7
+ ?>
8
+
9
+ <div id="oneclickorder-form-wrapper" class="<?php echo $this->getAction()->getFullActionName()?>">
10
+ <div class="oneclickorder-title"><?php echo $this->__('1 Click Order')?></div>
11
+ <div class="descr">
12
+ <?php echo $this->__('Manager will call you, knows all details and will help place your order.')?>
13
+ </div>
14
+ <form id="oneclickorder-form" action="<?php echo $this->getUrl('oneclickorder/index/saveOrder')?>" method="post">
15
+ <div class="oneclickorder-fields">
16
+ <img class="phone-icon" src="<?php echo $this->getSkinUrl('images/oneclickorder/telephone.png') ?>"/>
17
+ <?php echo $this->getPhoneCodeHtml('oneclickorder[country]', 'validate-select oneclickorder-country', true, $helper->__('Code'))?>
18
+ <input type="text" name="oneclickorder[phone]" class="required-entry oneclickorder-phone" placeholder="<?php echo $this->__('phone number')?>"/>
19
+ <?php if ($this->isShowEmailField()): ?>
20
+ <input type="text" name="oneclickorder[email]" class="required-entry validate-email oneclickorder-email" placeholder="<?php echo $this->__('email')?>"/>
21
+ <?php endif; ?>
22
+ <div class="comment-wrapper" id="oneclickorder-comment-wrapper" style="display: none;">
23
+ <span class="comment"><?php echo $helper->__('Comment:')?></span>
24
+ <textarea name="oneclickorder[comment]"></textarea>
25
+ </div>
26
+ </div>
27
+ <div class="button-wrapper" id="oneclickorder-buttons-container">
28
+ <div class="comment-toggle" title="<?php echo $this->__('Add comment')?>">&nbsp;</div>
29
+ <button type="button" class="button <?php echo $action=='checkout_cart_index' ? 'btn-proceed-checkout btn-checkout' : ''?>" name="submitOneclickOrder" onclick="oneClickOrder.saveOrder()"/>
30
+ <span><span><?php echo $this->__('Order Now')?></span></span>
31
+ </button>
32
+ </div>
33
+ <span class="please-wait" id="oneclickorder-please-wait" style="display:none;">
34
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $helper->__('Submit Order...') ?>" title="<?php echo $helper->__('Submit Order...') ?>" class="v-middle" /> <?php echo $helper->__('Submit Order...') ?>
35
+ </span>
36
+ </form>
37
+
38
+ </div>
39
+ <script type="text/javascript">
40
+
41
+ var oneClickOrder = {
42
+ formInstance:new VarienForm('oneclickorder-form'),
43
+
44
+ _processResponse:function (response) {
45
+ if (response.error) {
46
+ Element.hide('oneclickorder-please-wait');
47
+ Element.show('oneclickorder-buttons-container');
48
+ $('oneclickorder-buttons-container').descendants().each(function(s) {
49
+ s.disabled = false;
50
+ });
51
+ alert(response.error);
52
+ return false;
53
+ }
54
+ if (response.success) {
55
+ if (response.message) {
56
+ alert(response.message)
57
+ }
58
+ if (response.redirect) {
59
+ window.location.href = response.redirect;
60
+ }
61
+ }
62
+ return true;
63
+ },
64
+ _afterSaveOrder:function (transport) {
65
+ var response = {};
66
+ try {
67
+ response = transport.responseText.evalJSON();
68
+ } catch (e) {
69
+ response = transport.responseText;
70
+ }
71
+ if (this._processResponse(response)) {
72
+
73
+ }
74
+ },
75
+ saveOrder:function () {
76
+ if (this.formInstance.validator && this.formInstance.validator.validate()) {
77
+
78
+ Element.show('oneclickorder-please-wait');
79
+ Element.hide('oneclickorder-buttons-container');
80
+ $('oneclickorder-buttons-container').descendants().each(function(s) {
81
+ s.disabled = true;
82
+ });
83
+
84
+ new Ajax.Request(this.formInstance.form.getAttribute('action'), {
85
+ method:'post',
86
+ parameters:this.formInstance.form.serialize(),
87
+ onComplete:this._afterSaveOrder.bind(this),
88
+ onFailure:function () {
89
+ location.href = BASE_URL;
90
+ }
91
+ });
92
+ }
93
+ },
94
+ toggleCommentBlock:function (event) {
95
+ Element.toggle('oneclickorder-comment-wrapper');
96
+ }
97
+ };
98
+
99
+ $$("#oneclickorder-form-wrapper .comment-toggle").invoke('observe', 'click', function () {
100
+ oneClickOrder.toggleCommentBlock(this)
101
+ });
102
+
103
+ </script>
app/design/frontend/base/default/template/smasoft/oneclickorder/success.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Smasoft_Oneclickorder_Block_Success */
3
+ ?>
4
+
5
+ <?php
6
+ if ($this->isShowMagentoOrderSuccess()) :
7
+ echo $this->getChildHtml('magento_order_success');
8
+ else :
9
+ ?>
10
+
11
+ <div class="page-title">
12
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
13
+ </div>
14
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
15
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
16
+
17
+ <?php if ($this->getOrderId()) : ?>
18
+ <p><?php echo $this->__('Your order # is: %s. Manager will call you to %s', $this->getOrderId(), $this->getPhoneNumber()) ?></p>
19
+ <?php endif; ?>
20
+ <div class="buttons-set">
21
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>"
22
+ onclick="window.location.href = '<?php echo $this->getUrl() ?>'">
23
+ <span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
24
+ </div>
25
+
26
+ <?php endif; ?>
app/etc/modules/Smasoft_Oneclickorder.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Smasoft_Oneclickorder>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Adminhtml/>
9
+ <Mage_Catalog />
10
+ <Mage_Checkout/>
11
+ </depends>
12
+ <version>0.1.0</version>
13
+ </Smasoft_Oneclickorder>
14
+ </modules>
15
+ </config>
app/locale/ru_RU/Smasoft_Oneclickorder.csv ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "1 Click Order","Заказ в 1 Клик"
2
+ "Admin Email Template","Админ шаблон для Заказы в 1 Клик"
3
+ "By default uses General Store Email [General=>Store Email Addresses=>General Contact]","По умолчанию используется основной адрес магазина [Общие=>Адреса магазина=>Основной адрес]"
4
+ "Create Magento Order","Создавать заказ в Magento"
5
+ "If select more, than one option, on frontend will be shown select-box with selected phone codes","Отображаемый список кодов на витрине"
6
+ "One Click Order General Settings","Заказы в 1 Клик. Общие настройки"
7
+ "Send Email with order info","Отправлять email администратору о заказе"
8
+ "Code","Код"
9
+ "Manager will call you, knows all details and will help place your order.","Менеджер перезвонит вам, узнает все детали и поможет оформить заказ."
10
+ "Place Order","Оформить заказ"
11
+ "Comment:","Комментарий"
12
+ "Add comment","Добавить комментарий"
13
+ "phone number","номер телефона"
14
+ "Submit Order...","Сохранение заказа"
15
+ "Your order # is: %s. Manager will call you to %s","Номер заказа %s. Менеджер перезвонит Вам на номер %s"
16
+ "Phone","Телефон"
17
+ "One Click Order","Заказ в 1 Клик"
18
+ "OneClick Order Admin Email template","Админ шаблон для Заказы в 1 Клик"
19
+ "View Magento Order","Перейти к заказу в Magento"
20
+ "Email Address","Email адрес"
21
+ "Order Now","Заказать"
22
+ "Change standard One Page Checkout","Заменить стандартное оформление заказа"
23
+ "If yes, than standard One Page Checkout will be replaced by One Click Order","Если включено, то стандартный чекаут не будет доступен"
24
+ "One Click Order Checkout Settings","Настройки оформления заказа в 1 клик."
25
+ "Total items","Total items"
26
+ "Controls whether create Magento Order if possible.","Если включено, то будет сохранен заказ в Magento"
package.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Smasoft_Oneclickorder</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magento One Click Order</summary>
10
+ <description>This extension allows your customers to place an order only in one click , by entering only phone number.&#xD;
11
+ &#xD;
12
+ On the Product View page (right column) and Cart View page will appear form "1 Click order"&#xD;
13
+ &#xD;
14
+ &lt;h2&gt;Features&lt;/h2&gt;&#xD;
15
+ &lt;ul&gt;&#xD;
16
+ &lt;li&gt;Ability to view order history in admin&lt;/li&gt;&#xD;
17
+ &lt;li&gt;Save order in Magento [optional]&lt;/li&gt;&#xD;
18
+ &lt;li&gt;Send notification to admin by email [optional]&lt;/li&gt;&#xD;
19
+ &lt;li&gt;Disable extension&lt;/li&gt;&#xD;
20
+ &lt;li&gt;ajax form submit&lt;/li&gt;&#xD;
21
+ &lt;/ul&gt;</description>
22
+ <notes>Add extension code</notes>
23
+ <authors><author><name>Slabko Michail</name><user>mslabko</user><email>michail.slabko@magento.com</email></author></authors>
24
+ <date>2013-02-17</date>
25
+ <time>19:32:14</time>
26
+ <contents><target name="magecommunity"><dir name="Smasoft"><dir name="Oneclickorder"><dir><dir name="Block"><file name="Abstract.php" hash="7ac1c4d2e31853bde2104fe43bfb219b"/><dir name="Adminhtml"><dir name="Orders"><dir name="Grid"><dir name="Filter"><file name="Filter.php" hash="85310a3cd2b743761e91eba00eae9160"/></dir><dir name="Renderer"><file name="Customer.php" hash="41d3e6b5c27ea79647e175ae966ed85d"/></dir></dir><file name="Grid.php" hash="dd552aec694f243eb479941e9799c33f"/><dir name="View"><dir name="Tab"><file name="Cart.php" hash="7d33d08f804ca525ca2268ae2766c6f1"/><file name="View.php" hash="59d8bb9146b051d8deb7eafba78441df"/></dir><file name="Tabs.php" hash="96121fedb9fde7f875287f9795d53dc9"/><file name="Totals.php" hash="e034a5b9dd5fbaa84fb7cb8194b100a1"/></dir><file name="View.php" hash="ba7a0f092ebe0388073c31e7330fb8d1"/></dir><file name="Orders.php" hash="c13781a656ef0ad6dd6cbc45171f0ffd"/></dir><dir name="Email"><file name="Items.php" hash="f3429350aa7adff3b8f38ba4fa8224c6"/></dir><file name="Form.php" hash="dd11a5a24931cc9114dcb09fd1c866bd"/><file name="Success.php" hash="85648fecbd5c1db1c2a2e2c0a80814f0"/></dir><dir name="Helper"><file name="Data.php" hash="fe618bf196b25961e7dd2b7b9c23b546"/><file name="Email.php" hash="fbcc2b33a32d1352ba49a46ac0624421"/></dir><dir name="Model"><file name="Country.php" hash="81e4fe06bb7480d91185d26006afb07e"/><file name="Observer.php" hash="8b43e8ee35bc52a44c2d4d2056554702"/><file name="Order.php" hash="5f8572272cebc0b94bb9ed404bd7dcd3"/><dir name="Payment"><dir name="Method"><file name="Oneclick.php" hash="cc78b8283304560f3c10b8ca603c5e73"/></dir></dir><dir name="Resource"><dir name="Country"><file name="Collection.php" hash="78ffe2ccd768fe3207693103cb2e2b9a"/></dir><file name="Country.php" hash="6ab590f51494c706e58b8be26b6de799"/><dir name="Order"><file name="Collection.php" hash="909e254e17fa93326a7adb1427f6e1ad"/></dir><file name="Order.php" hash="848513d334ecb128ecb31da0b926e158"/></dir><file name="ServiceQuote.php" hash="588b5af1ab7d5361dfac5ab77ee55aa0"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Country.php" hash="d4f27b6a172bcfd6ad31f253d4637f0d"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="OneclickorderController.php" hash="d364c0c870bc1467f011cfb0fc68646d"/></dir><file name="IndexController.php" hash="310d1e2ac0bee1704fe5b385170caac8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d5bb33432bc01b35a395935bbff852fb"/><file name="config.xml" hash="2531e2b0d6b4122df85dc5398b2ea184"/><file name="system.xml" hash="d85dab36443009f3c769b896d7fee217"/></dir><dir name="sql"><dir name="oneclickorder_setup"><file name="mysql4-install-0.1.0.php" hash="0f74fa38899ed8ec22ce6dd61844a074"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="smasoft"><file name="oneclickorder.xml" hash="d6909370ecd1c83f0ca30f9975e20d18"/></dir></dir><dir name="template"><dir name="smasoft"><dir><dir name="oneclickorder"><file name="view.phtml" hash="851502a4e36982b3c11658eae83910ed"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="smasoft"><file name="oneclickorder.xml" hash="7d30fc248b37372ec574aea63aed60fe"/></dir></dir><dir name="template"><dir name="smasoft"><dir><dir name="oneclickorder"><dir name="email"><file name="items.phtml" hash="84b6c0882e2d419603fcd3248287ed0c"/></dir><file name="form.phtml" hash="7a735295a44df1940101d750ff8365b1"/><file name="success.phtml" hash="c325bfd66ded12b59199f36afe393c00"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Smasoft_Oneclickorder.xml" hash="41538eaa88059b69cd0bd1e1d4ef02e2"/></dir></target><target name="magelocale"><dir name="ru_RU"><file name="Smasoft_Oneclickorder.csv" hash="bc7bb64d47579cb159fa1bb3c4780a27"/></dir><dir name="en_US"><file name="Smasoft_Oneclickorder.csv" hash=""/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="oneclickorder.css" hash="69ef655acbab8ba3178f53871f51a2ea"/></dir><dir name="images"><dir name="oneclickorder"><file name="comment.png" hash="a22ab82fb3a33ece38c3ab5e0844154d"/><file name="telephone.png" hash="0c8298910fbe3c2423f4f30f8ce5c983"/></dir></dir></dir></dir></dir></target></contents>
27
+ <compatible/>
28
+ <dependencies><required><php><min>5.2.0</min><max>5.4.0</max></php></required></dependencies>
29
+ </package>
skin/frontend/default/default/css/oneclickorder.css ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #oneclickorder-form-wrapper {
2
+ text-align: left;
3
+ margin: 2px 0 10px 0;
4
+ }
5
+
6
+ #oneclickorder-form-wrapper .oneclickorder-fields{
7
+ text-align: right;
8
+ /*width: 196px;*/
9
+ width: 98%;
10
+ }
11
+
12
+ #oneclickorder-form-wrapper form {
13
+ margin-top: 6px;
14
+ display: block;
15
+ }
16
+
17
+
18
+ #oneclickorder-form-wrapper input {
19
+ width: 30px;
20
+ }
21
+
22
+ #oneclickorder-form-wrapper .button-wrapper {
23
+ margin-top: 4px;
24
+ }
25
+
26
+ #oneclickorder-form-wrapper .oneclickorder-country {
27
+ width: 58px;
28
+ }
29
+
30
+ #oneclickorder-form-wrapper .oneclickorder-phone,
31
+ #oneclickorder-form-wrapper .oneclickorder-email {
32
+ /*width: 110px;*/
33
+ width: 63%;
34
+ height: 15px;
35
+ margin-bottom: 2px;
36
+
37
+ }
38
+
39
+ #oneclickorder-form-wrapper .oneclickorder-email {
40
+ /*margin: 2px 0 0 39px;*/
41
+ }
42
+
43
+ #oneclickorder-form-wrapper .phone-icon {
44
+ /*margin-top: 3px;*/
45
+ vertical-align:top;
46
+ }
47
+
48
+ #oneclickorder-form-wrapper .descr {
49
+ font-size: 10px;
50
+ line-height: 12px;
51
+ }
52
+
53
+ #oneclickorder-form-wrapper .oneclickorder-title {
54
+ font-size: 15px;
55
+ font-weight: bold;
56
+ }
57
+
58
+ #oneclickorder-form-wrapper .please-wait {
59
+ display: block;
60
+ margin-top: 5px;
61
+ float: none;
62
+ }
63
+
64
+ #oneclickorder-form-wrapper .checkout_cart_index {
65
+
66
+ }
67
+
68
+ #oneclickorder-form-wrapper .catalog_product_view {
69
+
70
+ }
71
+
72
+ #oneclickorder-form-wrapper .comment-toggle {
73
+ background: url('../images/oneclickorder/comment.png');
74
+ width: 17px;
75
+ height: 16px;
76
+ cursor: pointer;
77
+ float: left;
78
+ margin-top: 2px;
79
+ margin-right: 4px;
80
+ }
81
+
82
+ #oneclickorder-form-wrapper .comment-wrapper textarea {
83
+ width: 90%;
84
+ max-width: 178px;
85
+ height: 50px;
86
+ }
87
+
88
+ #oneclickorder-form-wrapper .button {
89
+ /*margin: 5px 0 0 24px;*/
90
+ /*float: none;*/
91
+ }
92
+
93
+ #oneclickorder-form-wrapper.catalog_product_view {
94
+ width: 195px;
95
+ }
96
+
skin/frontend/default/default/images/oneclickorder/comment.png ADDED
Binary file
skin/frontend/default/default/images/oneclickorder/telephone.png ADDED
Binary file