Version Notes
First release
Download this release
Release Info
Developer | MagEvol |
Extension | Magevol_QuickShopping |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Magevol/QuickShopping/controllers/CartController.php +106 -0
- app/code/community/Magevol/QuickShopping/etc/config.xml +33 -0
- app/design/frontend/base/default/layout/quickshopping.xml +19 -0
- app/design/frontend/base/default/template/checkout/cart/quickshopping.phtml +30 -0
- app/etc/modules/Magevol_QuickShopping.xml +16 -0
- package.xml +19 -0
app/code/community/Magevol/QuickShopping/controllers/CartController.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category Magevol
|
5 |
+
* @package Magevol_QuickShopping
|
6 |
+
* @author Magevol
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Shopping cart controller
|
11 |
+
*/
|
12 |
+
require_once 'Mage/Checkout/controllers/CartController.php';
|
13 |
+
class Magevol_QuickShopping_CartController extends Mage_Checkout_CartController
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Initialize product instance from request data
|
17 |
+
*
|
18 |
+
* @return Mage_Catalog_Model_Product || false
|
19 |
+
*/
|
20 |
+
protected function _initProduct()
|
21 |
+
{
|
22 |
+
$sku = $this->getRequest()->getParam('sku');
|
23 |
+
$product = Mage::getModel('catalog/product');
|
24 |
+
$productId = $product->getIdBySku($sku);
|
25 |
+
if ($productId) {
|
26 |
+
$product = Mage::getModel('catalog/product')
|
27 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
28 |
+
->load($productId);
|
29 |
+
if ($product->getId()) {
|
30 |
+
return $product;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
return false;
|
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 |
+
try {
|
47 |
+
if (isset($params['qty'])) {
|
48 |
+
$filter = new Zend_Filter_LocalizedToNormalized(
|
49 |
+
array('locale' => Mage::app()->getLocale()->getLocaleCode())
|
50 |
+
);
|
51 |
+
$params['qty'] = $filter->filter($params['qty']);
|
52 |
+
}
|
53 |
+
|
54 |
+
$product = $this->_initProduct();
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Check product availability
|
58 |
+
*/
|
59 |
+
if (!$product) {
|
60 |
+
$this->_goBack();
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
$cart->addProduct($product, $params);
|
65 |
+
$cart->save();
|
66 |
+
|
67 |
+
$this->_getSession()->setCartWasUpdated(true);
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @todo remove wishlist observer processAddToCart
|
71 |
+
*/
|
72 |
+
Mage::dispatchEvent('checkout_cart_add_product_complete',
|
73 |
+
array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
|
74 |
+
);
|
75 |
+
|
76 |
+
if (!$this->_getSession()->getNoCartRedirect(true)) {
|
77 |
+
if (!$cart->getQuote()->getHasError()) {
|
78 |
+
$message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
|
79 |
+
$this->_getSession()->addSuccess($message);
|
80 |
+
}
|
81 |
+
$this->_goBack();
|
82 |
+
}
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
if ($this->_getSession()->getUseNotice(true)) {
|
85 |
+
$this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
|
86 |
+
} else {
|
87 |
+
$messages = array_unique(explode("\n", $e->getMessage()));
|
88 |
+
foreach ($messages as $message) {
|
89 |
+
$this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
$url = $this->_getSession()->getRedirectUrl(true);
|
94 |
+
if ($url) {
|
95 |
+
$this->getResponse()->setRedirect($url);
|
96 |
+
} else {
|
97 |
+
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
|
98 |
+
}
|
99 |
+
} catch (Exception $e) {
|
100 |
+
$this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
|
101 |
+
Mage::logException($e);
|
102 |
+
$this->_goBack();
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
app/code/community/Magevol/QuickShopping/etc/config.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Magevol
|
5 |
+
* @package Magevol_QuickShopping
|
6 |
+
* @author Magevol
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<modules>
|
11 |
+
<Magevol_QuickShopping>
|
12 |
+
<version>0.1.0</version>
|
13 |
+
</Magevol_QuickShopping>
|
14 |
+
</modules>
|
15 |
+
<frontend>
|
16 |
+
<routers>
|
17 |
+
<quickshopping>
|
18 |
+
<use>standard</use>
|
19 |
+
<args>
|
20 |
+
<module>Magevol_QuickShopping</module>
|
21 |
+
<frontName>quickshopping</frontName>
|
22 |
+
</args>
|
23 |
+
</quickshopping>
|
24 |
+
</routers>
|
25 |
+
<layout>
|
26 |
+
<updates>
|
27 |
+
<quickshopping>
|
28 |
+
<file>quickshopping.xml</file>
|
29 |
+
</quickshopping>
|
30 |
+
</updates>
|
31 |
+
</layout>
|
32 |
+
</frontend>
|
33 |
+
</config>
|
app/design/frontend/base/default/layout/quickshopping.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category design
|
5 |
+
* @package base_default
|
6 |
+
* @author Magevol
|
7 |
+
*/
|
8 |
+
|
9 |
+
-->
|
10 |
+
<layout version="0.1.0">
|
11 |
+
<checkout_cart_index>
|
12 |
+
<reference name="content">
|
13 |
+
<block type="checkout/cart" name="quickshopping" before="-" >
|
14 |
+
<action method="setTemplate"><template>quickshopping</template></action>
|
15 |
+
<block type="checkout/cart" name="quickshopping" as="quickshopping" template="checkout/cart/quickshopping.phtml" />
|
16 |
+
</block>
|
17 |
+
</reference>
|
18 |
+
</checkout_cart_index>
|
19 |
+
</layout>
|
app/design/frontend/base/default/template/checkout/cart/quickshopping.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category design
|
4 |
+
* @package base_default
|
5 |
+
* @author Magevol
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<form action="<?php echo $this->getUrl('quickshopping/cart/add') ?>" class="add-to-cart" method="post" id="ref_addtocart_form">
|
9 |
+
<div class="fieldset">
|
10 |
+
<ul class="form-list">
|
11 |
+
<li class="fields">
|
12 |
+
<div class="field">
|
13 |
+
<label><?php echo $this->__('Sku :') ?></label>
|
14 |
+
<div class="input-box">
|
15 |
+
<input type="text" name="sku" id="sku" value="" placeholder="<?php echo $this->__('Enter SKU product') ?>" title="<?php echo $this->__('SKU ') ?>" class="input-text sku" />
|
16 |
+
</div>
|
17 |
+
</div>
|
18 |
+
<div class="field">
|
19 |
+
<label for="qty"><?php echo $this->__('Qty:') ?></label>
|
20 |
+
<div class="input-box">
|
21 |
+
<input type="text" name="qty" id="qty" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
</li>
|
25 |
+
<li>
|
26 |
+
<button class="button btn-add-cart" title="<?php echo $this->__('Add to cart') ?>" type="submit"><span><span><?php echo $this->__('Add to cart') ?></span></span></button>
|
27 |
+
</li>
|
28 |
+
</ul>
|
29 |
+
</div>
|
30 |
+
</form>
|
app/etc/modules/Magevol_QuickShopping.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Magevol
|
5 |
+
* @package Magevol_QuickShopping
|
6 |
+
* @author Magevol
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<modules>
|
11 |
+
<Magevol_QuickShopping>
|
12 |
+
<active>true</active>
|
13 |
+
<codePool>community</codePool>
|
14 |
+
</Magevol_QuickShopping>
|
15 |
+
</modules>
|
16 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Magevol_QuickShopping</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows the user to easily add a product to the cart by SKU</summary>
|
10 |
+
<description>This extension allows the user to easily add a product to the cart by SKU
|
11 |
+
A block is added to the shopping cart page to enter the SKU and quantity of product to cart.</description>
|
12 |
+
<notes>First release</notes>
|
13 |
+
<authors><author><name>MagEvol</name><user>MagEvol</user><email>contact@magevol.com</email></author></authors>
|
14 |
+
<date>2015-04-24</date>
|
15 |
+
<time>15:17:55</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Magevol"><dir name="QuickShopping"><dir name="controllers"><file name="CartController.php" hash="b84e90ce48c3859d00a5dfe73c821576"/></dir><dir name="etc"><file name="config.xml" hash="185beb0b9569fd2eef2471244311b48e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magevol_QuickShopping.xml" hash="3cf34ac723bce6576c2dc5e8250b4ba3"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="quickshopping.xml" hash="120c6433b7c35ca634591d00f26a703d"/></dir><dir name="template"><dir name="checkout"><dir name="cart"><file name="quickshopping.phtml" hash="8befa27989e2239536d985e41ad1922a"/></dir></dir></dir></dir></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|