Chapagain_QuickOrder - Version 0.1.0

Version Notes

Initial release

Download this release

Release Info

Developer Mukesh Chapagain
Extension Chapagain_QuickOrder
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Chapagain/QuickOrder/Block/Quickorder.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chapagain_QuickOrder_Block_Quickorder extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ }
app/code/community/Chapagain/QuickOrder/Helper/Data.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chapagain_QuickOrder_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * Retrieve configuration settings
7
+ * To show quickorder block in shopping cart page
8
+ *
9
+ * @return boolean
10
+ */
11
+ public function getShowInCart()
12
+ {
13
+ return Mage::getStoreConfig('catalog/chapagain_quickorder/show_in_cart');
14
+ }
15
+
16
+ public function getVersion()
17
+ {
18
+ return Mage::getVersion();
19
+ }
20
+
21
+ public function getVersion19()
22
+ {
23
+ if (version_compare($this->getVersion(), '1.9', '>=')){
24
+ return true;
25
+ }
26
+ return false;
27
+ }
28
+ }
app/code/community/Chapagain/QuickOrder/controllers/Checkout/CartController.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Checkout/controllers/CartController.php';
3
+ class Chapagain_QuickOrder_Checkout_CartController extends Mage_Checkout_CartController
4
+ {
5
+ /**
6
+ * Initialize product instance from request data
7
+ *
8
+ * @return Mage_Catalog_Model_Product || false
9
+ */
10
+ protected function _initProduct()
11
+ {
12
+ $sku = $this->getRequest()->getParam('sku');
13
+ $productId = Mage::getModel('catalog/product')->getIdBySku($sku);
14
+
15
+ if ($productId) {
16
+ $product = Mage::getModel('catalog/product')
17
+ ->setStoreId(Mage::app()->getStore()->getId())
18
+ ->load($productId);
19
+
20
+ if ($product->getId()
21
+ && $product->isSaleable()
22
+ && $this->isEnabled($product->getStatus())
23
+ && $product->isVisibleInSiteVisibility()
24
+ ) {
25
+ return $product;
26
+ }
27
+ }
28
+ return false;
29
+ }
30
+
31
+ public function isEnabled($status)
32
+ {
33
+ return $status == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
34
+ }
35
+
36
+ /**
37
+ * Add product to shopping cart action
38
+ *
39
+ * @return Mage_Core_Controller_Varien_Action
40
+ * @throws Exception
41
+ */
42
+ public function addAction()
43
+ {
44
+ $cart = $this->_getCart();
45
+ $params = $this->getRequest()->getParams();
46
+
47
+ try {
48
+ if (isset($params['qty'])) {
49
+ $filter = new Zend_Filter_LocalizedToNormalized(
50
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
51
+ );
52
+ $params['qty'] = $filter->filter($params['qty']);
53
+ }
54
+
55
+ $product = $this->_initProduct();
56
+
57
+ /**
58
+ * Check product availability
59
+ */
60
+ if (!$product) {
61
+ $this->_getSession()->addError($this->__('Cannot add the item to shopping cart.') . $this->__(' ( SKU: '.$params['sku'].' )'));
62
+ $this->_goBack();
63
+ return;
64
+ }
65
+
66
+ $cart->addProduct($product, $params);
67
+ $cart->save();
68
+
69
+ $this->_getSession()->setCartWasUpdated(true);
70
+
71
+ /**
72
+ * @todo remove wishlist observer processAddToCart
73
+ */
74
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
75
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
76
+ );
77
+
78
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
79
+ if (!$cart->getQuote()->getHasError()) {
80
+ $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
81
+ $this->_getSession()->addSuccess($message);
82
+ }
83
+ $this->_goBack();
84
+ }
85
+ } catch (Mage_Core_Exception $e) {
86
+ if ($this->_getSession()->getUseNotice(true)) {
87
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
88
+ } else {
89
+ $messages = array_unique(explode("\n", $e->getMessage()));
90
+ foreach ($messages as $message) {
91
+ $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
92
+ }
93
+ }
94
+
95
+ $url = $this->_getSession()->getRedirectUrl(true);
96
+ if ($url) {
97
+ $this->getResponse()->setRedirect($url);
98
+ } else {
99
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
100
+ }
101
+ } catch (Exception $e) {
102
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
103
+ Mage::logException($e);
104
+ $this->_goBack();
105
+ }
106
+ }
107
+
108
+ }
app/code/community/Chapagain/QuickOrder/controllers/QuickorderController.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chapagain_QuickOrder_QuickorderController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ }
app/code/community/Chapagain/QuickOrder/etc/config.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chapagain_QuickOrder>
5
+ <version>0.1.0</version>
6
+ </Chapagain_QuickOrder>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <quickorder>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Chapagain_QuickOrder</module>
14
+ <frontName>quickorder</frontName>
15
+ </args>
16
+ </quickorder>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <quickorder>
21
+ <file>chapagain_quickorder.xml</file>
22
+ </quickorder>
23
+ </updates>
24
+ </layout>
25
+ <translate>
26
+ <modules>
27
+ <Chapagain_QuickOrder>
28
+ <files>
29
+ <default>Chapagain_QuickOrder.csv</default>
30
+ </files>
31
+ </Chapagain_QuickOrder>
32
+ </modules>
33
+ </translate>
34
+ </frontend>
35
+ <global>
36
+ <resources>
37
+ <quickorder_setup>
38
+ <setup>
39
+ <module>Chapagain_QuickOrder</module>
40
+ </setup>
41
+ <connection>
42
+ <use>core_setup</use>
43
+ </connection>
44
+ </quickorder_setup>
45
+ <quickorder_write>
46
+ <connection>
47
+ <use>core_write</use>
48
+ </connection>
49
+ </quickorder_write>
50
+ <quickorder_read>
51
+ <connection>
52
+ <use>core_read</use>
53
+ </connection>
54
+ </quickorder_read>
55
+ </resources>
56
+ <blocks>
57
+ <quickorder>
58
+ <class>Chapagain_QuickOrder_Block</class>
59
+ </quickorder>
60
+ </blocks>
61
+ <helpers>
62
+ <quickorder>
63
+ <class>Chapagain_QuickOrder_Helper</class>
64
+ </quickorder>
65
+ </helpers>
66
+ </global>
67
+ <default>
68
+ <catalog>
69
+ <chapagain_quickorder>
70
+ <show_in_cart>1</show_in_cart>
71
+ <show_in_left_sidebar>1</show_in_left_sidebar>
72
+ <show_in_right_sidebar>1</show_in_right_sidebar>
73
+ </chapagain_quickorder>
74
+ </catalog>
75
+ </default>
76
+ </config>
app/code/community/Chapagain/QuickOrder/etc/system.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <catalog translate="label">
5
+ <groups>
6
+ <chapagain_quickorder translate="label" module="quickorder">
7
+ <label>Quick Order</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>10</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <show_in_cart translate="label comment">
15
+ <label>Show in Cart</label>
16
+ <comment>Show in Shopping Cart Page</comment>
17
+ <frontend_type>select</frontend_type>
18
+ <source_model>adminhtml/system_config_source_yesno</source_model>
19
+ <sort_order>30</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
+ </show_in_cart>
24
+ <show_in_left_sidebar translate="label comment">
25
+ <label>Show in Left Sidebar</label>
26
+ <!--<comment>Show in Left Sidebar</comment>-->
27
+ <frontend_type>select</frontend_type>
28
+ <source_model>adminhtml/system_config_source_yesno</source_model>
29
+ <sort_order>30</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </show_in_left_sidebar>
34
+ <show_in_right_sidebar translate="label comment">
35
+ <label>Show in Right Sidebar</label>
36
+ <!--<comment>Show in Right Sidebar</comment>-->
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_yesno</source_model>
39
+ <sort_order>40</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </show_in_right_sidebar>
44
+ </fields>
45
+ </chapagain_quickorder>
46
+ </groups>
47
+ </catalog>
48
+ </sections>
49
+ </config>
app/design/frontend/base/default/layout/chapagain_quickorder.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <block type="quickorder/quickorder" name="quickorder.sidebar" before="-" template="chapagain_quickorder/block_sidebar.phtml"/>
5
+ <reference name="left">
6
+ <action method="append" ifconfig="catalog/chapagain_quickorder/show_in_left_sidebar">
7
+ <block>quickorder.sidebar</block>
8
+ </action>
9
+ </reference>
10
+ <reference name="right">
11
+ <action method="append" ifconfig="catalog/chapagain_quickorder/show_in_right_sidebar">
12
+ <block>quickorder.sidebar</block>
13
+ </action>
14
+ </reference>
15
+ </default>
16
+
17
+ <checkout_cart_index>
18
+ <block type="quickorder/quickorder" name="checkout.cart.extra" template="chapagain_quickorder/block_cart.phtml"/>
19
+ <reference name="content">
20
+ <reference name="checkout.cart">
21
+ <!--<block type="quickorder/quickorder" name="checkout.cart.extra" template="chapagain_quickorder/block_cart.phtml"/>-->
22
+ <action method="append" ifconfig="catalog/chapagain_quickorder/show_in_cart">
23
+ <block>checkout.cart.extra</block>
24
+ </action>
25
+ </reference>
26
+ </reference>
27
+ </checkout_cart_index>
28
+
29
+ </layout>
app/design/frontend/base/default/template/chapagain_quickorder/block_cart.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php //if($this->helper('quickorder')->getShowInCart()): ?>
3
+
4
+ <form id="quickorder-form-cart" action="<?php echo $this->getUrl('quickorder/checkout_cart/add') ?>" method="post">
5
+ <div class="discount">
6
+ <h2><?php echo $this->__('Quick Order') ?></h2>
7
+ <div class="block-content">
8
+ <label><?php echo $this->__('Enter SKU of Product') ?></label>
9
+ <div class="input-box">
10
+ <?php echo $this->__('SKU')?>: <input class="input-text" id="sku" name="sku" style="width:58%"/> &nbsp;
11
+ <?php echo $this->__('Qty')?>: <input class="input-text" id="qty" name="qty" value="1" style="width:10%"/>
12
+ </div>
13
+ <div class="buttons-set">
14
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button" onclick="submitQuickOrderFromCart()" value="<?php echo $this->__('Add to Cart') ?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
15
+ </div>
16
+
17
+ </div>
18
+ </div>
19
+ </form>
20
+ <script type="text/javascript">
21
+ //<![CDATA[
22
+ var quickOrderFromCart = new VarienForm('quickorder-form-cart');
23
+
24
+ function submitQuickOrderFromCart() {
25
+ quickOrderFromCart.form.submit();
26
+ }
27
+ //]]>
28
+ </script>
29
+
30
+ <?php //endif; ?>
app/design/frontend/base/default/template/chapagain_quickorder/block_sidebar.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="block block-subscribe">
3
+ <div class="block-title">
4
+ <strong><span><?php echo $this->__('Quick Order') ?></span></strong>
5
+ </div>
6
+ <form action="<?php echo $this->getUrl('quickorder/checkout_cart/add') ?>" method="post" id="quickorder-form-sidebar">
7
+ <div class="block-content">
8
+ <div class="input-box">
9
+ <label><?php echo $this->__('SKU') ?></label> <input type="text" class="input-text" id="sku" name="sku"/>
10
+ <label><?php echo $this->__('Qty') ?></label><input type="text" class="input-text" id="qty" name="qty" value="1" style="width:30px"/>
11
+ </div>
12
+ <div class="actions">
13
+ <button type="submit" title="<?php echo $this->__('Add to Cart') ?>" class="button" onclick="submitQuickOrderFromSidebar()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
14
+ </div>
15
+ </div>
16
+ </form>
17
+ <script type="text/javascript">
18
+ //<![CDATA[
19
+ var quickOrderFromSidebar = new VarienForm('quickorder-form-sidebar');
20
+ function submitQuickOrderFromSidebar() {
21
+ quickOrderFromSidebar.form.submit();
22
+ }
23
+ //]]>
24
+ </script>
25
+ </div>
app/etc/modules/Chapagain_QuickOrder.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chapagain_QuickOrder>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Chapagain_QuickOrder>
8
+ </modules>
9
+ </config>
app/locale/en_US/Chapagain_QuickOrder.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ Quick Order,Quick Order
2
+ Enter SKU of Product,Enter SKU of Product
3
+ SKU,SKU
4
+ Qty,Qty
5
+ Add to Cart,Add to Cart
package.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package><name>Chapagain_QuickOrder</name><version>0.1.0</version><stability>stable</stability><license>OSL v3.0</license><channel>community</channel><extends></extends><summary>Quick Order - Directly add products to shopping cart by product SKU</summary><description>Quickly/Directly add products to shopping cart using product SKU.
3
+
4
+ A 'Quick Order' block is added just above the Discount Coupon block in Shopping Cart page. You can enter the product SKU and quantity to add to cart.
5
+
6
+ The 'Quick Order' block can also be displayed in Left Sidebar and Right Sidebar.
7
+
8
+ This can be managed from System -&gt; Configuration -&gt; Catalog -&gt; Quick Order.
9
+
10
+ Features:-
11
+
12
+ Easy to install and use
13
+ 100% Free
14
+ 100% Open Source</description><notes>Initial release</notes><authors><author><name>Mukesh Chapagain</name><user>chapagain</user><email>mukesh.chapagain@gmail.com</email></author></authors><date>2015-07-25</date><time>3:36:35</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="chapagain_quickorder.xml" hash="929b78d67eb55a282cc45f9068112917"/></dir><dir name="template"><dir name="chapagain_quickorder"><file name="block_cart.phtml" hash="9150f39316a5de34fc2ae7544a016090"/><file name="block_sidebar.phtml" hash="2aea2f2b16382b21eb1538fd0a9a4108"/></dir></dir></dir></dir></dir></dir><dir name="locale"><dir name="en_US"><file name="Chapagain_QuickOrder.csv" hash="cfcfb069a8a7f13765973191592e426a"/></dir></dir><dir name="code"><dir name="community"><dir name="Chapagain"><dir name="QuickOrder"><dir name="controllers"><file name="QuickorderController.php" hash="0ae1190b65170faa2a3f3765e035d7fa"/><dir name="Checkout"><file name="CartController.php" hash="f53a789d69a2517e03cdb698bda2f2a6"/></dir></dir><dir name="etc"><file name="config.xml" hash="6bfeaa6a1fa0dcf4b8876066edef8894"/><file name="system.xml" hash="d5fe73980c067fbc5ce1e2bd2f83ec59"/></dir><dir name="Helper"><file name="Data.php" hash="8b99fe95b753ba4b899f0b97ce3b2926"/></dir><dir name="Block"><file name="Quickorder.php" hash="4be05eed8f99327e2192f00d892e6908"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Chapagain_QuickOrder.xml" hash="e00d1603d219e419702316686dea647f"/></dir></dir></dir></target></contents></package>