Version Notes
Initial release
Download this release
Release Info
Developer | Intercastilla Team |
Extension | Intercastilla_Hideprices |
Version | 0.2.0 |
Comparing to | |
See all releases |
Version 0.2.0
- app/code/community/Intercastilla/Hideprices/Block/Catalog/.DS_Store +0 -0
- app/code/community/Intercastilla/Hideprices/Block/Catalog/Layer/View.php +71 -0
- app/code/community/Intercastilla/Hideprices/Helper/Client.php +79 -0
- app/code/community/Intercastilla/Hideprices/Helper/Data.php +63 -0
- app/code/community/Intercastilla/Hideprices/Model/Observer/Product.php +157 -0
- app/code/community/Intercastilla/Hideprices/etc/adminhtml.xml +49 -0
- app/code/community/Intercastilla/Hideprices/etc/config.xml +97 -0
- app/code/community/Intercastilla/Hideprices/etc/system.xml +77 -0
- app/etc/modules/Intercastilla_Hideprices.xml +39 -0
- package.xml +18 -0
app/code/community/Intercastilla/Hideprices/Block/Catalog/.DS_Store
ADDED
Binary file
|
app/code/community/Intercastilla/Hideprices/Block/Catalog/Layer/View.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Intercastilla Hideprices Extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
8 |
+
*
|
9 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 |
+
* of this software and associated documentation files (the "Software"), to deal
|
11 |
+
* in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13 |
+
* copies of the Software, and to permit persons to whom the Software is
|
14 |
+
* furnished to do so, subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included i
|
17 |
+
* all copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OF
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
21 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
23 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
24 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25 |
+
* THE SOFTWARE.
|
26 |
+
*
|
27 |
+
* @category Intercastilla
|
28 |
+
* @package Intercastilla_Hideprices
|
29 |
+
* @author Borja A.
|
30 |
+
* @copyright Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L. (http://www.intercastilla.com)
|
31 |
+
* @license http://opensource.org/licenses/MIT MIT License
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Intercastilla_Hideprices_Block_Catalog_Layer_View extends Mage_Catalog_Block_Layer_View
|
35 |
+
{
|
36 |
+
|
37 |
+
/**
|
38 |
+
* The price attribute code.
|
39 |
+
* It won't probably change in a 100 years time
|
40 |
+
*/
|
41 |
+
const EAV_PRICE_ATTRIBUTE_CODE = 'price';
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get all fiterable attributes of current category.
|
45 |
+
*
|
46 |
+
* If the user cant view prices, remove the price layer filter
|
47 |
+
* from the collection of filterable attributes
|
48 |
+
*
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
protected function _getFilterableAttributes()
|
52 |
+
{
|
53 |
+
/** @var Mage_Catalog_Model_Resource_Product_Attribute_Collection $attributes */
|
54 |
+
// get attributes from extended class
|
55 |
+
$attributes = parent::_getFilterableAttributes();
|
56 |
+
if (!Mage::helper('hideprices/client')->isAllowedToSeePrices()) {
|
57 |
+
// remove the price filter from the filter layer collection
|
58 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
|
59 |
+
foreach ($attributes as $filterableKey => $attribute) {
|
60 |
+
if (self::EAV_PRICE_ATTRIBUTE_CODE == $attribute->getAttributeCode()) {
|
61 |
+
// remove from the layer
|
62 |
+
$attributes->removeItemByKey($filterableKey);
|
63 |
+
break;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
return $attributes;
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
app/code/community/Intercastilla/Hideprices/Helper/Client.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Intercastilla Hideprices Extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
8 |
+
*
|
9 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 |
+
* of this software and associated documentation files (the "Software"), to deal
|
11 |
+
* in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13 |
+
* copies of the Software, and to permit persons to whom the Software is
|
14 |
+
* furnished to do so, subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included i
|
17 |
+
* all copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
21 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHE
|
23 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
24 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25 |
+
* THE SOFTWARE.
|
26 |
+
*
|
27 |
+
* @category Intercastilla
|
28 |
+
* @package Intercastilla_Hideprices
|
29 |
+
* @author Borja A.
|
30 |
+
* @copyright Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L. (http://www.intercastilla.com)
|
31 |
+
* @license http://opensource.org/licenses/MIT MIT License
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Intercastilla_Hideprices_Helper_Client extends Mage_Core_Helper_Abstract
|
35 |
+
{
|
36 |
+
|
37 |
+
/**
|
38 |
+
* System config path for customer_groups
|
39 |
+
*/
|
40 |
+
const CONFIG_PATH_HIDEPRICE_CUSTOMER_GROUP = 'hideprices/hideprices/customer_groups';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Flag to tell whether the user is allowed to see prices
|
44 |
+
*
|
45 |
+
* @var bool
|
46 |
+
*/
|
47 |
+
private $_isAllowedToSeePrices;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Checks if a client is allowed to see prices on the frontend
|
51 |
+
*
|
52 |
+
* @return bool
|
53 |
+
*/
|
54 |
+
public function isAllowedToSeePrices()
|
55 |
+
{
|
56 |
+
if (!isset($this->_isAllowedToSeePrices)) {
|
57 |
+
|
58 |
+
if (Mage::helper('hideprices')->isEnabled()) {
|
59 |
+
// by default we don't show prices for guest users
|
60 |
+
$this->_isAllowedToSeePrices = false;
|
61 |
+
// is the user logged in ?
|
62 |
+
if (Mage::getSingleton('customer/session' )->isLoggedIn()) {
|
63 |
+
// get configured customer groups
|
64 |
+
$configuredCustomerGroups = Mage::getStoreConfig(self::CONFIG_PATH_HIDEPRICE_CUSTOMER_GROUP);
|
65 |
+
// get this customer group id
|
66 |
+
$groupId = Mage::getSingleton('customer/session' )->getCustomerGroupId();
|
67 |
+
if ('' != $configuredCustomerGroups && $groupId) {
|
68 |
+
$configuredCustomerGroups = explode(',', $configuredCustomerGroups);
|
69 |
+
$this->_isAllowedToSeePrices = in_array($groupId, $configuredCustomerGroups);
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
return $this->_isAllowedToSeePrices;
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
app/code/community/Intercastilla/Hideprices/Helper/Data.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Intercastilla Hideprices Extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
8 |
+
*
|
9 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 |
+
* of this software and associated documentation files (the "Software"), to deal
|
11 |
+
* in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13 |
+
* copies of the Software, and to permit persons to whom the Software is
|
14 |
+
* furnished to do so, subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included i
|
17 |
+
* all copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OF
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
21 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
23 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
24 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25 |
+
* THE SOFTWARE.
|
26 |
+
*
|
27 |
+
* @category Intercastilla
|
28 |
+
* @package Intercastilla_Hideprices
|
29 |
+
* @author Borja A.
|
30 |
+
* @copyright Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L. (http://www.intercastilla.com)
|
31 |
+
* @license http://opensource.org/licenses/MIT MIT License
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Intercastilla_Hideprices_Helper_Data extends Mage_Core_Helper_Abstract
|
35 |
+
{
|
36 |
+
|
37 |
+
/**
|
38 |
+
* System config path for extension nabled flag
|
39 |
+
*/
|
40 |
+
const CONFIG_PATH_HIDEPRICE_ENABLED = 'hideprices/hideprices/enabled';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Flag to tell whether the extension is enabled
|
44 |
+
*
|
45 |
+
* @var bool
|
46 |
+
*/
|
47 |
+
private $_isEnabled;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Checks if the extension is enabled
|
51 |
+
*
|
52 |
+
* @return bool
|
53 |
+
*/
|
54 |
+
public function isEnabled()
|
55 |
+
{
|
56 |
+
if (!isset($this->_isEnabled)) {
|
57 |
+
$this->_isEnabled = Mage::getStoreConfigFlag(self::CONFIG_PATH_HIDEPRICE_ENABLED);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->_isEnabled;
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
app/code/community/Intercastilla/Hideprices/Model/Observer/Product.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Intercastilla Hideprices Extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
8 |
+
*
|
9 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
10 |
+
* of this software and associated documentation files (the "Software"), to deal
|
11 |
+
* in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13 |
+
* copies of the Software, and to permit persons to whom the Software is
|
14 |
+
* furnished to do so, subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included i
|
17 |
+
* all copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS O
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
21 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL TH
|
22 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHE
|
23 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
24 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25 |
+
* THE SOFTWARE.
|
26 |
+
*
|
27 |
+
* @category Intercastilla
|
28 |
+
* @package Intercastilla_Hideprices
|
29 |
+
* @author Borja A.
|
30 |
+
* @copyright Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L. (http://www.intercastilla.com)
|
31 |
+
* @license http://opensource.org/licenses/MIT MIT License
|
32 |
+
*/
|
33 |
+
|
34 |
+
class Intercastilla_Hideprices_Model_Observer_Product extends Varien_Object
|
35 |
+
{
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Boolean flags for salable/not salable
|
39 |
+
*/
|
40 |
+
const HIDEPRICES_PRODUCT_MARK_NOT_SALABLE = false;
|
41 |
+
const HIDEPRICES_PRODUCT_MARK_SALABLE = true;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Boolean flags for show/not show price
|
45 |
+
*/
|
46 |
+
const HIDEPRICES_PRODUCT_MARK_NO_SHOW_PRICE = false;
|
47 |
+
const HIDEPRICES_PRODUCT_MARK_SHOW_PRICE = true;
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Logic to determine if the product should NOT be available
|
52 |
+
* (Don't show price and don't allow add to cart)
|
53 |
+
*
|
54 |
+
* @return bool
|
55 |
+
*/
|
56 |
+
protected function _matches()
|
57 |
+
{
|
58 |
+
$_matches = !Mage::helper('hideprices/client')->isAllowedToSeePrices();
|
59 |
+
|
60 |
+
Mage::dispatchEvent('intercastilla_hideprices_client_matches', array(
|
61 |
+
'matches' => $_matches
|
62 |
+
));
|
63 |
+
|
64 |
+
return $_matches;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Sets each item with the neccesary condition to not show the price
|
69 |
+
*
|
70 |
+
* @param Mage_Catalog_Model_Product $item
|
71 |
+
* @param bool True for show price, false for not
|
72 |
+
*
|
73 |
+
*/
|
74 |
+
protected function _markItemShowPrice($item, $showPrice = self::HIDEPRICES_PRODUCT_MARK_NO_SHOW_PRICE)
|
75 |
+
{
|
76 |
+
$item->setCanShowPrice($showPrice);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Sets the item as salable/not salable
|
81 |
+
*
|
82 |
+
* @param Mage_Catalog_Model_Product $item
|
83 |
+
* @param bool True for salable, false for not salable
|
84 |
+
*/
|
85 |
+
protected function _markItemSalable($item, $isSalable = self::HIDEPRICES_PRODUCT_MARK_NOT_SALABLE)
|
86 |
+
{
|
87 |
+
$item->setIsSalable($isSalable);
|
88 |
+
// additional custom flag, useful for template stuff
|
89 |
+
// this is because seting a product as not salable, will
|
90 |
+
// set the product as 'out of stock'
|
91 |
+
$item->setIsNotAvailableForUser($isSalable);
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Marks an item BOTH not salable and NOT allowed to see price for it
|
96 |
+
*
|
97 |
+
* @param Mage_Catalog_Model_Product $item
|
98 |
+
*/
|
99 |
+
protected function _setItemNotAvailable($item)
|
100 |
+
{
|
101 |
+
if ($item->getId()) {
|
102 |
+
$this->_markItemShowPrice($item);
|
103 |
+
$this->_markItemSalable($item);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Hooks on product init, and sets canShowPrice = false
|
109 |
+
* if the condition matches
|
110 |
+
*
|
111 |
+
* @param Varien_Event_Observer $observer
|
112 |
+
*
|
113 |
+
*/
|
114 |
+
public function catalogControllerProductInit(Varien_Event_Observer $observer)
|
115 |
+
{
|
116 |
+
if (Mage::helper('hideprices')->isEnabled()) {
|
117 |
+
if (($product = $observer->getProduct()) && ($this->_matches())) {
|
118 |
+
$this->_setItemNotAvailable($product);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Hooks on product collection creation, and sets the required flags to each product
|
125 |
+
* if the condition matches
|
126 |
+
*
|
127 |
+
* @param $observer Varien_Event_Observer
|
128 |
+
*/
|
129 |
+
public function productCollectionLoadAfter(Varien_Event_Observer $observer)
|
130 |
+
{
|
131 |
+
if (Mage::helper('hideprices')->isEnabled() && $this->_matches()) {
|
132 |
+
/** @var Mage_Catalog_Model_Resource_Product_Collection $collection */
|
133 |
+
if ($collection = $observer->getCollection()) {
|
134 |
+
foreach ($collection as $item) {
|
135 |
+
$this->_setItemNotAvailable($item);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Hooks to catalog_product_is_salable_after
|
143 |
+
* Sets the product to not salable if the condition matches
|
144 |
+
*
|
145 |
+
* @param Varien_Event_Observer $observer
|
146 |
+
*/
|
147 |
+
public function catalogProductIsSalableAfter(Varien_Event_Observer $observer)
|
148 |
+
{
|
149 |
+
if (Mage::helper('hideprices')->isEnabled() && $this->_matches()) {
|
150 |
+
if ($salable = $observer->getSalable()) {
|
151 |
+
// mark item as not salable
|
152 |
+
$this->_markItemSalable($observer->getSalable()->getProduct());
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
app/code/community/Intercastilla/Hideprices/etc/adminhtml.xml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
*
|
4 |
+
* Intercastilla Hideprices Extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
9 |
+
*
|
10 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 |
+
* of this software and associated documentation files (the "Software"), to deal
|
12 |
+
* in the Software without restriction, including without limitation the rights
|
13 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 |
+
* copies of the Software, and to permit persons to whom the Software is
|
15 |
+
* furnished to do so, subject to the following conditions:
|
16 |
+
*
|
17 |
+
* The above copyright notice and this permission notice shall be included i
|
18 |
+
* all copies or substantial portions of the Software.
|
19 |
+
*
|
20 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OF
|
21 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
22 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
24 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
25 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26 |
+
* THE SOFTWARE.
|
27 |
+
*
|
28 |
+
-->
|
29 |
+
<config>
|
30 |
+
<acl>
|
31 |
+
<resources>
|
32 |
+
<admin>
|
33 |
+
<children>
|
34 |
+
<system>
|
35 |
+
<children>
|
36 |
+
<config>
|
37 |
+
<children>
|
38 |
+
<hideprices translate="title" module="hideprices">
|
39 |
+
<title>Hide prices</title>
|
40 |
+
</hideprices>
|
41 |
+
</children>
|
42 |
+
</config>
|
43 |
+
</children>
|
44 |
+
</system>
|
45 |
+
</children>
|
46 |
+
</admin>
|
47 |
+
</resources>
|
48 |
+
</acl>
|
49 |
+
</config>
|
app/code/community/Intercastilla/Hideprices/etc/config.xml
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
*
|
4 |
+
* Intercastilla Hideprices Extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
9 |
+
*
|
10 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 |
+
* of this software and associated documentation files (the "Software"), to deal
|
12 |
+
* in the Software without restriction, including without limitation the rights
|
13 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 |
+
* copies of the Software, and to permit persons to whom the Software is
|
15 |
+
* furnished to do so, subject to the following conditions:
|
16 |
+
*
|
17 |
+
* The above copyright notice and this permission notice shall be included i
|
18 |
+
* all copies or substantial portions of the Software.
|
19 |
+
*
|
20 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OF
|
21 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
22 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OR
|
24 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
25 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26 |
+
* THE SOFTWARE.
|
27 |
+
*
|
28 |
+
-->
|
29 |
+
<config>
|
30 |
+
<modules>
|
31 |
+
<Intercastilla_Hideprices>
|
32 |
+
<version>0.2.0</version>
|
33 |
+
</Intercastilla_Hideprices>
|
34 |
+
</modules>
|
35 |
+
<global>
|
36 |
+
<blocks>
|
37 |
+
<hideprices>
|
38 |
+
<class>Intercastilla_Hideprices_Block</class>
|
39 |
+
</hideprices>
|
40 |
+
<catalog>
|
41 |
+
<rewrite>
|
42 |
+
<layer_view>Intercastilla_Hideprices_Block_Catalog_Layer_View</layer_view>
|
43 |
+
</rewrite>
|
44 |
+
</catalog>
|
45 |
+
</blocks>
|
46 |
+
<events>
|
47 |
+
<catalog_controller_product_init>
|
48 |
+
<observers>
|
49 |
+
<hideprices_catalog_controller_product_init>
|
50 |
+
<type>singleton</type>
|
51 |
+
<class>hideprices/observer_product</class>
|
52 |
+
<method>catalogControllerProductInit</method>
|
53 |
+
</hideprices_catalog_controller_product_init>
|
54 |
+
</observers>
|
55 |
+
</catalog_controller_product_init>
|
56 |
+
<catalog_product_collection_load_after>
|
57 |
+
<observers>
|
58 |
+
<hideprices_catalog_product_collection_load_after>
|
59 |
+
<type>singleton</type>
|
60 |
+
<class>hideprices/observer_product</class>
|
61 |
+
<method>productCollectionLoadAfter</method>
|
62 |
+
</hideprices_catalog_product_collection_load_after>
|
63 |
+
</observers>
|
64 |
+
</catalog_product_collection_load_after>
|
65 |
+
<catalog_product_is_salable_after>
|
66 |
+
<observers>
|
67 |
+
<hideprices_catalog_product_is_salable_after>
|
68 |
+
<type>singleton</type>
|
69 |
+
<class>hideprices/observer_product</class>
|
70 |
+
<method>catalogProductIsSalableAfter</method>
|
71 |
+
</hideprices_catalog_product_is_salable_after>
|
72 |
+
</observers>
|
73 |
+
</catalog_product_is_salable_after>
|
74 |
+
</events>
|
75 |
+
<helpers>
|
76 |
+
<hideprices>
|
77 |
+
<class>Intercastilla_Hideprices_Helper</class>
|
78 |
+
</hideprices>
|
79 |
+
</helpers>
|
80 |
+
<models>
|
81 |
+
<hideprices>
|
82 |
+
<class>Intercastilla_Hideprices_Model</class>
|
83 |
+
</hideprices>
|
84 |
+
</models>
|
85 |
+
</global>
|
86 |
+
<adminhtml>
|
87 |
+
<translate>
|
88 |
+
<modules>
|
89 |
+
<Intercastilla_Hideprices>
|
90 |
+
<files>
|
91 |
+
<default>Intercastilla_Hideprices.csv</default>
|
92 |
+
</files>
|
93 |
+
</Intercastilla_Hideprices>
|
94 |
+
</modules>
|
95 |
+
</translate>
|
96 |
+
</adminhtml>
|
97 |
+
</config>
|
app/code/community/Intercastilla/Hideprices/etc/system.xml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
*
|
4 |
+
* Intercastilla Hideprices Extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
9 |
+
*
|
10 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 |
+
* of this software and associated documentation files (the "Software"), to deal
|
12 |
+
* in the Software without restriction, including without limitation the rights
|
13 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 |
+
* copies of the Software, and to permit persons to whom the Software is
|
15 |
+
* furnished to do so, subject to the following conditions:
|
16 |
+
*
|
17 |
+
* The above copyright notice and this permission notice shall be included i
|
18 |
+
* all copies or substantial portions of the Software.
|
19 |
+
*
|
20 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OF
|
21 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
22 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
24 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
25 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26 |
+
* THE SOFTWARE.
|
27 |
+
*
|
28 |
+
-->
|
29 |
+
<config>
|
30 |
+
<sections>
|
31 |
+
<hideprices translate="label" module="hideprices">
|
32 |
+
<label>Hide prices</label>
|
33 |
+
<tab>catalog</tab>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>210</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
<groups>
|
40 |
+
<hideprices translate="label">
|
41 |
+
<label>Hide prices</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>15</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
<fields>
|
48 |
+
<enabled translate="label">
|
49 |
+
<label>Enable</label>
|
50 |
+
<frontend_type>select</frontend_type>
|
51 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
52 |
+
<sort_order>10</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</enabled>
|
57 |
+
<customer_groups translate="label comment">
|
58 |
+
<label>Customer Group</label>
|
59 |
+
<comment><![CDATA[Select the customer groups you want to show prices for.
|
60 |
+
Use the CTRL key or Command key (Mac OS) to select multiple values at once.]]></comment>
|
61 |
+
<frontend_type>multiselect</frontend_type>
|
62 |
+
<source_model>adminhtml/system_config_source_customer_group_multiselect</source_model>
|
63 |
+
<sort_order>20</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>1</show_in_store>
|
67 |
+
<can_be_empty>1</can_be_empty>
|
68 |
+
<depends>
|
69 |
+
<enabled>1</enabled>
|
70 |
+
</depends>
|
71 |
+
</customer_groups>
|
72 |
+
</fields>
|
73 |
+
</hideprices>
|
74 |
+
</groups>
|
75 |
+
</hideprices>
|
76 |
+
</sections>
|
77 |
+
</config>
|
app/etc/modules/Intercastilla_Hideprices.xml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
*
|
4 |
+
* Intercastilla Hideprices Extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Copyright (c) 2014 Intercastilla Diseño y Comunicación Gráfica, S.L.
|
9 |
+
*
|
10 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 |
+
* of this software and associated documentation files (the "Software"), to deal
|
12 |
+
* in the Software without restriction, including without limitation the rights
|
13 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 |
+
* copies of the Software, and to permit persons to whom the Software is
|
15 |
+
* furnished to do so, subject to the following conditions:
|
16 |
+
*
|
17 |
+
* The above copyright notice and this permission notice shall be included i
|
18 |
+
* all copies or substantial portions of the Software.
|
19 |
+
*
|
20 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OF
|
21 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
22 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
24 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
|
25 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26 |
+
* THE SOFTWARE.
|
27 |
+
*
|
28 |
+
-->
|
29 |
+
<config>
|
30 |
+
<modules>
|
31 |
+
<Intercastilla_Hideprices>
|
32 |
+
<active>true</active>
|
33 |
+
<codePool>community</codePool>
|
34 |
+
<depends>
|
35 |
+
<Mage_Catalog />
|
36 |
+
</depends>
|
37 |
+
</Intercastilla_Hideprices>
|
38 |
+
</modules>
|
39 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Intercastilla_Hideprices</name>
|
4 |
+
<version>0.2.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/MIT">MIT</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows you to hide prices for not logged-in or selected customer groups</summary>
|
10 |
+
<description>This extension allows you to hide prices for not logged-in and/or selected customer groups. It also removes the "add to cart" button</description>
|
11 |
+
<notes>Initial release</notes>
|
12 |
+
<authors><author><name>Intercastilla Team</name><user>comercial</user><email>comercial@intercastilla.com</email></author></authors>
|
13 |
+
<date>2014-11-25</date>
|
14 |
+
<time>17:20:30</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Intercastilla"><dir name="Hideprices"><dir name="Block"><dir name="Catalog"><dir name="Layer"><file name="View.php" hash="c8ecac387f7f7b7f0a35514bc54359e4"/></dir><file name=".DS_Store" hash="10a64f59410242bae6275897e348f9e7"/></dir></dir><dir name="Helper"><file name="Client.php" hash="41377241b7fe9c86f371770857b38687"/><file name="Data.php" hash="90282798fc83bbd0ccce48795c222c8a"/></dir><dir name="Model"><dir name="Observer"><file name="Product.php" hash="5500f62457e5c1eb260f21836b242f3d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f18cd6f993a22a72cfebd1369ebfb616"/><file name="config.xml" hash="fc0c34dcef964a07f1731b23cb07d916"/><file name="system.xml" hash="e0fde8f15b0bd19fc92130675da30829"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intercastilla_Hideprices.xml" hash="6b12ed5c100c4878f1c066b830e58d68"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|