Sitewards_B2BProfessional - Version 2.2.2

Version Notes

Add documentation and fix a bug with PHP 5.2

Download this release

Release Info

Developer Sitewards Magento Team
Extension Sitewards_B2BProfessional
Version 2.2.2
Comparing to
See all releases


Code changes from version 2.1.4 to 2.2.2

Files changed (37) hide show
  1. app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Price.php +0 -41
  2. app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Checkbox.php +0 -40
  3. app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Multi.php +0 -25
  4. app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Radio.php +0 -25
  5. app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Select.php +0 -25
  6. app/code/community/Sitewards/B2BProfessional/Block/Catalog/Product/List.php +24 -0
  7. app/code/community/Sitewards/B2BProfessional/Block/Catalog/Product/New.php +24 -0
  8. app/code/community/Sitewards/B2BProfessional/Block/Catalog/Product/Widget/New.php +24 -0
  9. app/code/community/Sitewards/B2BProfessional/Block/Checkout/Links.php +1 -1
  10. app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Compared.php +24 -0
  11. app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Viewed.php +24 -0
  12. app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Widget/Compared.php +24 -0
  13. app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Widget/Viewed.php +24 -0
  14. app/code/community/Sitewards/B2BProfessional/Docs/Sitewards B2B Professional_Deutsch V4.pdf +0 -0
  15. app/code/community/Sitewards/B2BProfessional/Docs/Sitewards B2B Professional_ENG_V4.pdf +0 -0
  16. app/code/community/Sitewards/B2BProfessional/Helper/Catalog/Product/Compare.php +23 -0
  17. app/code/community/Sitewards/B2BProfessional/Helper/Category.php +225 -0
  18. app/code/community/Sitewards/B2BProfessional/Helper/Core.php +35 -0
  19. app/code/community/Sitewards/B2BProfessional/Helper/Customer.php +157 -0
  20. app/code/community/Sitewards/B2BProfessional/Helper/Data.php +92 -380
  21. app/code/community/Sitewards/B2BProfessional/Helper/Messages.php +72 -0
  22. app/code/community/Sitewards/B2BProfessional/Helper/Redirects.php +39 -0
  23. app/code/community/Sitewards/B2BProfessional/Helper/Replacements.php +274 -0
  24. app/code/community/Sitewards/B2BProfessional/Model/Customer.php +4 -2
  25. app/code/community/Sitewards/B2BProfessional/Model/Observer.php +100 -19
  26. app/code/community/Sitewards/B2BProfessional/Model/System/Config/Source/Category.php +19 -19
  27. app/code/community/Sitewards/B2BProfessional/Model/System/Config/Source/Identifiers.php +4 -0
  28. app/code/community/Sitewards/B2BProfessional/controllers/CartController.php +8 -5
  29. app/code/community/Sitewards/B2BProfessional/etc/adminhtml.xml +1 -1
  30. app/code/community/Sitewards/B2BProfessional/etc/config.xml +41 -12
  31. app/code/community/Sitewards/B2BProfessional/etc/system.xml +84 -10
  32. app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/checkbox.phtml +34 -0
  33. app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/multi.phtml +31 -0
  34. app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/radio.phtml +47 -0
  35. app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/select.phtml +37 -0
  36. app/locale/de_DE/Sitewards_B2BProfessional.csv +6 -1
  37. package.xml +7 -6
app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Price.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_Block_Price
4
- * - Check that the current product is active and display custom text
5
- *
6
- * @author david.manners <david.manners@sitewards.com>
7
- * @category Sitewards
8
- * @package Sitewards_B2BProfessional
9
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
10
- */
11
- class Sitewards_B2BProfessional_Block_Bundle_Catalog_Price extends Mage_Bundle_Block_Catalog_Product_Price {
12
- /**
13
- * The last product Id
14
- *
15
- * @var int
16
- */
17
- protected static $_iLastProductId = 0;
18
-
19
- /**
20
- * Check that the current product is active
21
- * - Override the text with the module text
22
- *
23
- * @return string
24
- */
25
- protected function _toHtml() {
26
- $sPriceHtml = parent::_toHtml();
27
- $iCurrentProductId = $this->getProduct()->getId();
28
-
29
- /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
30
- $oB2BHelper = Mage::helper('b2bprofessional');
31
- if ($oB2BHelper->checkActive($iCurrentProductId)) {
32
- if ($iCurrentProductId == self::$_iLastProductId) {
33
- return '';
34
- }
35
- self::$_iLastProductId = $iCurrentProductId;
36
-
37
- return $oB2BHelper->getPriceMessage();
38
- }
39
- return $sPriceHtml;
40
- }
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Checkbox.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Checkbox
4
- * - Validate that the selection is active and display the custom information
5
- *
6
- * @category Sitewards
7
- * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
- */
10
- class Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Checkbox extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox {
11
- /**
12
- * Validate the it is active the display the selection name
13
- *
14
- * @param Mage_Catalog_Model_Product $oBundleSelection
15
- * @param boolean $bIncludeContainer
16
- * @return string
17
- */
18
- public function getSelectionTitlePrice($oBundleSelection, $bIncludeContainer = true) {
19
- if (Mage::helper('b2bprofessional')->checkActive()) {
20
- return $oBundleSelection->getName();
21
- } else {
22
- return parent::getSelectionTitlePrice($oBundleSelection, $bIncludeContainer);
23
- }
24
- }
25
-
26
- /**
27
- * Validate the it is active the display the selection quantity and name
28
- *
29
- * @param Mage_Catalog_Model_Product $oBundleSelection
30
- * @param boolean $bIncludeContainer
31
- * @return string
32
- */
33
- public function getSelectionQtyTitlePrice($oBundleSelection, $bIncludeContainer = true) {
34
- if (Mage::helper ( 'b2bprofessional' )->checkActive ()) {
35
- return $oBundleSelection->getSelectionQty() * 1 . ' x ' . $oBundleSelection->getName();
36
- } else {
37
- return parent::getSelectionQtyTitlePrice($oBundleSelection, $bIncludeContainer);
38
- }
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Multi.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Multi
4
- * - Validate that the selection is active and display the custom information
5
- *
6
- * @category Sitewards
7
- * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
- */
10
- class Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Multi extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Multi {
11
- /**
12
- * Validate that the selection is active and display custom information
13
- *
14
- * @param Mage_Catalog_Model_Product $oBundleSelection
15
- * @param boolean $bIncludeContainer
16
- * @return string
17
- */
18
- public function getSelectionTitlePrice($oBundleSelection, $bIncludeContainer = true) {
19
- if (Mage::helper('b2bprofessional')->checkActive()) {
20
- return $oBundleSelection->getName();
21
- } else {
22
- return parent::getSelectionTitlePrice($oBundleSelection, $bIncludeContainer);
23
- }
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Radio.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Radio
4
- * - Validate that the selection is active and display the custom information
5
- *
6
- * @category Sitewards
7
- * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
- */
10
- class Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Radio extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio {
11
- /**
12
- * Validate that the selection is active and display custom information
13
- *
14
- * @param Mage_Catalog_Model_Product $oBundleSelection
15
- * @param boolean $bIncludeContainer
16
- * @return string
17
- */
18
- public function getSelectionTitlePrice($oBundleSelection, $bIncludeContainer = true) {
19
- if (Mage::helper('b2bprofessional')->checkActive()) {
20
- return $oBundleSelection->getName();
21
- } else {
22
- return parent::getSelectionTitlePrice($oBundleSelection, $bIncludeContainer);
23
- }
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Product/View/Type/Bundle/Option/Select.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Select
4
- * - Validate that the selection is active and display the custom information
5
- *
6
- * @category Sitewards
7
- * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
- */
10
- class Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Select extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Select {
11
- /**
12
- * Validate that the selection is active and display custom information
13
- *
14
- * @param Mage_Catalog_Model_Product $oBundleSelection
15
- * @param boolean $bIncludeContainer
16
- * @return string
17
- */
18
- public function getSelectionTitlePrice($oBundleSelection, $bIncludeContainer = true) {
19
- if (Mage::helper('b2bprofessional')->checkActive()) {
20
- return $oBundleSelection->getName();
21
- } else {
22
- return parent::getSelectionTitlePrice($oBundleSelection, $bIncludeContainer);
23
- }
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sitewards/B2BProfessional/Block/Catalog/Product/List.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Catalog_Product_List
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Block/Catalog/Product/New.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Catalog_Product_New
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Catalog_Product_New extends Mage_Catalog_Block_Product_New {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Block/Catalog/Product/Widget/New.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Catalog_Product_Widget_New
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Catalog_Product_Widget_New extends Mage_Catalog_Block_Product_Widget_New {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Block/Checkout/Links.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @category Sitewards
7
  * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
  */
10
  class Sitewards_B2BProfessional_Block_Checkout_Links extends Mage_Checkout_Block_Links {
11
  /**
5
  *
6
  * @category Sitewards
7
  * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
  */
10
  class Sitewards_B2BProfessional_Block_Checkout_Links extends Mage_Checkout_Block_Links {
11
  /**
app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Compared.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Reports_Product_Compared
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Reports_Product_Compared extends Mage_Reports_Block_Product_Compared {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Viewed.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Reports_Product_Viewed
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Reports_Product_Viewed extends Mage_Reports_Block_Product_Viewed {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Widget/Compared.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Reports_Product_Widget_Compared
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Reports_Product_Widget_Compared extends Mage_Reports_Block_Product_Widget_Compared {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Block/Reports/Product/Widget/Viewed.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Reports_Product_Widget_Viewed
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Block_Reports_Product_Widget_Viewed extends Mage_Reports_Block_Product_Widget_Viewed {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @param array $aAdditional
17
+ * @return string
18
+ */
19
+ public function getAddToCartUrl($oProduct, $aAdditional = array()) {
20
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
21
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
22
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct, $aAdditional));
23
+ }
24
+ }
app/code/community/Sitewards/B2BProfessional/Docs/Sitewards B2B Professional_Deutsch V4.pdf ADDED
Binary file
app/code/community/Sitewards/B2BProfessional/Docs/Sitewards B2B Professional_ENG_V4.pdf ADDED
Binary file
app/code/community/Sitewards/B2BProfessional/Helper/Catalog/Product/Compare.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Helper_Catalog_Product_Compare
4
+ * - rewrite the getAddToCartUrl function to check if the product is active
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Helper_Catalog_Product_Compare extends Mage_Catalog_Helper_Product_Compare {
11
+ /**
12
+ * Check if the product is valid
13
+ * - return the replacement text for the add to cart url when required
14
+ *
15
+ * @param Mage_Catalog_Model_Product $oProduct
16
+ * @return string
17
+ */
18
+ public function getAddToCartUrl($oProduct) {
19
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
20
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
21
+ return $oB2BReplacementsHelper->replaceAddToCart($oProduct->getId(), parent::getAddToCartUrl($oProduct));
22
+ }
23
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Category.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_B2BProfessional_Helper_Category
4
+ * - function to check if extension is activated by category
5
+ * - function to check if category is active
6
+ * - function to check if category is active by a given product id
7
+ * - function to get the current category id and all children ids
8
+ * - function to get the category ids of each category filter set
9
+ * - function to check that at least one of the given category ids is active
10
+ * - function to get the current category object
11
+ * - function to get all category ids activated via the system config
12
+ * - function to get an array of category ids activated via the admin config section
13
+ * - function to load all child category ids into an array from a given category id
14
+ *
15
+ * @category Sitewards
16
+ * @package Sitewards_B2BProfessional
17
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
18
+ */
19
+ class Sitewards_B2BProfessional_Helper_Category extends Mage_Core_Helper_Abstract {
20
+ /**
21
+ * Check to see if the extension is activated by category
22
+ *
23
+ * @return bool
24
+ */
25
+ public function isExtensionActivatedByCategory() {
26
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_CATEGORY_SETTINGS_NODE . '/activebycategory');
27
+ }
28
+
29
+ /**
30
+ * Validate that the category is activated in the module
31
+ *
32
+ * @return boolean
33
+ */
34
+ public function isCategoryActive() {
35
+ /*
36
+ * Check if there is a filtered category
37
+ * - If not check for a current_category,
38
+ * - If not load the store default category,
39
+ */
40
+ $aB2BProfFilters = Mage::registry('b2bprof_category_filters');
41
+ if(empty($aB2BProfFilters)) {
42
+ $aCurrentCategories = $this->getCurrentCategoryIds();
43
+ } else {
44
+ $aCurrentCategories = $this->getCategoryIdsByB2BProfFilters($aB2BProfFilters);
45
+ }
46
+ $aCurrentCategories = array_unique($aCurrentCategories);
47
+
48
+ if (!is_array($aCurrentCategories)) {
49
+ $aCurrentCategories = array (
50
+ $aCurrentCategories
51
+ );
52
+ }
53
+ return $this->hasActiveCategory($aCurrentCategories);
54
+ }
55
+
56
+ /**
57
+ * Validate that the category of a give product is activated in the module
58
+ *
59
+ * @param int $iProductId
60
+ * @return boolean
61
+ */
62
+ public function isCategoryActiveByProduct($iProductId) {
63
+ /* @var $oProduct Mage_Catalog_Model_Product */
64
+ $oProduct = Mage::getModel('catalog/product')->load($iProductId);
65
+ $aCurrentCategories = $oProduct->getCategoryIds();
66
+ $aParentProductIds = array();
67
+
68
+ if($oProduct->isGrouped()) {
69
+ /* @var $oGroupedProductModel Mage_Catalog_Model_Product_Type_Grouped */
70
+ $oGroupedProductModel = Mage::getModel('catalog/product_type_grouped');
71
+ $aParentProductIds = $oGroupedProductModel->getParentIdsByChild($iProductId);
72
+ } elseif($oProduct->isConfigurable()) {
73
+ /* @var $oConfigurableProductModel Mage_Catalog_Model_Product_Type_Configurable */
74
+ $oConfigurableProductModel = Mage::getModel('catalog/product_type_configurable');
75
+ $aParentProductIds = $oConfigurableProductModel->getParentIdsByChild($iProductId);
76
+ }
77
+
78
+ if(!empty($aParentProductIds)) {
79
+ foreach ($aParentProductIds as $iParentProductId) {
80
+ /* @var $oParentProduct Mage_Catalog_Model_Product */
81
+ $oParentProduct = Mage::getModel('catalog/product')->load($iParentProductId);
82
+ $aParentProductCategories = $oParentProduct->getCategoryIds();
83
+ $aCurrentCategories = array_merge($aCurrentCategories, $aParentProductCategories);
84
+ }
85
+ }
86
+ $aCurrentCategories = array_unique($aCurrentCategories);
87
+
88
+ if (!is_array($aCurrentCategories)) {
89
+ $aCurrentCategories = array (
90
+ $aCurrentCategories
91
+ );
92
+ }
93
+ return $this->hasActiveCategory($aCurrentCategories);
94
+ }
95
+
96
+ /**
97
+ * Get the current category id and all children ids
98
+ *
99
+ * @return array
100
+ */
101
+ private function getCurrentCategoryIds() {
102
+ /* @var $oCategory Mage_Catalog_Model_Category */
103
+ $oCategory = $this->getCurrentCategory();
104
+
105
+ $aCurrentCategories = $oCategory->getAllChildren(true);
106
+ $aCurrentCategories[] = $oCategory->getId();
107
+
108
+ return $aCurrentCategories;
109
+ }
110
+
111
+ /**
112
+ * Get the category ids of each category filter set
113
+ *
114
+ * @param array $aB2BProfFilters
115
+ * array(
116
+ * cat_id_1,
117
+ * cat_id_2
118
+ * )
119
+ * @return array
120
+ */
121
+ private function getCategoryIdsByB2BProfFilters($aB2BProfFilters) {
122
+ $aCurrentCategories = $aB2BProfFilters;
123
+ foreach($aB2BProfFilters as $iCategoryId) {
124
+ /* @var $oCategory Mage_Catalog_Model_Category */
125
+ $oCategory = Mage::getModel('catalog/category')->load($iCategoryId);
126
+
127
+ $aCurrentCategories = array_merge($aCurrentCategories, $oCategory->getAllChildren(true));
128
+ }
129
+ return $aCurrentCategories;
130
+ }
131
+
132
+ /**
133
+ * Check that at least one of the given category ids is active
134
+ *
135
+ * @param array $aCategoryIds
136
+ * @return bool
137
+ */
138
+ private function hasActiveCategory($aCategoryIds) {
139
+ $aActiveCategoryIds = $this->getActiveCategories();
140
+ foreach ($aCategoryIds as $iCategoryId) {
141
+ if (in_array($iCategoryId, $aActiveCategoryIds)) {
142
+ return true;
143
+ }
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Get the current category object
149
+ * - Use the "filter category" if set
150
+ * - Use the "current_category" if set
151
+ * - Use the store root category
152
+ *
153
+ * @return Mage_Catalog_Model_Category
154
+ */
155
+ private function getCurrentCategory() {
156
+ /* @var $oCategory Mage_Catalog_Model_Category */
157
+ $oCategory = Mage::registry('current_category_filter');
158
+ if(is_null($oCategory)) {
159
+ $oCategory = Mage::registry('current_category');
160
+ if(is_null($oCategory)) {
161
+ $oCategory = Mage::getModel('catalog/category')->load(Mage::app()->getStore()->getRootCategoryId());
162
+ }
163
+ }
164
+ return $oCategory;
165
+ }
166
+
167
+ /**
168
+ * Get all category ids activated via the system config
169
+ * - Include the children category ids
170
+ *
171
+ * @return array
172
+ * array(
173
+ * cat_id_1,
174
+ * cat_id_2
175
+ * )
176
+ */
177
+ private function getActiveCategories() {
178
+ $aCurrentActiveCategories = $this->getActivatedCategoryIds();
179
+
180
+ /**
181
+ * Loop through each activated category ids and add children category ids
182
+ */
183
+ $aSubActiveCategories = array();
184
+ foreach ($aCurrentActiveCategories as $iCategoryId) {
185
+ $aSubActiveCategories = $this->addCategoryChildren($iCategoryId, $aSubActiveCategories);
186
+ }
187
+ return array_unique($aSubActiveCategories);
188
+ }
189
+
190
+ /**
191
+ * Get an array of category ids activated via the admin config section
192
+ *
193
+ * @return array
194
+ */
195
+ private function getActivatedCategoryIds() {
196
+ /*
197
+ * Category Ids are saved in the config in format
198
+ * - "category1,category2"
199
+ */
200
+ $sActivatedCategoryIds = Mage::getStoreConfig(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_CATEGORY_SETTINGS_NODE . '/activecategories');
201
+ return explode(',', $sActivatedCategoryIds);
202
+ }
203
+
204
+ /**
205
+ * From given category id load all child ids into an array
206
+ *
207
+ * @param int $iCategoryId
208
+ * @param array $aCurrentCategories
209
+ * array(
210
+ * cat_id_1,
211
+ * cat_id_2
212
+ * )
213
+ * @return array
214
+ * array(
215
+ * cat_id_1,
216
+ * cat_id_2
217
+ * )
218
+ */
219
+ private function addCategoryChildren($iCategoryId, $aCurrentCategories = array()) {
220
+ /* @var $oCurrentCategory Mage_Catalog_Model_Category */
221
+ $oCurrentCategory = Mage::getModel('catalog/category');
222
+ $oCurrentCategory = $oCurrentCategory->load($iCategoryId);
223
+ return array_merge($aCurrentCategories, $oCurrentCategory->getAllChildren(true));
224
+ }
225
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Core.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_B2BProfessional_Helper_Core
4
+ * - define the reusable sections of the config file
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Helper_Core extends Mage_Core_Helper_Abstract {
11
+ /**
12
+ * The root node of the b2b professional configuration
13
+ */
14
+ const CONFIG_B2B_PROFESSIONAL_NODE = 'b2bprofessional';
15
+
16
+ /**
17
+ * The general settings node of the b2b professional configuration
18
+ */
19
+ const CONFIG_GENERAL_SETTINGS_NODE = 'generalsettings';
20
+
21
+ /**
22
+ * The language settings node of the b2b professional configuration
23
+ */
24
+ const CONFIG_LANGUAGE_SETTINGS_NODE = 'languagesettings';
25
+
26
+ /**
27
+ * The category settings node of the b2b professional configuration
28
+ */
29
+ const CONFIG_CATEGORY_SETTINGS_NODE = 'activatebycategorysettings';
30
+
31
+ /**
32
+ * The customer settings node of the b2b professional configuration
33
+ */
34
+ const CONFIG_CUSTOMER_SETTINGS_NODE = 'activatebycustomersettings';
35
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Customer.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_B2BProfessional_Helper_Customer
4
+ * - function to check if extension is activated by customer
5
+ * - function to check if extension requires login
6
+ * - function to check if customer is active
7
+ * - function to check if customer is allowed in the current store
8
+ * - function to check if customers are activated globally
9
+ * - function to check if customer is active for store
10
+ * - function to check if customer was created via the admin section
11
+ * - function to get the extension's activated customer groups
12
+ *
13
+ * @category Sitewards
14
+ * @package Sitewards_B2BProfessional
15
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
16
+ */
17
+ class Sitewards_B2BProfessional_Helper_Customer extends Mage_Core_Helper_Abstract {
18
+ /**
19
+ * Check to see if the extension is activated by customer
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isExtensionActivatedByCustomer() {
24
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_CUSTOMER_SETTINGS_NODE . '/activebycustomer');
25
+ }
26
+
27
+ /**
28
+ * Check to see if the website is set-up to require a user login to view pages
29
+ *
30
+ * @return boolean
31
+ */
32
+ public function isLoginRequired() {
33
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/requirelogin/requirelogin');
34
+ }
35
+
36
+ /**
37
+ * Check that the current customer's group id is in the list of active group ids
38
+ *
39
+ * @return boolean
40
+ */
41
+ public function isCustomerActive() {
42
+ /* @var $oCustomerSession Mage_Customer_Model_Session */
43
+ $oCustomerSession = Mage::getModel('customer/session');
44
+ $iCurrentCustomerGroupId = $oCustomerSession->getCustomerGroupId();
45
+ $aActiveCustomerGroupIds = $this->getActivatedCustomerGroupIds();
46
+
47
+ if (in_array($iCurrentCustomerGroupId, $aActiveCustomerGroupIds)) {
48
+ return true;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Check to see if the user is allowed on the current store
54
+ * - Check if the customer is logged in,
55
+ * - Check if the extension is set to have global customer activation,
56
+ * - Check if the user is active for the current store
57
+ *
58
+ * @return bool
59
+ */
60
+ public function isCustomerAllowedInStore() {
61
+ /* @var $oCustomerSession Mage_Customer_Model_Session */
62
+ $oCustomerSession = Mage::getSingleton('customer/session');
63
+ if ($oCustomerSession->isLoggedIn()) {
64
+ /*
65
+ * If customer activation is global
66
+ * - then any customer can access any store
67
+ */
68
+ if ($this->isCustomerActivationGlobal()) {
69
+ return true;
70
+ }
71
+
72
+ /* @var $oCustomer Mage_Customer_Model_Customer */
73
+ $oCustomer = $oCustomerSession->getCustomer();
74
+ if($this->isCustomerActiveForStore($oCustomer)) {
75
+ return true;
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Check to see if the extension has the "global customer activation"
82
+ *
83
+ * @return bool
84
+ */
85
+ private function isCustomerActivationGlobal() {
86
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_GENERAL_SETTINGS_NODE . '/activecustomers');
87
+ }
88
+
89
+ /**
90
+ * Check to see if the user is active for current store
91
+ * NOTE: users created via the admin section cannot be attached to a front end store and so have global activation
92
+ *
93
+ * @param $oCustomer Mage_Customer_Model_Customer
94
+ * @return bool
95
+ */
96
+ private function isCustomerActiveForStore($oCustomer) {
97
+ /*
98
+ * Check to see if the user was created via the admin section
99
+ * - Note: users created via the admin section cannot be attached to a front end store
100
+ */
101
+ if ($this->isCustomerAdminCreation($oCustomer)) {
102
+ return true;
103
+ }
104
+
105
+ /*
106
+ * Get user's store and current store for comparison
107
+ */
108
+ $iUserStoreId = $oCustomer->getStoreId();
109
+ $iCurrentStoreId = Mage::app()->getStore()->getId();
110
+
111
+ /*
112
+ * Return true if:
113
+ * - the user's store id matches the current store id
114
+ */
115
+ if ($iUserStoreId == $iCurrentStoreId) {
116
+ return true;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Check to see if the user has been created via the admin section
122
+ *
123
+ * @param $oCustomer Mage_Customer_Model_Customer
124
+ * @return bool
125
+ */
126
+ private function isCustomerAdminCreation($oCustomer) {
127
+ if($oCustomer->getCreatedIn() == 'Admin') {
128
+ return true;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Get an array of all the activated customer group ids
134
+ * - always include the 'NOT LOGGED IN' group
135
+ *
136
+ * @return array
137
+ */
138
+ private function getActivatedCustomerGroupIds() {
139
+ /*
140
+ * Customer group ids are saved in the config in format
141
+ * - "group1,group2"
142
+ */
143
+ $sActivatedCustomerGroups = Mage::getStoreConfig(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_CUSTOMER_SETTINGS_NODE . '/activecustomers');
144
+ $aActivatedCustomerGroupIds = explode(',', $sActivatedCustomerGroups);
145
+
146
+ /*
147
+ * Always add the guest user group id when activated by customer group
148
+ * Note: the the group code for the guest user can not be changed via the admin section
149
+ */
150
+ /* @var $oCustomerGroup Mage_Customer_Model_Group */
151
+ $oCustomerGroup = Mage::getModel('customer/group');
152
+ $iGuestGroupId = $oCustomerGroup->load('NOT LOGGED IN', 'customer_group_code')->getId();
153
+ $aActivatedCustomerGroupIds[] = $iGuestGroupId;
154
+
155
+ return $aActivatedCustomerGroupIds;
156
+ }
157
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Data.php CHANGED
@@ -12,212 +12,135 @@
12
  *
13
  * @category Sitewards
14
  * @package Sitewards_B2BProfessional
15
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
16
  */
17
  class Sitewards_B2BProfessional_Helper_Data extends Mage_Core_Helper_Abstract {
18
  /**
19
- * Regular expression for replacements
 
 
20
  */
21
- const PATTERN_BASE = '@<%1$s %2$s="%3$s"[^>]*?>.*?</%1$s>@siu';
22
 
23
  /**
24
- * Check to see if the website is set-up to require a user login to view pages
25
  *
26
- * @return boolean
27
  */
28
- public function checkRequireLogin() {
29
- return Mage::getStoreConfigFlag('b2bprofessional/generalsettings/requirelogin');
30
- }
31
 
32
  /**
33
- * Check to see if the user is allowed on the current store
34
- *
35
- * @return boolean
36
  */
37
- public function checkAllowed() {
38
- // if option is not active return true!
39
- if (Mage::getStoreConfig('b2bprofessional/generalsettings/activecustomers')) {
40
- return true;
41
- }
42
-
43
- $bCreatedViaAdmin = false;
44
- $oCustomer = Mage::getSingleton('customer/session')->getCustomer();
45
- if($oCustomer->getCreatedIn() == 'Admin') {
46
- $bCreatedViaAdmin = true;
47
- }
48
- $iUserStoreId = $oCustomer->getStoreId();
49
- $iCurrentStoreId = Mage::app()->getStore()->getId();
50
-
51
- if ($iUserStoreId == $iCurrentStoreId || $bCreatedViaAdmin == true) {
52
- return true;
53
- }
54
  }
55
 
56
  /**
57
- * Validate that the category of a give product is activated in the module
58
- *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  * @param int $iProductId
60
- * @return boolean
61
  */
62
- public function checkCategoryIsActive($iProductId = null) {
63
- $aCurrentCategories = array ();
 
 
 
64
 
65
- // activate by category
66
- if ($iProductId !== null) {
67
- /* @var $oProduct Mage_Catalog_Model_Product */
68
- $oProduct = Mage::getModel('catalog/product')->load($iProductId);
69
- $aParentProductIds = $oProduct->loadParentProductIds()->getData('parent_product_ids');
70
- if (!empty($aParentProductIds) && $oProduct->isGrouped()) {
71
- foreach ($aParentProductIds as $iParentProductId) {
72
- /* @var $oParentProduct Mage_Catalog_Model_Product */
73
- $oParentProduct = Mage::getModel('catalog/product')->load($iParentProductId);
74
- $aParentProductCategories = $oParentProduct->getCategoryIds();
75
- $aCurrentCategories = array_merge($aCurrentCategories, $aParentProductCategories);
76
- }
77
- } else {
78
- $aCurrentCategories = $oProduct->getCategoryIds();
79
  }
80
- } else {
81
- /*
82
- * Check if there is a filtered category
83
- * - If not check for a current_category,
84
- * - If not load the store default category,
85
- */
86
- $aB2BProfFilters = Mage::registry('b2bprof_category_filters');
87
- if(empty($aB2BProfFilters)) {
88
- /* @var $oCategory Mage_Catalog_Model_Category */
89
- $oCategory = Mage::registry('current_category_filter');
90
- if(is_null($oCategory)) {
91
- $oCategory = Mage::registry('current_category');
92
- if(is_null($oCategory)) {
93
- $oCategory = Mage::getModel('catalog/category')->load(Mage::app()->getStore()->getRootCategoryId());
94
- }
95
- }
96
- $aCurrentCategories = $oCategory->getAllChildren(true);
97
- $aCurrentCategories[] = $oCategory->getId();
98
- } else {
99
- $aCurrentCategories = $aB2BProfFilters;
100
- foreach($aB2BProfFilters as $iCategoryId) {
101
- $oCategory = Mage::getModel('catalog/category')->load($iCategoryId);
102
 
103
- $aCurrentCategories = array_merge($aCurrentCategories, $oCategory->getAllChildren(true));
104
- }
105
- }
106
- }
107
- $aCurrentCategories = array_unique($aCurrentCategories);
108
 
109
- $aActiveCategories = $this->getActiveCategories();
110
- if (!is_array($aCurrentCategories)) {
111
- $aCurrentCategories = array (
112
- $aCurrentCategories
113
- );
114
- }
115
- $bActive = false;
116
- foreach ($aCurrentCategories as $iCategoryId) {
117
- if (in_array($iCategoryId, $aActiveCategories)) {
118
- $bActive = true;
119
  }
120
- }
121
- return $bActive;
122
- }
123
-
124
- /**
125
- * Check that the current customer has an active group id
126
- *
127
- * @return boolean
128
- */
129
- public function checkCustomerIsActive() {
130
- // activate by customer group
131
- /* @var $oCustomerSession Mage_Customer_Model_Session */
132
- $oCustomerSession = Mage::getModel('customer/session');
133
- $iCurrentCustomerGroupId = $oCustomerSession->getCustomerGroupId();
134
- $aActiveCustomerGroupIds = explode(',', Mage::getStoreConfig('b2bprofessional/activatebycustomersettings/activecustomers'));
135
-
136
- /*
137
- * Always add the guest user when activated by customer group
138
- * Note: the the group code for the guest user can not be changed via the admin section
139
- */
140
- $iGuestGroupId = Mage::getModel('customer/group')->load('NOT LOGGED IN', 'customer_group_code')->getId();
141
- $aActiveCustomerGroupIds[] = $iGuestGroupId;
142
-
143
- if (in_array($iCurrentCustomerGroupId, $aActiveCustomerGroupIds)) {
144
- return true;
145
  } else {
146
- return false;
147
- }
148
- }
149
-
150
- /**
151
- * Check the global active flag
152
- *
153
- * @return boolean
154
- */
155
- public function checkGlobalActive() {
156
- if (Mage::getStoreConfig('b2bprofessional/generalsettings/active') == 1) {
157
- return true;
158
- }
159
- }
160
-
161
- /**
162
- * Check that a customer is logged in,
163
- * - If they are logged in validate their account usint the checkAllowed function
164
- *
165
- * @return boolean
166
- */
167
- public function checkLoggedIn() {
168
- $bLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
169
-
170
- if (!$this->checkAllowed()) {
171
- $bLoggedIn = false;
172
  }
173
- return $bLoggedIn;
174
  }
175
 
176
  /**
177
- * Check that the product/customer is activated
178
- *
179
- * @param int $iProductId
180
- * @return boolean
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  */
182
- public function checkActive($iProductId = null) {
183
  $bIsLoggedIn = false;
184
  // global extension activation
185
- if ($this->checkGlobalActive()) {
 
 
186
  // check user logged in and has store access
187
- if ($this->checkLoggedIn()) {
188
  $bIsLoggedIn = true;
189
  }
190
 
191
- $bCheckUser = Mage::getStoreConfigFlag('b2bprofessional/activatebycustomersettings/activebycustomer');
192
- $bCheckCategory = Mage::getStoreConfigFlag('b2bprofessional/activatebycategorysettings/activebycategory');
193
 
194
  if($bCheckUser == true && $bCheckCategory == true) {
195
- // check both the category and customer group is active via the extension
196
- if ($this->checkCategoryIsActive($iProductId) && $this->checkCustomerIsActive()) {
197
- $bIsActive = true;
198
- } else {
199
- $bIsActive = false;
200
- }
201
  } elseif($bCheckUser == true) {
202
- // check user group is active via the extension
203
- if ($this->checkCustomerIsActive()) {
204
- $bIsActive = true;
205
- } else {
206
- $bIsActive = false;
207
- }
208
  } elseif ($bCheckCategory == true) {
209
- // check category is active via the extension
210
- if (!$this->checkCategoryIsActive($iProductId) || $bIsLoggedIn == true) {
211
- $bIsActive = false;
212
- } else {
213
- $bIsActive = true;
214
- }
215
  } else {
216
- if ($bIsLoggedIn == false) {
217
- $bIsActive = true;
218
- } else {
219
- $bIsActive = false;
220
- }
221
  }
222
  } else {
223
  $bIsActive = false;
@@ -225,80 +148,6 @@ class Sitewards_B2BProfessional_Helper_Data extends Mage_Core_Helper_Abstract {
225
  return $bIsActive;
226
  }
227
 
228
- /**
229
- * Get all active categories
230
- * - allow for sub categories also
231
- * @param boolean $bIncludeSubCategories
232
- * @return array
233
- * array(
234
- * cat_id_1,
235
- * cat_id_2
236
- * )
237
- */
238
- public function getActiveCategories($bIncludeSubCategories = true) {
239
- $aCurrentActiveCategories = explode(',', Mage::getStoreConfig('b2bprofessional/activatebycategorysettings/activecategories'));
240
- if($bIncludeSubCategories == false) {
241
- return $aCurrentActiveCategories;
242
- }
243
-
244
- $aSubActiveCategories = array();
245
- foreach ($aCurrentActiveCategories as $iCategoryId) {
246
- $aSubActiveCategories = $this->addCategoryChildren($iCategoryId, $aSubActiveCategories);
247
- }
248
- return array_unique($aSubActiveCategories);
249
- }
250
-
251
- /**
252
- * From given category id load all child ids into an array
253
- *
254
- * @param int $iCategoryId
255
- * @param array $aCurrentCategories
256
- * array(
257
- * cat_id_1,
258
- * cat_id_2
259
- * )
260
- * @return array
261
- * array(
262
- * cat_id_1,
263
- * cat_id_2
264
- * )
265
- */
266
- public function addCategoryChildren($iCategoryId, $aCurrentCategories = array()) {
267
- /* @var $oCurrentCategory Mage_Catalog_Model_Category */
268
- $oCurrentCategory = Mage::getModel('catalog/category');
269
- $oCurrentCategory = $oCurrentCategory->load($iCategoryId);
270
- return array_merge($aCurrentCategories, $oCurrentCategory->getAllChildren(true));
271
- }
272
-
273
- /**
274
- * Get the require login message
275
- *
276
- * @return string
277
- */
278
- public function getRequireLoginMessage() {
279
- // text displayed instead of price
280
- if (Mage::getStoreConfig('b2bprofessional/languagesettings/languageoverride') == 1) {
281
- $sLoginMessage = Mage::getStoreConfig('b2bprofessional/languagesettings/requireloginmessage');
282
- } else {
283
- $sLoginMessage = $this->__('You do not have access to view this store.');
284
- }
285
- return $sLoginMessage;
286
- }
287
-
288
- /**
289
- * Get the url of the require login redirect
290
- *
291
- * @return string
292
- */
293
- public function getRequireLoginRedirect() {
294
- $sRedirectPath = '/';
295
- $sConfigVar = Mage::getStoreConfig('b2bprofessional/generalsettings/requireloginredirect');
296
- if (isset($sConfigVar)) {
297
- $sRedirectPath = $sConfigVar;
298
- }
299
- return Mage::getUrl($sRedirectPath);
300
- }
301
-
302
  /**
303
  * Validate that the current quote in the checkout session is valid for the user
304
  * - Check each item in the quote against the function checkActive
@@ -315,147 +164,10 @@ class Sitewards_B2BProfessional_Helper_Data extends Mage_Core_Helper_Abstract {
315
  /*
316
  * For each item check if it is active for the current user
317
  */
318
- if ($this->checkActive($iProductId)) {
319
  $bValidCart = false;
320
  }
321
  }
322
  return $bValidCart;
323
  }
324
-
325
- /**
326
- * Get the message to replace prices with
327
- * - Check for admin language override
328
- *
329
- * @return string
330
- */
331
- public function getPriceMessage() {
332
- // text displayed instead of price
333
- if (Mage::getStoreConfig('b2bprofessional/languagesettings/languageoverride') == 1) {
334
- $sReplacementText = Mage::getStoreConfig('b2bprofessional/languagesettings/logintext');
335
- } else {
336
- $sReplacementText = $this->__('Please login');
337
- }
338
- return $sReplacementText;
339
- }
340
-
341
- /**
342
- * * Get the checkout error message
343
- * - Check for admin language override
344
- *
345
- * @return string
346
- */
347
- public function getCheckoutMessage() {
348
- if (Mage::getStoreConfig('b2bprofessional/languagesettings/languageoverride') == 1) {
349
- $sCheckoutMessage = Mage::getStoreConfig('b2bprofessional/languagesettings/errortext');
350
- } else {
351
- $sCheckoutMessage = $this->__('Your account is not allowed to access this store.');
352
- }
353
- return $sCheckoutMessage;
354
- }
355
-
356
- /**
357
- * When we have an invalid cart
358
- * - Perform a preg_replace with a given set of patterns and replacements on a string
359
- * - When product id is given check for valid product
360
- * - When no product id is given then check to complete cart
361
- *
362
- * @param array $aPatterns
363
- * @param array $aReplacements
364
- * @param string $sBlockHtml
365
- * @param int $iProductId
366
- * @return string
367
- */
368
- public function replaceOnInvalidCart($aPatterns, $aReplacements, $sBlockHtml, $iProductId = null) {
369
- /*
370
- * If you have no product id provided and an invalid cart
371
- * OR
372
- * If you have a product id provided and it is invalid
373
- *
374
- * THEN
375
- * Perform the preg_replace
376
- */
377
- if (
378
- is_null($iProductId) && !$this->hasValidCart()
379
- ||
380
- !is_null($iProductId) && $this->checkActive($iProductId)
381
- ) {
382
- $sBlockHtml = preg_replace(
383
- $aPatterns,
384
- $aReplacements,
385
- $sBlockHtml
386
- );
387
- }
388
- return $sBlockHtml;
389
- }
390
-
391
- /**
392
- * From a given config section
393
- * - Load all the config
394
- * - remove unused sections
395
- * - perform a sprintf on given config items
396
- *
397
- * @param string $sConfigSection
398
- * @return string
399
- */
400
- public function getPattern($sConfigSection) {
401
- // Load config array and unset unused information
402
- $aSectionConfig = Mage::getStoreConfig('b2bprofessional/'.$sConfigSection);
403
- unset($aSectionConfig['replace']);
404
- unset($aSectionConfig['remove']);
405
-
406
- // Replace the tag, id and value sections of the regular expression
407
- return sprintf($this::PATTERN_BASE, $aSectionConfig['tag'], $aSectionConfig['id'], $aSectionConfig['value']);
408
- }
409
-
410
- /**
411
- * Get replacement text for a given config section
412
- *
413
- * @param string $sConfigSection
414
- * @return string
415
- */
416
- public function getReplacement($sConfigSection) {
417
- // Check for the remove flag
418
- if(!Mage::getStoreConfigFlag('b2bprofessional/'.$sConfigSection.'/remove')) {
419
- // If the remove flag is not set then get the module's price message
420
- return $this->getPriceMessage();
421
- }
422
- }
423
-
424
- /**
425
- * Check if a given config section should be replaced
426
- *
427
- * @param string $sConfigSection
428
- * @return bool
429
- */
430
- public function replaceSection($sConfigSection) {
431
- return Mage::getStoreConfigFlag('b2bprofessional/'.$sConfigSection.'/replace');
432
- }
433
-
434
- /**
435
- * Build two arrays,
436
- * - one for patterns
437
- * - one for replacements,
438
- * Using these two array call to replace the patterns when the cart is invalid
439
- *
440
- * @param array $aSections
441
- * @param string $sHtml
442
- * @param int $iProductId
443
- * @return string
444
- */
445
- public function replaceSections($aSections, $sHtml, $iProductId = null) {
446
- $aPatterns = array();
447
- $aReplacements = array();
448
- /*
449
- * Foreach section to replace
450
- * - add the pattern
451
- * - add the replacement
452
- */
453
- foreach($aSections as $sReplaceSection) {
454
- if($this->replaceSection($sReplaceSection)) {
455
- $aPatterns[] = $this->getPattern($sReplaceSection);
456
- $aReplacements[] = $this->getReplacement($sReplaceSection);
457
- }
458
- }
459
- return $this->replaceOnInvalidCart($aPatterns, $aReplacements, $sHtml, $iProductId);
460
- }
461
  }
12
  *
13
  * @category Sitewards
14
  * @package Sitewards_B2BProfessional
15
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
16
  */
17
  class Sitewards_B2BProfessional_Helper_Data extends Mage_Core_Helper_Abstract {
18
  /**
19
+ * Object for the sitewards b2bprofessional category helper
20
+ *
21
+ * @var Sitewards_B2BProfessional_Helper_Category
22
  */
23
+ protected $oB2BCategoryHelper;
24
 
25
  /**
26
+ * Object for the sitewards b2bprofessional customer helper
27
  *
28
+ * @var Sitewards_B2BProfessional_Helper_Customer
29
  */
30
+ protected $oB2BCustomerHelper;
 
 
31
 
32
  /**
33
+ * Create instances of the sitewards b2bprofessional category and customer helpers
 
 
34
  */
35
+ protected function _prepareHelpers() {
36
+ /** @var $this->oB2BCategoryHelper Sitewards_B2BProfessional_Helper_Category */
37
+ $this->oB2BCategoryHelper = Mage::helper('b2bprofessional/category');
38
+ /** @var $this->oB2BCustomerHelper Sitewards_B2BProfessional_Helper_Customer */
39
+ $this->oB2BCustomerHelper = Mage::helper('b2bprofessional/customer');
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
  /**
43
+ * Check to see if the extension is active
44
+ * Returns the extension's general setting "active"
45
+ *
46
+ * @return bool
47
+ */
48
+ public function isExtensionActive() {
49
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_GENERAL_SETTINGS_NODE . '/active');
50
+ }
51
+
52
+ /**
53
+ * Check that the price can be displayed for the given product id
54
+ * - Check that the extension is active
55
+ * - Check that the customer is allowed in the store
56
+ * - When the extension is activated by customer group and category
57
+ * - Check that:
58
+ * - The category is active by product
59
+ * - AND The customer is active
60
+ * - When the extension is activated by customer group
61
+ * - Check that:
62
+ * - The customer is active
63
+ * - When the extension is activated by category
64
+ * - Check that:
65
+ * - The category is active by product
66
+ * - AND the user is not logged in
67
+ * - Else
68
+ * - Check if the user is not logged in
69
+ *
70
  * @param int $iProductId
71
+ * @return bool
72
  */
73
+ public function isProductActive($iProductId) {
74
+ $bIsLoggedIn = false;
75
+ // global extension activation
76
+ if ($this->isExtensionActive()) {
77
+ $this->_prepareHelpers();
78
 
79
+ // check user logged in and has store access
80
+ if ($this->oB2BCustomerHelper->isCustomerAllowedInStore()) {
81
+ $bIsLoggedIn = true;
 
 
 
 
 
 
 
 
 
 
 
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ $bCheckUser = $this->oB2BCustomerHelper->isExtensionActivatedByCustomer();
85
+ $bCheckCategory = $this->oB2BCategoryHelper->isExtensionActivatedByCategory();
 
 
 
86
 
87
+ if($bCheckUser == true && $bCheckCategory == true) {
88
+ $bIsActive = $this->oB2BCategoryHelper->isCategoryActiveByProduct($iProductId) && $this->oB2BCustomerHelper->isCustomerActive();
89
+ } elseif($bCheckUser == true) {
90
+ $bIsActive = $this->oB2BCustomerHelper->isCustomerActive();
91
+ } elseif ($bCheckCategory == true) {
92
+ $bIsActive = $this->oB2BCategoryHelper->isCategoryActiveByProduct($iProductId) && !$bIsLoggedIn;
93
+ } else {
94
+ $bIsActive = !$bIsLoggedIn;
 
 
95
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  } else {
97
+ $bIsActive = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
+ return $bIsActive;
100
  }
101
 
102
  /**
103
+ * Check that the price can be displayed when no product id is given
104
+ * - Check that the extension is active
105
+ * - Check that the customer is allowed in the store
106
+ * - When the extension is activated by customer group and category
107
+ * - Check that:
108
+ * - The category is active
109
+ * - AND The customer is active
110
+ * - When the extension is activated by customer group
111
+ * - Check that:
112
+ * - The customer is active
113
+ * - When the extension is activated by category
114
+ * - Check that:
115
+ * - The category is active
116
+ * - AND the user is not logged in
117
+ * - Else
118
+ * - Check if the user not is logged in
119
+ *
120
+ * @return bool
121
  */
122
+ public function isActive() {
123
  $bIsLoggedIn = false;
124
  // global extension activation
125
+ if ($this->isExtensionActive()) {
126
+ $this->_prepareHelpers();
127
+
128
  // check user logged in and has store access
129
+ if ($this->oB2BCustomerHelper->isCustomerAllowedInStore()) {
130
  $bIsLoggedIn = true;
131
  }
132
 
133
+ $bCheckUser = $this->oB2BCustomerHelper->isExtensionActivatedByCustomer();
134
+ $bCheckCategory = $this->oB2BCategoryHelper->isExtensionActivatedByCategory();
135
 
136
  if($bCheckUser == true && $bCheckCategory == true) {
137
+ $bIsActive = $this->oB2BCategoryHelper->isCategoryActive() && $this->oB2BCustomerHelper->isCustomerActive();
 
 
 
 
 
138
  } elseif($bCheckUser == true) {
139
+ $bIsActive = $this->oB2BCustomerHelper->isCustomerActive();
 
 
 
 
 
140
  } elseif ($bCheckCategory == true) {
141
+ $bIsActive = $this->oB2BCategoryHelper->isCategoryActive() && !$bIsLoggedIn;
 
 
 
 
 
142
  } else {
143
+ $bIsActive = !$bIsLoggedIn;
 
 
 
 
144
  }
145
  } else {
146
  $bIsActive = false;
148
  return $bIsActive;
149
  }
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  /**
152
  * Validate that the current quote in the checkout session is valid for the user
153
  * - Check each item in the quote against the function checkActive
164
  /*
165
  * For each item check if it is active for the current user
166
  */
167
+ if ($this->isProductActive($iProductId)) {
168
  $bValidCart = false;
169
  }
170
  }
171
  return $bValidCart;
172
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  }
app/code/community/Sitewards/B2BProfessional/Helper/Messages.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_B2BProfessional_Helper_Messages
4
+ * - contains each message type constant
5
+ * - checkout = 0
6
+ * - price = 1
7
+ * - login = 2
8
+ * - contains an array with all messages
9
+ * - configuration path to override message
10
+ * - default message
11
+ * - function that takes in message type and returns the valid message
12
+ *
13
+ * @category Sitewards
14
+ * @package Sitewards_B2BProfessional
15
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
16
+ */
17
+ class Sitewards_B2BProfessional_Helper_Messages extends Mage_Core_Helper_Abstract {
18
+ /**
19
+ * Array id for the checkout message
20
+ */
21
+ const MESSAGE_TYPE_CHECKOUT = 0;
22
+
23
+ /**
24
+ * Array id for the price message
25
+ */
26
+ const MESSAGE_TYPE_PRICE = 1;
27
+
28
+ /**
29
+ * Array id for the login message
30
+ */
31
+ const MESSAGE_TYPE_LOGIN = 2;
32
+
33
+ /**
34
+ * Array containing
35
+ * - all the message config paths
36
+ * - the default message for each type
37
+ *
38
+ * @var array
39
+ */
40
+ protected $aMessages = array(
41
+ self::MESSAGE_TYPE_CHECKOUT => array(
42
+ 'config' => 'errortext',
43
+ 'default' => 'Your account is not allowed to access this store.'
44
+ ),
45
+ self::MESSAGE_TYPE_PRICE => array(
46
+ 'config' => 'logintext',
47
+ 'default' => 'Please login'
48
+ ),
49
+ self::MESSAGE_TYPE_LOGIN => array(
50
+ 'config' => 'requireloginmessage',
51
+ 'default' => 'You do not have access to view this store.'
52
+ )
53
+ );
54
+
55
+ /**
56
+ * The getMessage function will for a given message type
57
+ * - check if the language override flag has been set via the admin config
58
+ * - if override is set it will load the message from the admin config
59
+ * - else it will load and translate the default message from the $_aMessages array
60
+ *
61
+ * @param int $iMessageType
62
+ * @return string
63
+ */
64
+ public function getMessage($iMessageType) {
65
+ if (Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_LANGUAGE_SETTINGS_NODE . '/languageoverride')) {
66
+ $sMessage = Mage::getStoreConfig(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . Sitewards_B2BProfessional_Helper_Core::CONFIG_LANGUAGE_SETTINGS_NODE . '/' . $this->aMessages[$iMessageType]['config']);
67
+ } else {
68
+ $sMessage = $this->__($this->aMessages[$iMessageType]['default']);
69
+ }
70
+ return $sMessage;
71
+ }
72
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Redirects.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_B2BProfessional_Helper_Redirects
4
+ * - contains each redirect type config path as constant
5
+ * - function that takes in a config path and returns a url
6
+ *
7
+ * @category Sitewards
8
+ * @package Sitewards_B2BProfessional
9
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
10
+ */
11
+ class Sitewards_B2BProfessional_Helper_Redirects extends Mage_Core_Helper_Abstract {
12
+ /**
13
+ * String containing the configuration path for the login redirect
14
+ */
15
+ const REDIRECT_TYPE_LOGIN = 'requirelogin/requireloginredirect';
16
+
17
+ /**
18
+ * String containing the configuration path for the add to cart redirect
19
+ */
20
+ const REDIRECT_TYPE_ADD_TO_CART = 'generalsettings/addtocartredirect';
21
+
22
+ /**
23
+ * The getRedirect function will for a given redirect configuration path
24
+ * - load the value for the given configuration path
25
+ * - return a formatted url based on this value
26
+ *
27
+ * @param string $sConfigPath
28
+ * @return string
29
+ */
30
+ public static function getRedirect($sConfigPath) {
31
+ $sConfigPath = Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . $sConfigPath;
32
+ $sRedirectPath = '/';
33
+ $sConfigVar = Mage::getStoreConfig($sConfigPath);
34
+ if (isset($sConfigVar)) {
35
+ $sRedirectPath = $sConfigVar;
36
+ }
37
+ return Mage::getUrl($sRedirectPath);
38
+ }
39
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Replacements.php ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_B2BProfessional_Helper_Replacements
4
+ * - contains the replacement pattern regular expression
5
+ * - function to get add to cart replacement string
6
+ * - function to check if product needs add to cart button replaced
7
+ * - functions to replace given sections
8
+ *
9
+ * @category Sitewards
10
+ * @package Sitewards_B2BProfessional
11
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
12
+ */
13
+ class Sitewards_B2BProfessional_Helper_Replacements extends Mage_Core_Helper_Abstract {
14
+ /**
15
+ * Regular expression for replacements
16
+ */
17
+ const PATTERN_BASE = '@<%1$s [^>]*?%2$s="[^"]*?%3$s[^"]*?"[^>]*?>.*?</%1$s>@siu';
18
+
19
+ /**
20
+ * Object for the main sitewards b2bprofessional helper
21
+ *
22
+ * @var Sitewards_B2BProfessional_Helper_Data
23
+ */
24
+ protected $oB2BHelper;
25
+
26
+ /**
27
+ * Create an instance of the main sitewards b2bprofessional helper
28
+ */
29
+ public function __construct() {
30
+ $this->oB2BHelper = Mage::helper('b2bprofessional');
31
+ }
32
+
33
+ /**
34
+ * Get the replacement text for the add to cart url
35
+ *
36
+ * @return string
37
+ */
38
+ public function getReplaceAddToCartUrl() {
39
+ return Mage::getStoreConfig(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/add_to_cart/value');
40
+ }
41
+
42
+ /**
43
+ * Check if the add to cart button should be replace
44
+ * - if so return the new url
45
+ * - else return the normal url
46
+ *
47
+ * @param int $iProductId
48
+ * @param string $sNormalAddToCartUrl
49
+ * @return string
50
+ */
51
+ public function replaceAddToCart($iProductId, $sNormalAddToCartUrl) {
52
+ if ($this->isAddToCartToBeReplaced($iProductId)) {
53
+ return $this->getReplaceAddToCartUrl();
54
+ } else {
55
+ return $sNormalAddToCartUrl;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Check to see if the add to cart button should be replaced
61
+ *
62
+ * @param int $iProductId
63
+ * @return bool
64
+ */
65
+ public function isAddToCartToBeReplaced($iProductId) {
66
+ return (bool) $this->oB2BHelper->isProductActive($iProductId) && $this->replaceSection('add_to_cart');
67
+ }
68
+
69
+ /**
70
+ * Build two arrays,
71
+ * - one for patterns
72
+ * - one for replacements,
73
+ * Using these two array call to replace the patterns when the cart is invalid
74
+ *
75
+ * @param array $aSections
76
+ * @param string $sHtml
77
+ * @return string
78
+ */
79
+ public function replaceSections($aSections, $sHtml) {
80
+ $aPatterns = array();
81
+ $aReplacements = array();
82
+ /*
83
+ * Foreach section to replace
84
+ * - add the pattern
85
+ * - add the replacement
86
+ */
87
+ $bReplaceOnInvalidCart = false;
88
+ foreach($aSections as $sReplaceSection) {
89
+ if($this->replaceSection($sReplaceSection)) {
90
+ $aPatterns[] = $this->getPattern($sReplaceSection);
91
+ $aReplacements[] = $this->getReplacement($sReplaceSection);
92
+ if($this->checkInvalidCart($sReplaceSection)) {
93
+ $bReplaceOnInvalidCart = true;
94
+ }
95
+ }
96
+ }
97
+ if($bReplaceOnInvalidCart == true) {
98
+ return $this->replaceOnInvalidCart($aPatterns, $aReplacements, $sHtml);
99
+ } else {
100
+ return $this->replaceOnIsActive($aPatterns, $aReplacements, $sHtml);
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Build two arrays,
106
+ * - one for patterns
107
+ * - one for replacements,
108
+ * Using these two array call to replace the patterns when the cart is invalid
109
+ *
110
+ * @param array $aSections
111
+ * @param string $sHtml
112
+ * @param int $iProductId
113
+ * @return string
114
+ */
115
+ public function replaceSectionsByProductId($aSections, $sHtml, $iProductId) {
116
+ $aPatterns = array();
117
+ $aReplacements = array();
118
+ /*
119
+ * Foreach section to replace
120
+ * - add the pattern
121
+ * - add the replacement
122
+ */
123
+ foreach($aSections as $sReplaceSection) {
124
+ if($this->replaceSection($sReplaceSection)) {
125
+ $aPatterns[] = $this->getPattern($sReplaceSection);
126
+ $aReplacements[] = $this->getReplacement($sReplaceSection);
127
+ }
128
+ }
129
+ return $this->replaceOnInvalidCartByProductId($aPatterns, $aReplacements, $sHtml, $iProductId);
130
+ }
131
+
132
+ /**
133
+ * Check if a given config section should be replaced
134
+ *
135
+ * @param string $sConfigSection
136
+ * @return bool
137
+ */
138
+ public function replaceSection($sConfigSection) {
139
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . $sConfigSection . '/replace');
140
+ }
141
+
142
+ /**
143
+ * From a given config section
144
+ * - Load all the config
145
+ * - remove unused sections
146
+ * - perform a sprintf on given config items
147
+ *
148
+ * @param string $sConfigSection
149
+ * @return string
150
+ */
151
+ private function getPattern($sConfigSection) {
152
+ // Load config array and unset unused information
153
+ $aSectionConfig = Mage::getStoreConfig(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . $sConfigSection);
154
+ unset($aSectionConfig['replace']);
155
+ unset($aSectionConfig['remove']);
156
+
157
+ // Replace the tag, id and value sections of the regular expression
158
+ return sprintf(self::PATTERN_BASE, $aSectionConfig['tag'], $aSectionConfig['id'], $aSectionConfig['value']);
159
+ }
160
+
161
+ /**
162
+ * Get replacement text for a given config section
163
+ *
164
+ * @param string $sConfigSection
165
+ * @return string
166
+ */
167
+ private function getReplacement($sConfigSection) {
168
+ // Check for the remove flag
169
+ if(!Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . $sConfigSection . '/remove')) {
170
+ // If the remove flag is not set then get the module's price message
171
+ /* @var $oB2BMessagesHelper Sitewards_B2BProfessional_Helper_Messages */
172
+ $oB2BMessagesHelper = Mage::helper('b2bprofessional/messages');
173
+ return $oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_PRICE);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Check if a given config section should check if the cart is valid
179
+ *
180
+ * @param string $sConfigSection
181
+ * @return bool
182
+ */
183
+ private function checkInvalidCart($sConfigSection) {
184
+ return Mage::getStoreConfigFlag(Sitewards_B2BProfessional_Helper_Core::CONFIG_B2B_PROFESSIONAL_NODE . '/' . $sConfigSection . '/check_cart');
185
+ }
186
+
187
+ /**
188
+ * When we have an invalid cart
189
+ * - Perform a preg_replace with a given set of patterns and replacements on a string
190
+ * - When product id is given check for valid product
191
+ * - When no product id is given then check to complete cart
192
+ *
193
+ * @param array $aPatterns
194
+ * @param array $aReplacements
195
+ * @param string $sBlockHtml
196
+ * @return string
197
+ */
198
+ private function replaceOnInvalidCart($aPatterns, $aReplacements, $sBlockHtml) {
199
+ /*
200
+ * If you have no product id provided and an invalid cart
201
+ *
202
+ * THEN
203
+ * Perform the preg_replace
204
+ */
205
+ if (
206
+ !$this->oB2BHelper->hasValidCart()
207
+ ) {
208
+ $sBlockHtml = $this->getNewBlockHtml($aPatterns, $aReplacements, $sBlockHtml);
209
+ }
210
+ return $sBlockHtml;
211
+ }
212
+
213
+ /**
214
+ * When we have an invalid user
215
+ * - Perform a preg_replace with a given set of patterns and replacements on a string
216
+ * - Use only global isActive
217
+ *
218
+ * @param array $aPatterns
219
+ * @param array $aReplacements
220
+ * @param string $sBlockHtml
221
+ * @return string
222
+ */
223
+ private function replaceOnIsActive($aPatterns, $aReplacements, $sBlockHtml) {
224
+ if (
225
+ $this->oB2BHelper->isActive()
226
+ ) {
227
+ $sBlockHtml = $this->getNewBlockHtml($aPatterns, $aReplacements, $sBlockHtml);
228
+ }
229
+ return $sBlockHtml;
230
+ }
231
+
232
+ /**
233
+ * When we have an invalid cart
234
+ * - Perform a preg_replace with a given set of patterns and replacements on a string
235
+ * - When product id is given check for valid product
236
+ * - When no product id is given then check to complete cart
237
+ *
238
+ * @param array $aPatterns
239
+ * @param array $aReplacements
240
+ * @param string $sBlockHtml
241
+ * @param int $iProductId
242
+ * @return string
243
+ */
244
+ private function replaceOnInvalidCartByProductId($aPatterns, $aReplacements, $sBlockHtml, $iProductId) {
245
+ /*
246
+ * If you have a product id provided and it is invalid
247
+ *
248
+ * THEN
249
+ * Perform the preg_replace
250
+ */
251
+ if (
252
+ $this->oB2BHelper->isProductActive($iProductId)
253
+ ) {
254
+ $sBlockHtml = $this->getNewBlockHtml($aPatterns, $aReplacements, $sBlockHtml);
255
+ }
256
+ return $sBlockHtml;
257
+ }
258
+
259
+ /**
260
+ * Perform a preg_replace with the pattern and replacements given
261
+ *
262
+ * @param array $aPatterns
263
+ * @param array $aReplacements
264
+ * @param string $sBlockHtml
265
+ * @return mixed
266
+ */
267
+ private function getNewBlockHtml($aPatterns, $aReplacements, $sBlockHtml) {
268
+ return preg_replace(
269
+ $aPatterns,
270
+ $aReplacements,
271
+ $sBlockHtml
272
+ );
273
+ }
274
+ }
app/code/community/Sitewards/B2BProfessional/Model/Customer.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @category Sitewards
7
  * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
  */
10
  class Sitewards_B2BProfessional_Model_Customer extends Mage_Customer_Model_Customer {
11
  const XML_PATH_DISTRIBUTOR_EMAIL_TEMPLATE = 'customer/create_account/email_distributor_template';
@@ -15,7 +15,7 @@ class Sitewards_B2BProfessional_Model_Customer extends Mage_Customer_Model_Custo
15
  * Authenticate customer,
16
  * - Check they have been confirmed,
17
  * - Validate password,
18
- * - If cusomter is not active,
19
  * - Throw correct exception or add system message,
20
  *
21
  * @param string $sLoginEmail
@@ -39,6 +39,8 @@ class Sitewards_B2BProfessional_Model_Customer extends Mage_Customer_Model_Custo
39
 
40
  if (!$this->getData('customer_activated')) {
41
  if (Mage::app()->getRequest()->getActionName() == 'createpost') {
 
 
42
  $oSession->addSuccess($oCustomerHelper->__('Please wait for your account to be activated'));
43
  } else {
44
  throw new Exception ($oCustomerHelper->__ ('This account is not activated.'), self::EXCEPTION_CUSTOMER_NOT_ACTIVATED );
5
  *
6
  * @category Sitewards
7
  * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
  */
10
  class Sitewards_B2BProfessional_Model_Customer extends Mage_Customer_Model_Customer {
11
  const XML_PATH_DISTRIBUTOR_EMAIL_TEMPLATE = 'customer/create_account/email_distributor_template';
15
  * Authenticate customer,
16
  * - Check they have been confirmed,
17
  * - Validate password,
18
+ * - If customer is not active,
19
  * - Throw correct exception or add system message,
20
  *
21
  * @param string $sLoginEmail
39
 
40
  if (!$this->getData('customer_activated')) {
41
  if (Mage::app()->getRequest()->getActionName() == 'createpost') {
42
+ /* @var $oSession Mage_Core_Model_Session */
43
+ $oSession = Mage::getSingleton('core/session');
44
  $oSession->addSuccess($oCustomerHelper->__('Please wait for your account to be activated'));
45
  } else {
46
  throw new Exception ($oCustomerHelper->__ ('This account is not activated.'), self::EXCEPTION_CUSTOMER_NOT_ACTIVATED );
app/code/community/Sitewards/B2BProfessional/Model/Observer.php CHANGED
@@ -25,15 +25,20 @@ class Sitewards_B2BProfessional_Model_Observer {
25
  public function onControllerActionPreDispatch(Varien_Event_Observer $oObserver) {
26
  /* @var $oHelper Sitewards_B2BProfessional_Helper_Data */
27
  $oHelper = Mage::helper('b2bprofessional');
28
- if($oHelper->checkGlobalActive() == true) {
29
  /* @var $oControllerAction Mage_Core_Controller_Front_Action */
30
  $oControllerAction = $oObserver->getData('controller_action');
31
 
 
 
 
 
 
32
  /*
33
  * Check to see if the system requires a login
34
  * And there is no logged in user
35
  */
36
- if($oHelper->checkRequireLogin() == true && !Mage::getSingleton('customer/session')->isLoggedIn()) {
37
  /*
38
  * Check to see if the controller is:
39
  * 1) Cms related for cms pages,
@@ -52,7 +57,7 @@ class Sitewards_B2BProfessional_Model_Observer {
52
  // Redirect to the homepage
53
  /* @var $oResponse Mage_Core_Controller_Response_Http */
54
  $oResponse = $oControllerAction->getResponse();
55
- $oResponse->setRedirect($oHelper->getRequireLoginRedirect());
56
 
57
  /*
58
  * Add message to the session
@@ -61,7 +66,7 @@ class Sitewards_B2BProfessional_Model_Observer {
61
  */
62
  /* @var $oSession Mage_Core_Model_Session */
63
  $oSession = Mage::getSingleton('core/session');
64
- $oSession->addNotice($oHelper->getRequireLoginMessage());
65
  session_write_close();
66
  }
67
  /*
@@ -78,7 +83,7 @@ class Sitewards_B2BProfessional_Model_Observer {
78
  // Stop the default action from being dispatched
79
  $oControllerAction->setFlag('', 'no-dispatch', true);
80
  //Set the appropriate error message to the user session
81
- Mage::getSingleton('customer/session')->addError($oHelper->getCheckoutMessage());
82
  //Redirect to the account login url
83
  Mage::app()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'))->sendHeaders();
84
  }
@@ -89,7 +94,7 @@ class Sitewards_B2BProfessional_Model_Observer {
89
  */
90
  } elseif($oControllerAction instanceof Mage_Checkout_CartController) {
91
  if (!$oHelper->hasValidCart()) {
92
- Mage::getSingleton('checkout/session')->addError($oHelper->getCheckoutMessage());
93
  }
94
  }
95
  }
@@ -109,23 +114,55 @@ class Sitewards_B2BProfessional_Model_Observer {
109
 
110
  /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
111
  $oB2BHelper = Mage::helper('b2bprofessional');
 
 
 
 
112
 
 
 
 
113
  if($oBlock instanceof Mage_Catalog_Block_Product_Price) {
114
  $oProduct = $oBlock->getProduct();
115
  $iCurrentProductId = $oProduct->getId();
116
 
117
- if ($oB2BHelper->checkActive($iCurrentProductId)) {
118
  // To stop duplicate information being displayed validate that we only do this once per product
119
  if ($iCurrentProductId != self::$_iLastProductId) {
120
  self::$_iLastProductId = $iCurrentProductId;
121
 
122
- $oTransport->setHtml($oB2BHelper->getPriceMessage());
123
  } else {
124
  $oTransport->setHtml('');
125
  }
126
  // Set can show price to false to stop tax being displayed via Symmetrics_TweaksGerman_Block_Tax
127
  $oProduct->setCanShowPrice(false);
128
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  } elseif(
130
  $oBlock instanceof Mage_Checkout_Block_Cart_Totals
131
  ||
@@ -140,6 +177,9 @@ class Sitewards_B2BProfessional_Model_Observer {
140
  if (!$oB2BHelper->hasValidCart()) {
141
  $oTransport->setHtml('');
142
  }
 
 
 
143
  } elseif (
144
  $oBlock instanceof Mage_Checkout_Block_Cart_Sidebar
145
  ) {
@@ -147,8 +187,11 @@ class Sitewards_B2BProfessional_Model_Observer {
147
  'cart_sidebar_totals',
148
  'cart_sidebar_actions'
149
  );
150
- $sOriginalHtml = $oB2BHelper->replaceSections($aSections, $oTransport->getHtml());
151
  $oTransport->setHtml($sOriginalHtml);
 
 
 
152
  } elseif (
153
  $oBlock instanceof Mage_Checkout_Block_Cart_Item_Renderer
154
  ) {
@@ -156,29 +199,67 @@ class Sitewards_B2BProfessional_Model_Observer {
156
  $aSections = array(
157
  'cart_item_price'
158
  );
159
- $sOriginalHtml = $oB2BHelper->replaceSections($aSections, $oTransport->getHtml(), $iProductId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  $oTransport->setHtml($sOriginalHtml);
161
  }
162
  }
163
 
164
  /**
165
  * On the event core_block_abstract_to_html_before
 
166
  * - Check for the block type Mage_Catalog_Block_Product_List_Toolbar
167
- * - Remove the price order when required
 
 
 
 
 
168
  *
169
  * @param Varien_Event_Observer $oObserver
170
  */
171
  public function onCoreBlockAbstractToHtmlBefore(Varien_Event_Observer $oObserver) {
172
  $oBlock = $oObserver->getData('block');
173
 
174
- if($oBlock instanceof Mage_Catalog_Block_Product_List_Toolbar) {
175
- /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
176
- $oB2BHelper = Mage::helper('b2bprofessional');
177
-
178
- if($oB2BHelper->checkActive()) {
179
  $oBlock->removeOrderFromAvailableOrders('price');
180
  }
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  /**
@@ -192,7 +273,7 @@ class Sitewards_B2BProfessional_Model_Observer {
192
  /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
193
  $oB2BHelper = Mage::helper('b2bprofessional');
194
 
195
- if ($oB2BHelper->checkActive($oProduct->getId())) {
196
  $oProduct->setConfigurablePrice(0);
197
  }
198
  }
@@ -212,7 +293,7 @@ class Sitewards_B2BProfessional_Model_Observer {
212
  /*
213
  * Get all possible category filters
214
  * Assign to value b2bprof_category_filters to be used in
215
- * Sitewards_B2BProfessional_Helper_Data->checkCategoryIsActive
216
  */
217
  /* @var $oCategoryFilter Mage_Catalog_Block_Layer_Filter_Category */
218
  $oCategoryFilter = $oBlock->getChild('category_filter');
@@ -225,7 +306,7 @@ class Sitewards_B2BProfessional_Model_Observer {
225
  }
226
  Mage::register('b2bprof_category_filters', $aCategoryOptions);
227
 
228
- if($oB2BHelper->checkActive()) {
229
  $aFilterableAttributes = $oBlock->getData('_filterable_attributes');
230
  $aNewFilterableAttributes = array();
231
  foreach ($aFilterableAttributes as $oFilterableAttribute) {
25
  public function onControllerActionPreDispatch(Varien_Event_Observer $oObserver) {
26
  /* @var $oHelper Sitewards_B2BProfessional_Helper_Data */
27
  $oHelper = Mage::helper('b2bprofessional');
28
+ if($oHelper->isExtensionActive() == true) {
29
  /* @var $oControllerAction Mage_Core_Controller_Front_Action */
30
  $oControllerAction = $oObserver->getData('controller_action');
31
 
32
+ /* @var $oB2BMessagesHelper Sitewards_B2BProfessional_Helper_Messages */
33
+ $oB2BMessagesHelper = Mage::helper('b2bprofessional/messages');
34
+ /* @var $oB2BCustomerHelper Sitewards_B2BProfessional_Helper_Customer */
35
+ $oB2BCustomerHelper = Mage::helper('b2bprofessional/customer');
36
+
37
  /*
38
  * Check to see if the system requires a login
39
  * And there is no logged in user
40
  */
41
+ if($oB2BCustomerHelper->isLoginRequired() == true && !Mage::getSingleton('customer/session')->isLoggedIn()) {
42
  /*
43
  * Check to see if the controller is:
44
  * 1) Cms related for cms pages,
57
  // Redirect to the homepage
58
  /* @var $oResponse Mage_Core_Controller_Response_Http */
59
  $oResponse = $oControllerAction->getResponse();
60
+ $oResponse->setRedirect(Sitewards_B2BProfessional_Helper_Redirects::getRedirect(Sitewards_B2BProfessional_Helper_Redirects::REDIRECT_TYPE_LOGIN));
61
 
62
  /*
63
  * Add message to the session
66
  */
67
  /* @var $oSession Mage_Core_Model_Session */
68
  $oSession = Mage::getSingleton('core/session');
69
+ $oSession->addNotice($oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_LOGIN));
70
  session_write_close();
71
  }
72
  /*
83
  // Stop the default action from being dispatched
84
  $oControllerAction->setFlag('', 'no-dispatch', true);
85
  //Set the appropriate error message to the user session
86
+ Mage::getSingleton('customer/session')->addError($oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_CHECKOUT));
87
  //Redirect to the account login url
88
  Mage::app()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'))->sendHeaders();
89
  }
94
  */
95
  } elseif($oControllerAction instanceof Mage_Checkout_CartController) {
96
  if (!$oHelper->hasValidCart()) {
97
+ Mage::getSingleton('checkout/session')->addError($oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_CHECKOUT));
98
  }
99
  }
100
  }
114
 
115
  /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
116
  $oB2BHelper = Mage::helper('b2bprofessional');
117
+ /* @var $oB2BMessagesHelper Sitewards_B2BProfessional_Helper_Messages */
118
+ $oB2BMessagesHelper = Mage::helper('b2bprofessional/messages');
119
+ /* @var $oB2BReplacementsHelper Sitewards_B2BProfessional_Helper_Replacements */
120
+ $oB2BReplacementsHelper = Mage::helper('b2bprofessional/replacements');
121
 
122
+ /*
123
+ * Check to see if we should remove the product price
124
+ */
125
  if($oBlock instanceof Mage_Catalog_Block_Product_Price) {
126
  $oProduct = $oBlock->getProduct();
127
  $iCurrentProductId = $oProduct->getId();
128
 
129
+ if ($oB2BHelper->isProductActive($iCurrentProductId)) {
130
  // To stop duplicate information being displayed validate that we only do this once per product
131
  if ($iCurrentProductId != self::$_iLastProductId) {
132
  self::$_iLastProductId = $iCurrentProductId;
133
 
134
+ $oTransport->setHtml($oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_PRICE));
135
  } else {
136
  $oTransport->setHtml('');
137
  }
138
  // Set can show price to false to stop tax being displayed via Symmetrics_TweaksGerman_Block_Tax
139
  $oProduct->setCanShowPrice(false);
140
  }
141
+ /*
142
+ * Check to see if we should remove the add to cart button on the product page
143
+ */
144
+ } elseif(
145
+ $oBlock instanceof Mage_Catalog_Block_Product_View
146
+ &&
147
+ $oBlock->getNameInLayout() == 'product.info.addtocart'
148
+ ) {
149
+ $iCurrentProductId = $oBlock->getProduct()->getId();
150
+ if ($oB2BReplacementsHelper->isAddToCartToBeReplaced($iCurrentProductId)) {
151
+ $oTransport->setHtml('');
152
+ }
153
+ /*
154
+ * Check to see if we should remove the add to cart button on the wishlist item
155
+ */
156
+ } elseif (
157
+ $oBlock instanceof Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Cart
158
+ ) {
159
+ $iCurrentProductId = $oBlock->getItem()->getProduct()->getId();
160
+ if ($oB2BReplacementsHelper->isAddToCartToBeReplaced($iCurrentProductId)) {
161
+ $oTransport->setHtml($oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_PRICE));
162
+ }
163
+ /*
164
+ * Check to see if we should remove totals and actions from the cart
165
+ */
166
  } elseif(
167
  $oBlock instanceof Mage_Checkout_Block_Cart_Totals
168
  ||
177
  if (!$oB2BHelper->hasValidCart()) {
178
  $oTransport->setHtml('');
179
  }
180
+ /*
181
+ * Check to see if we should replace totals and actions from the cart sidebar
182
+ */
183
  } elseif (
184
  $oBlock instanceof Mage_Checkout_Block_Cart_Sidebar
185
  ) {
187
  'cart_sidebar_totals',
188
  'cart_sidebar_actions'
189
  );
190
+ $sOriginalHtml = $oB2BReplacementsHelper->replaceSections($aSections, $oTransport->getHtml());
191
  $oTransport->setHtml($sOriginalHtml);
192
+ /*
193
+ * Check to see if we should replace item price from the cart
194
+ */
195
  } elseif (
196
  $oBlock instanceof Mage_Checkout_Block_Cart_Item_Renderer
197
  ) {
199
  $aSections = array(
200
  'cart_item_price'
201
  );
202
+ $sOriginalHtml = $oB2BReplacementsHelper->replaceSectionsByProductId($aSections, $oTransport->getHtml(), $iProductId);
203
+ $oTransport->setHtml($sOriginalHtml);
204
+ /*
205
+ * Check to see if we should replace the add to cart button on product blocks
206
+ */
207
+ } elseif (
208
+ $oBlock instanceof Mage_Catalog_Block_Product_Abstract
209
+ ||
210
+ $oBlock instanceof Mage_Catalog_Block_Product_Compare_Abstract
211
+ ) {
212
+ $aSections = array(
213
+ 'add_to_cart'
214
+ );
215
+ // Check for the block's product so we can filter on product id
216
+ $oCurrentProduct = $oBlock->getProduct();
217
+ if(!is_null($oCurrentProduct)) {
218
+ $iCurrentProductId = $oBlock->getProduct()->getId();
219
+ $sOriginalHtml = $oB2BReplacementsHelper->replaceSectionsByProductId($aSections, $oTransport->getHtml(), $iCurrentProductId);
220
+ } else {
221
+ $sOriginalHtml = $oB2BReplacementsHelper->replaceSections($aSections, $oTransport->getHtml());
222
+ }
223
  $oTransport->setHtml($sOriginalHtml);
224
  }
225
  }
226
 
227
  /**
228
  * On the event core_block_abstract_to_html_before
229
+ * - Check extension is active
230
  * - Check for the block type Mage_Catalog_Block_Product_List_Toolbar
231
+ * - Remove the price order
232
+ * - Check for the block type Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox
233
+ * - Check for the block type Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Multi
234
+ * - Check for the block type Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio
235
+ * - Check for the block type Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Select
236
+ * - Rewrite bundle options price templates
237
  *
238
  * @param Varien_Event_Observer $oObserver
239
  */
240
  public function onCoreBlockAbstractToHtmlBefore(Varien_Event_Observer $oObserver) {
241
  $oBlock = $oObserver->getData('block');
242
 
243
+ if (Mage::helper('b2bprofessional')->isActive()) {
244
+ if($oBlock instanceof Mage_Catalog_Block_Product_List_Toolbar) {
 
 
 
245
  $oBlock->removeOrderFromAvailableOrders('price');
246
  }
247
  }
248
+ /*
249
+ * Used isExtensionActive because isActive returns false
250
+ * for bundle product which is not under active category
251
+ */
252
+ if (Mage::helper('b2bprofessional')->isExtensionActive()) {
253
+ if ($oBlock instanceof Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox) {
254
+ $oBlock->setTemplate('sitewards/b2bprofessional/catalog/product/view/type/bundle/option/checkbox.phtml');
255
+ } else if ($oBlock instanceof Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Multi) {
256
+ $oBlock->setTemplate('sitewards/b2bprofessional/catalog/product/view/type/bundle/option/multi.phtml');
257
+ } else if ($oBlock instanceof Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio) {
258
+ $oBlock->setTemplate('sitewards/b2bprofessional/catalog/product/view/type/bundle/option/radio.phtml');
259
+ } else if ($oBlock instanceof Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Select) {
260
+ $oBlock->setTemplate('sitewards/b2bprofessional/catalog/product/view/type/bundle/option/select.phtml');
261
+ }
262
+ }
263
  }
264
 
265
  /**
273
  /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
274
  $oB2BHelper = Mage::helper('b2bprofessional');
275
 
276
+ if ($oB2BHelper->isProductActive($oProduct->getId())) {
277
  $oProduct->setConfigurablePrice(0);
278
  }
279
  }
293
  /*
294
  * Get all possible category filters
295
  * Assign to value b2bprof_category_filters to be used in
296
+ * Sitewards_B2BProfessional_Helper_Category->isCategoryActive
297
  */
298
  /* @var $oCategoryFilter Mage_Catalog_Block_Layer_Filter_Category */
299
  $oCategoryFilter = $oBlock->getChild('category_filter');
306
  }
307
  Mage::register('b2bprof_category_filters', $aCategoryOptions);
308
 
309
+ if($oB2BHelper->isActive()) {
310
  $aFilterableAttributes = $oBlock->getData('_filterable_attributes');
311
  $aNewFilterableAttributes = array();
312
  foreach ($aFilterableAttributes as $oFilterableAttribute) {
app/code/community/Sitewards/B2BProfessional/Model/System/Config/Source/Category.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_Model_System_Config_Source_Category
4
- * - Create an options array with the current system categories
5
- *
6
- * @category Sitewards
7
- * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
- */
10
- class Sitewards_B2BProfessional_Model_System_Config_Source_Category extends Mage_Adminhtml_Model_System_Config_Source_Category {
11
- /**
12
- * Populate an options array with the current system categories
13
- *
14
- * @param boolean $bAddEmpty
15
- * @return array
16
  */
17
- public function toOptionArray($bAddEmpty = true) {
18
  /* @var $oCategoryCollection Mage_Catalog_Model_Resource_Category_Collection */
19
  $oCategoryCollection = Mage::getResourceModel('catalog/category_collection');
20
  $oCategoryCollection->addAttributeToSelect('name')->load();
21
 
22
  $aCategoryOptions = array ();
23
  if ($bAddEmpty) {
24
- $aCategoryOptions [] = array (
25
- 'label' => Mage::helper('adminhtml')->__ ('-- Please select at least one category --'),
26
  'value' => ''
27
  );
28
  }
29
- foreach ($oCategoryCollection as $oCategory) {
30
  /* @var $oCategory Mage_Catalog_Model_Category */
31
  $aCategoryOptions [] = array (
32
  'label' => $oCategory->getName(),
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Model_System_Config_Source_Category
4
+ * - Create an options array with the current system categories
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ class Sitewards_B2BProfessional_Model_System_Config_Source_Category extends Mage_Adminhtml_Model_System_Config_Source_Category {
11
+ /**
12
+ * Populate an options array with the current system categories
13
+ *
14
+ * @param boolean $bAddEmpty
15
+ * @return array
16
  */
17
+ public function toOptionArray($bAddEmpty = true) {
18
  /* @var $oCategoryCollection Mage_Catalog_Model_Resource_Category_Collection */
19
  $oCategoryCollection = Mage::getResourceModel('catalog/category_collection');
20
  $oCategoryCollection->addAttributeToSelect('name')->load();
21
 
22
  $aCategoryOptions = array ();
23
  if ($bAddEmpty) {
24
+ $aCategoryOptions [] = array (
25
+ 'label' => Mage::helper('adminhtml')->__ ('-- Please select at least one category --'),
26
  'value' => ''
27
  );
28
  }
29
+ foreach ($oCategoryCollection as $oCategory) {
30
  /* @var $oCategory Mage_Catalog_Model_Category */
31
  $aCategoryOptions [] = array (
32
  'label' => $oCategory->getName(),
app/code/community/Sitewards/B2BProfessional/Model/System/Config/Source/Identifiers.php CHANGED
@@ -31,6 +31,10 @@ class Sitewards_B2BProfessional_Model_System_Config_Source_Identifiers {
31
  'value' => 'class',
32
  'label' => 'class'
33
  ),
 
 
 
 
34
  );
35
  }
36
  return $this->_aOptions;
31
  'value' => 'class',
32
  'label' => 'class'
33
  ),
34
+ array(
35
+ 'value' => 'onclick',
36
+ 'label' => 'onclick'
37
+ ),
38
  );
39
  }
40
  return $this->_aOptions;
app/code/community/Sitewards/B2BProfessional/controllers/CartController.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @category Sitewards
7
  * @package Sitewards_B2BProfessional
8
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
9
  */
10
  require_once 'Mage/Checkout/controllers/CartController.php';
11
  class Sitewards_B2BProfessional_CartController extends Mage_Checkout_CartController {
@@ -29,17 +29,20 @@ class Sitewards_B2BProfessional_CartController extends Mage_Checkout_CartControl
29
  if (!empty($aMultiProducts)) {
30
  foreach ($aMultiProducts as $iMultiProductId => $iMultiProductValue) {
31
  if ($iMultiProductValue > 0) {
32
- if ($oB2BHelper->checkActive($iMultiProductId)) {
33
  $bAllowed = false;
34
  }
35
  }
36
  }
37
  }
38
 
39
- if ((!empty($iProductId) && $oB2BHelper->checkActive($iProductId)) || ! $bAllowed) {
 
 
 
40
  $this->setFlag('', 'no-dispatch', true);
41
- Mage::getSingleton('customer/session')->addError($oB2BHelper->getCheckoutMessage());
42
- Mage::app()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'))->sendHeaders();
43
  }
44
  }
45
  }
5
  *
6
  * @category Sitewards
7
  * @package Sitewards_B2BProfessional
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
  */
10
  require_once 'Mage/Checkout/controllers/CartController.php';
11
  class Sitewards_B2BProfessional_CartController extends Mage_Checkout_CartController {
29
  if (!empty($aMultiProducts)) {
30
  foreach ($aMultiProducts as $iMultiProductId => $iMultiProductValue) {
31
  if ($iMultiProductValue > 0) {
32
+ if ($oB2BHelper->isProductActive($iMultiProductId)) {
33
  $bAllowed = false;
34
  }
35
  }
36
  }
37
  }
38
 
39
+ if ((!empty($iProductId) && $oB2BHelper->isProductActive($iProductId)) || ! $bAllowed) {
40
+ /* @var $oB2BMessagesHelper Sitewards_B2BProfessional_Helper_Messages */
41
+ $oB2BMessagesHelper = Mage::helper('b2bprofessional/messages');
42
+
43
  $this->setFlag('', 'no-dispatch', true);
44
+ Mage::getSingleton('customer/session')->addError($oB2BMessagesHelper->getMessage($oB2BMessagesHelper::MESSAGE_TYPE_CHECKOUT));
45
+ Mage::app()->getResponse()->setRedirect(Sitewards_B2BProfessional_Helper_Redirects::getRedirect(Sitewards_B2BProfessional_Helper_Redirects::REDIRECT_TYPE_ADD_TO_CART))->sendHeaders();
46
  }
47
  }
48
  }
app/code/community/Sitewards/B2BProfessional/etc/adminhtml.xml CHANGED
@@ -6,7 +6,7 @@
6
  *
7
  * @category Sitewards
8
  * @package Sitewards_B2BProfessional
9
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
10
  */
11
  -->
12
  <config>
6
  *
7
  * @category Sitewards
8
  * @package Sitewards_B2BProfessional
9
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
10
  */
11
  -->
12
  <config>
app/code/community/Sitewards/B2BProfessional/etc/config.xml CHANGED
@@ -12,34 +12,40 @@
12
  *
13
  * @category Sitewards
14
  * @package Sitewards_B2BProfessional
15
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
16
  */
17
  -->
18
  <config>
19
  <modules>
20
  <Sitewards_B2BProfessional>
21
- <version>2.1.3</version>
22
  </Sitewards_B2BProfessional>
23
  </modules>
24
  <global>
25
  <blocks>
26
- <bundle>
27
- <rewrite>
28
- <catalog_product_price>Sitewards_B2BProfessional_Block_Bundle_Catalog_Price</catalog_product_price>
29
- <catalog_product_view_type_bundle_option_checkbox>Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox>
30
- <catalog_product_view_type_bundle_option_multi>Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi>
31
- <catalog_product_view_type_bundle_option_radio>Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio>
32
- <catalog_product_view_type_bundle_option_select>Sitewards_B2BProfessional_Block_Bundle_Catalog_Product_View_Type_Bundle_Option_Select</catalog_product_view_type_bundle_option_select>
33
- </rewrite>
34
- </bundle>
35
  <b2bprofessional>
36
  <class>Sitewards_B2BProfessional_Block</class>
37
  </b2bprofessional>
 
 
 
 
 
 
 
38
  <checkout>
39
  <rewrite>
40
  <links>Sitewards_B2BProfessional_Block_Checkout_Links</links>
41
  </rewrite>
42
  </checkout>
 
 
 
 
 
 
 
 
43
  </blocks>
44
  <events>
45
  <controller_action_predispatch>
@@ -87,6 +93,11 @@
87
  <b2bprofessional>
88
  <class>Sitewards_B2BProfessional_Helper</class>
89
  </b2bprofessional>
 
 
 
 
 
90
  </helpers>
91
  <models>
92
  <b2bprofessional>
@@ -133,12 +144,18 @@
133
  </adminhtml>
134
  <default>
135
  <b2bprofessional>
 
 
 
136
  <languagesettings>
137
  <logintext>Please login</logintext>
138
  <errortext>Your account is not allowed to access this store.</errortext>
139
  <requireloginmessage>You do not have access to view this store.</requireloginmessage>
140
- <requireloginredirect>0</requireloginredirect>
141
  </languagesettings>
 
 
 
 
142
  <!--
143
  Each of the following sections is to do with replacing html when customer has limited access,
144
  They should contain:
@@ -147,6 +164,7 @@
147
  id: the type of identifier for this tag (id, class, href)
148
  value: what to look for in the identifier
149
  remove: if the section is removed or replaced by text
 
150
  -->
151
  <cart_sidebar_totals>
152
  <replace>1</replace>
@@ -154,6 +172,7 @@
154
  <id>class</id>
155
  <value>subtotal</value>
156
  <remove />
 
157
  </cart_sidebar_totals>
158
  <cart_sidebar_actions>
159
  <replace>1</replace>
@@ -161,6 +180,7 @@
161
  <id>class</id>
162
  <value>actions</value>
163
  <remove>1</remove>
 
164
  </cart_sidebar_actions>
165
  <cart_item_price>
166
  <replace>1</replace>
@@ -168,7 +188,16 @@
168
  <id>class</id>
169
  <value>price</value>
170
  <remove />
 
171
  </cart_item_price>
 
 
 
 
 
 
 
 
172
  </b2bprofessional>
173
  </default>
174
  </config>
12
  *
13
  * @category Sitewards
14
  * @package Sitewards_B2BProfessional
15
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
16
  */
17
  -->
18
  <config>
19
  <modules>
20
  <Sitewards_B2BProfessional>
21
+ <version>2.2.2</version>
22
  </Sitewards_B2BProfessional>
23
  </modules>
24
  <global>
25
  <blocks>
 
 
 
 
 
 
 
 
 
26
  <b2bprofessional>
27
  <class>Sitewards_B2BProfessional_Block</class>
28
  </b2bprofessional>
29
+ <catalog>
30
+ <rewrite>
31
+ <product_list>Sitewards_B2BProfessional_Block_Catalog_Product_List</product_list>
32
+ <product_new>Sitewards_B2BProfessional_Block_Catalog_Product_New</product_new>
33
+ <product_widget_new>Sitewards_B2BProfessional_Block_Catalog_Product_Widget_New</product_widget_new>
34
+ </rewrite>
35
+ </catalog>
36
  <checkout>
37
  <rewrite>
38
  <links>Sitewards_B2BProfessional_Block_Checkout_Links</links>
39
  </rewrite>
40
  </checkout>
41
+ <reports>
42
+ <rewrite>
43
+ <product_compared>Sitewards_B2BProfessional_Block_Reports_Product_Compared</product_compared>
44
+ <product_viewed>Sitewards_B2BProfessional_Block_Reports_Product_Viewed</product_viewed>
45
+ <product_widget_compared>Sitewards_B2BProfessional_Block_Reports_Product_Widget_Compared</product_widget_compared>
46
+ <product_widget_viewed>Sitewards_B2BProfessional_Block_Reports_Product_Widget_Viewed</product_widget_viewed>
47
+ </rewrite>
48
+ </reports>
49
  </blocks>
50
  <events>
51
  <controller_action_predispatch>
93
  <b2bprofessional>
94
  <class>Sitewards_B2BProfessional_Helper</class>
95
  </b2bprofessional>
96
+ <catalog>
97
+ <rewrite>
98
+ <product_compare>Sitewards_B2BProfessional_Helper_Catalog_Product_Compare</product_compare>
99
+ </rewrite>
100
+ </catalog>
101
  </helpers>
102
  <models>
103
  <b2bprofessional>
144
  </adminhtml>
145
  <default>
146
  <b2bprofessional>
147
+ <generalsettings>
148
+ <addtocartredirect>customer/account/login</addtocartredirect>
149
+ </generalsettings>
150
  <languagesettings>
151
  <logintext>Please login</logintext>
152
  <errortext>Your account is not allowed to access this store.</errortext>
153
  <requireloginmessage>You do not have access to view this store.</requireloginmessage>
 
154
  </languagesettings>
155
+ <requirelogin>
156
+ <requirelogin>0</requirelogin>
157
+ <requireloginredirect>customer/account/login</requireloginredirect>
158
+ </requirelogin>
159
  <!--
160
  Each of the following sections is to do with replacing html when customer has limited access,
161
  They should contain:
164
  id: the type of identifier for this tag (id, class, href)
165
  value: what to look for in the identifier
166
  remove: if the section is removed or replaced by text
167
+ check_cart: flag to check for invalid cart
168
  -->
169
  <cart_sidebar_totals>
170
  <replace>1</replace>
172
  <id>class</id>
173
  <value>subtotal</value>
174
  <remove />
175
+ <check_cart>1</check_cart>
176
  </cart_sidebar_totals>
177
  <cart_sidebar_actions>
178
  <replace>1</replace>
180
  <id>class</id>
181
  <value>actions</value>
182
  <remove>1</remove>
183
+ <check_cart>1</check_cart>
184
  </cart_sidebar_actions>
185
  <cart_item_price>
186
  <replace>1</replace>
188
  <id>class</id>
189
  <value>price</value>
190
  <remove />
191
+ <check_cart>1</check_cart>
192
  </cart_item_price>
193
+ <add_to_cart>
194
+ <replace>1</replace>
195
+ <tag>button</tag>
196
+ <id>onclick</id>
197
+ <value>remove-add-to-cart</value>
198
+ <remove>1</remove>
199
+ <check_cart />
200
+ </add_to_cart>
201
  </b2bprofessional>
202
  </default>
203
  </config>
app/code/community/Sitewards/B2BProfessional/etc/system.xml CHANGED
@@ -7,7 +7,7 @@
7
  *
8
  * @category Sitewards
9
  * @package Sitewards_B2BProfessional
10
- * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
11
  */
12
  -->
13
  <config>
@@ -55,6 +55,26 @@
55
  <show_in_store>1</show_in_store>
56
  <comment><![CDATA[Activate customers for all stores. Otherwise they will only see the prices in the store, they have registered for.]]></comment>
57
  </activecustomers>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  <requirelogin translate="label comment">
59
  <label>Require User Login</label>
60
  <frontend_type>select</frontend_type>
@@ -76,11 +96,11 @@
76
  <comment><![CDATA[Select which page to redirect a user to.]]></comment>
77
  </requireloginredirect>
78
  </fields>
79
- </generalsettings>
80
  <languagesettings translate="label comment">
81
  <label>Language settings</label>
82
  <frontend_type>text</frontend_type>
83
- <sort_order>2</sort_order>
84
  <show_in_default>1</show_in_default>
85
  <show_in_website>1</show_in_website>
86
  <show_in_store>1</show_in_store>
@@ -127,7 +147,7 @@
127
  <activatebycategorysettings translate="label comment">
128
  <label>Activate by category</label>
129
  <frontend_type>text</frontend_type>
130
- <sort_order>3</sort_order>
131
  <show_in_default>1</show_in_default>
132
  <show_in_website>1</show_in_website>
133
  <show_in_store>1</show_in_store>
@@ -157,7 +177,7 @@
157
  <activatebycustomersettings translate="label comment">
158
  <label>Activate by customer group</label>
159
  <frontend_type>text</frontend_type>
160
- <sort_order>4</sort_order>
161
  <show_in_default>1</show_in_default>
162
  <show_in_website>1</show_in_website>
163
  <show_in_store>1</show_in_store>
@@ -188,7 +208,7 @@
188
  <cart_sidebar_totals translate="label">
189
  <label>Cart Sidebar Totals</label>
190
  <frontend_type>text</frontend_type>
191
- <sort_order>5</sort_order>
192
  <show_in_default>1</show_in_default>
193
  <show_in_website>1</show_in_website>
194
  <show_in_store>1</show_in_store>
@@ -242,7 +262,7 @@
242
  <cart_sidebar_actions translate="label">
243
  <label>Cart Sidebar Actions</label>
244
  <frontend_type>text</frontend_type>
245
- <sort_order>6</sort_order>
246
  <show_in_default>1</show_in_default>
247
  <show_in_website>1</show_in_website>
248
  <show_in_store>1</show_in_store>
@@ -283,7 +303,7 @@
283
  <show_in_store>1</show_in_store>
284
  </value>
285
  <remove translate="label,comment">
286
- <label>Do you want to remove this section completely</label>
287
  <frontend_type>select</frontend_type>
288
  <source_model>adminhtml/system_config_source_yesno</source_model>
289
  <sort_order>5</sort_order>
@@ -296,7 +316,7 @@
296
  <cart_item_price translate="label">
297
  <label>Cart Items Price</label>
298
  <frontend_type>text</frontend_type>
299
- <sort_order>7</sort_order>
300
  <show_in_default>1</show_in_default>
301
  <show_in_website>1</show_in_website>
302
  <show_in_store>1</show_in_store>
@@ -337,7 +357,7 @@
337
  <show_in_store>1</show_in_store>
338
  </value>
339
  <remove translate="label,comment">
340
- <label>Do you want to remove this section completely</label>
341
  <frontend_type>select</frontend_type>
342
  <source_model>adminhtml/system_config_source_yesno</source_model>
343
  <sort_order>5</sort_order>
@@ -347,6 +367,60 @@
347
  </remove>
348
  </fields>
349
  </cart_item_price>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  </groups>
351
  </b2bprofessional>
352
  </sections>
7
  *
8
  * @category Sitewards
9
  * @package Sitewards_B2BProfessional
10
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
11
  */
12
  -->
13
  <config>
55
  <show_in_store>1</show_in_store>
56
  <comment><![CDATA[Activate customers for all stores. Otherwise they will only see the prices in the store, they have registered for.]]></comment>
57
  </activecustomers>
58
+ <addtocartredirect translate="label comment">
59
+ <label>On 'Add To Cart' Redirect User To Page</label>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>b2bprofessional/system_config_source_page</source_model>
62
+ <sort_order>3</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <comment><![CDATA[Select which page to redirect a user to when they try to add an invalid product to their cart.]]></comment>
67
+ </addtocartredirect>
68
+ </fields>
69
+ </generalsettings>
70
+ <requirelogin>
71
+ <label>Require User Login</label>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>2</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <fields>
78
  <requirelogin translate="label comment">
79
  <label>Require User Login</label>
80
  <frontend_type>select</frontend_type>
96
  <comment><![CDATA[Select which page to redirect a user to.]]></comment>
97
  </requireloginredirect>
98
  </fields>
99
+ </requirelogin>
100
  <languagesettings translate="label comment">
101
  <label>Language settings</label>
102
  <frontend_type>text</frontend_type>
103
+ <sort_order>3</sort_order>
104
  <show_in_default>1</show_in_default>
105
  <show_in_website>1</show_in_website>
106
  <show_in_store>1</show_in_store>
147
  <activatebycategorysettings translate="label comment">
148
  <label>Activate by category</label>
149
  <frontend_type>text</frontend_type>
150
+ <sort_order>4</sort_order>
151
  <show_in_default>1</show_in_default>
152
  <show_in_website>1</show_in_website>
153
  <show_in_store>1</show_in_store>
177
  <activatebycustomersettings translate="label comment">
178
  <label>Activate by customer group</label>
179
  <frontend_type>text</frontend_type>
180
+ <sort_order>5</sort_order>
181
  <show_in_default>1</show_in_default>
182
  <show_in_website>1</show_in_website>
183
  <show_in_store>1</show_in_store>
208
  <cart_sidebar_totals translate="label">
209
  <label>Cart Sidebar Totals</label>
210
  <frontend_type>text</frontend_type>
211
+ <sort_order>6</sort_order>
212
  <show_in_default>1</show_in_default>
213
  <show_in_website>1</show_in_website>
214
  <show_in_store>1</show_in_store>
262
  <cart_sidebar_actions translate="label">
263
  <label>Cart Sidebar Actions</label>
264
  <frontend_type>text</frontend_type>
265
+ <sort_order>7</sort_order>
266
  <show_in_default>1</show_in_default>
267
  <show_in_website>1</show_in_website>
268
  <show_in_store>1</show_in_store>
303
  <show_in_store>1</show_in_store>
304
  </value>
305
  <remove translate="label,comment">
306
+ <label>Do you want to remove this section completely?</label>
307
  <frontend_type>select</frontend_type>
308
  <source_model>adminhtml/system_config_source_yesno</source_model>
309
  <sort_order>5</sort_order>
316
  <cart_item_price translate="label">
317
  <label>Cart Items Price</label>
318
  <frontend_type>text</frontend_type>
319
+ <sort_order>8</sort_order>
320
  <show_in_default>1</show_in_default>
321
  <show_in_website>1</show_in_website>
322
  <show_in_store>1</show_in_store>
357
  <show_in_store>1</show_in_store>
358
  </value>
359
  <remove translate="label,comment">
360
+ <label>Do you want to remove this section completely?</label>
361
  <frontend_type>select</frontend_type>
362
  <source_model>adminhtml/system_config_source_yesno</source_model>
363
  <sort_order>5</sort_order>
367
  </remove>
368
  </fields>
369
  </cart_item_price>
370
+ <add_to_cart translate="label">
371
+ <label>Add to cart button</label>
372
+ <frontend_type>text</frontend_type>
373
+ <sort_order>8</sort_order>
374
+ <show_in_default>1</show_in_default>
375
+ <show_in_website>1</show_in_website>
376
+ <show_in_store>1</show_in_store>
377
+ <fields>
378
+ <replace translate="label,comment">
379
+ <label>Replace the add to cart button</label>
380
+ <frontend_type>select</frontend_type>
381
+ <source_model>adminhtml/system_config_source_yesno</source_model>
382
+ <sort_order>1</sort_order>
383
+ <show_in_default>1</show_in_default>
384
+ <show_in_website>1</show_in_website>
385
+ <show_in_store>1</show_in_store>
386
+ </replace>
387
+ <tag translate="label comment">
388
+ <label>What tag wraps the add to cart button?</label>
389
+ <frontend_type>select</frontend_type>
390
+ <source_model>b2bprofessional/system_config_source_tags</source_model>
391
+ <sort_order>2</sort_order>
392
+ <show_in_default>1</show_in_default>
393
+ <show_in_website>1</show_in_website>
394
+ <show_in_store>1</show_in_store>
395
+ </tag>
396
+ <id translate="label comment">
397
+ <label>What identifier does this tag have?</label>
398
+ <frontend_type>select</frontend_type>
399
+ <source_model>b2bprofessional/system_config_source_identifiers</source_model>
400
+ <sort_order>3</sort_order>
401
+ <show_in_default>1</show_in_default>
402
+ <show_in_website>1</show_in_website>
403
+ <show_in_store>1</show_in_store>
404
+ </id>
405
+ <value translate="label comment">
406
+ <label>What value does this identifier have?</label>
407
+ <frontend_type>text</frontend_type>
408
+ <sort_order>4</sort_order>
409
+ <show_in_default>1</show_in_default>
410
+ <show_in_website>1</show_in_website>
411
+ <show_in_store>1</show_in_store>
412
+ </value>
413
+ <remove translate="label,comment">
414
+ <label>Do you want to remove this section completely?</label>
415
+ <frontend_type>select</frontend_type>
416
+ <source_model>adminhtml/system_config_source_yesno</source_model>
417
+ <sort_order>5</sort_order>
418
+ <show_in_default>1</show_in_default>
419
+ <show_in_website>1</show_in_website>
420
+ <show_in_store>1</show_in_store>
421
+ </remove>
422
+ </fields>
423
+ </add_to_cart>
424
  </groups>
425
  </b2bprofessional>
426
  </sections>
app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/checkbox.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bundle product checkbox option price template
4
+ *
5
+ * @category Sitewards
6
+ * @package Sitewards_B2BProfessional
7
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
8
+ */
9
+ ?>
10
+
11
+ <?php /* @var $this Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox */ ?>
12
+ <?php $_option = $this->getOption() ?>
13
+ <?php $_selections = $_option->getSelections() ?>
14
+ <dt><label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php echo $this->htmlEscape($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<em>*</em>' ?></label></dt>
15
+ <dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
16
+ <div class="input-box">
17
+ <?php if (count($_selections) == 1 && $_option->getRequired()): ?>
18
+ <?php echo $this->getSelectionQtyTitlePrice($_selections[0]) ?>
19
+ <input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>"/>
20
+ <?php else:?>
21
+ <ul class="options-list">
22
+ <?php foreach($_selections as $_selection): ?>
23
+ <li><input onclick="bundle.changeSelection(this)" class="change-container-classname checkbox bundle-option-<?php echo $_option->getId() ?> <?php if ($_option->getRequired()) echo 'validate-one-required-by-name' ?>" id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>" type="checkbox" name="bundle_option[<?php echo $_option->getId() ?>][]"<?php if ($this->_isSelected($_selection)) echo ' checked="checked"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?> value="<?php echo $_selection->getSelectionId() ?>"/>
24
+ <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"><?php if (Mage::helper('b2bprofessional')->isProductActive($_selection->getId())): echo $_selection->getName(); else: echo $this->getSelectionQtyTitlePrice($_selection); endif;?></label></span>
25
+ <?php if($_option->getRequired()): ?>
26
+ <?php echo $this->setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?>
27
+ <?php endif; ?>
28
+ </li>
29
+ <?php endforeach; ?>
30
+ </ul>
31
+ <div id="bundle-option-<?php echo $_option->getId() ?>-container"></div>
32
+ <?php endif; ?>
33
+ </div>
34
+ </dd>
app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/multi.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bundle product multiselect option price template
4
+ *
5
+ * @category Sitewards
6
+ * @package Sitewards_B2BProfessional
7
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
8
+ */
9
+ ?>
10
+
11
+ <?php /* @var $this Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Multi */ ?>
12
+ <?php $_option = $this->getOption() ?>
13
+ <?php $_selections = $_option->getSelections() ?>
14
+ <dt><label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php echo $this->htmlEscape($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<em>*</em>' ?></label></dt>
15
+ <dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
16
+ <div class="input-box">
17
+ <?php if (count($_selections) == 1 && $_option->getRequired()): ?>
18
+ <?php echo $this->getSelectionQtyTitlePrice($_selections[0]) ?>
19
+ <input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>"/>
20
+ <?php else: ?>
21
+ <select onchange="bundle.changeSelection(this)" multiple="multiple" size="5" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>][]" class="bundle-option-<?php echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> bundle-option-select multiselect change-container-classname">
22
+ <?php if(!$_option->getRequired()): ?>
23
+ <option value=""><?php echo $this->__('None') ?></option>
24
+ <?php endif; ?>
25
+ <?php foreach ($_selections as $_selection): ?>
26
+ <option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php if (Mage::helper('b2bprofessional')->isProductActive($_selection->getId())): echo $_selection->getName(); else: echo $this->getSelectionQtyTitlePrice($_selection, false); endif;?></option>
27
+ <?php endforeach; ?>
28
+ </select>
29
+ <?php endif; ?>
30
+ </div>
31
+ </dd>
app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/radio.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bundle product radio option price template
4
+ *
5
+ * @category Sitewards
6
+ * @package Sitewards_B2BProfessional
7
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
8
+ */
9
+ ?>
10
+
11
+ <?php /* @var $this Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio */ ?>
12
+ <?php $_option = $this->getOption(); ?>
13
+ <?php $_selections = $_option->getSelections(); ?>
14
+ <?php $_default = $_option->getDefaultSelection(); ?>
15
+ <?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>
16
+
17
+ <dt>
18
+ <label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php echo $this->htmlEscape($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<em>*</em>' ?></label>
19
+ </dt>
20
+ <dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
21
+ <div class="input-box">
22
+ <?php if ($this->_showSingle()): ?>
23
+ <?php echo $this->getSelectionTitlePrice($_selections[0]) ?>
24
+ <input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>" />
25
+ <?php else:?>
26
+ <ul class="options-list">
27
+ <?php if (!$_option->getRequired()): ?>
28
+ <li><input type="radio" onclick="bundle.changeSelection(this)" class="radio" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]"<?php echo ($_default && $_default->isSalable())?'':' checked="checked" ' ?> value=""/>
29
+ <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>"><?php echo $this->__('None') ?></label></span>
30
+ </li>
31
+ <?php endif; ?>
32
+ <?php foreach ($_selections as $_selection): ?>
33
+ <li><input type="radio" onclick="bundle.changeSelection(this)" class="radio<?php echo $_option->getRequired()?' validate-one-required-by-name':'' ?> change-container-classname" id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]"<?php if ($this->_isSelected($_selection)) echo ' checked="checked"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>value="<?php echo $_selection->getSelectionId() ?>"/>
34
+ <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"><?php if (Mage::helper('b2bprofessional')->isProductActive($_selection->getId())): echo $_selection->getName(); else: echo $this->getSelectionTitlePrice($_selection); endif;?></label></span>
35
+ <?php if ($_option->getRequired()): ?>
36
+ <?php echo $this->setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?>
37
+ <?php endif; ?>
38
+ </li>
39
+ <?php endforeach; ?>
40
+ </ul>
41
+ <div id="bundle-option-<?php echo $_option->getId() ?>-container"></div>
42
+ <?php endif; ?>
43
+ </div>
44
+ <span class="qty-holder">
45
+ <label for="bundle-option-<?php echo $_option->getId() ?>-qty-input"><?php echo $this->__('Qty:') ?>&nbsp;</label><input onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>"/>
46
+ </span>
47
+ </dd>
app/design/frontend/base/default/template/sitewards/b2bprofessional/catalog/product/view/type/bundle/option/select.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bundle product select option price template
4
+ *
5
+ * @category Sitewards
6
+ * @package Sitewards_B2BProfessional
7
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
8
+ */
9
+ ?>
10
+
11
+ <?php /* @var $this Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Select */ ?>
12
+ <?php $_option = $this->getOption(); ?>
13
+ <?php $_selections = $_option->getSelections(); ?>
14
+ <?php $_default = $_option->getDefaultSelection(); ?>
15
+ <?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>
16
+
17
+ <dt>
18
+ <label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php echo $this->htmlEscape($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<em>*</em>' ?></label>
19
+ </dt>
20
+ <dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
21
+ <div class="input-box">
22
+ <?php if ($this->_showSingle()): ?>
23
+ <?php echo $this->getSelectionTitlePrice($_selections[0]) ?>
24
+ <input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>"/>
25
+ <?php else:?>
26
+ <select onchange="bundle.changeSelection(this)" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]" class="bundle-option-<?php echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> bundle-option-select change-container-classname">
27
+ <option value=""><?php echo $this->__('Choose a selection...') ?></option>
28
+ <?php foreach ($_selections as $_selection): ?>
29
+ <option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php if (Mage::helper('b2bprofessional')->isProductActive($_selection->getId())): echo $_selection->getName(); else: echo $this->getSelectionTitlePrice($_selection, false); endif;?></option>
30
+ <?php endforeach; ?>
31
+ </select>
32
+ <?php endif; ?>
33
+ </div>
34
+ <span class="qty-holder">
35
+ <label for="bundle-option-<?php echo $_option->getId() ?>-qty-input"><?php echo $this->__('Qty:') ?>&nbsp;</label><input onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>"/>
36
+ </span>
37
+ </dd>
app/locale/de_DE/Sitewards_B2BProfessional.csv CHANGED
@@ -39,4 +39,9 @@
39
  "What tag wraps the sidebar actions?","Welcher Tag umschließt die Aktionen des Sidebar-Warenkorbs?"
40
  "Cart Items Price","Preis der Produkte im Warenkorb"
41
  "Replace the cart item prices","Preis der Produkte im Warenkorb ersetzen"
42
- "What tag wraps the cart item prices?","Welcher Tag umschließt die Preise der Produkte im Warenkorb?"
 
 
 
 
 
39
  "What tag wraps the sidebar actions?","Welcher Tag umschließt die Aktionen des Sidebar-Warenkorbs?"
40
  "Cart Items Price","Preis der Produkte im Warenkorb"
41
  "Replace the cart item prices","Preis der Produkte im Warenkorb ersetzen"
42
+ "What tag wraps the cart item prices?","Welcher Tag umschließt die Preise der Produkte im Warenkorb?"
43
+ "Add to cart button","In den Warenkorb Button"
44
+ "Replace the add to cart button","Warenkorb Button ersetzen"
45
+ "What tag wraps the add to cart button?","Welcher Tag umschließt den Warenkorb Button?"
46
+ "On 'Add To Cart' Redirect User To Page","Seite, auf die Nutzer nach dem Hinzufügen eines Produkts zum Warenkorb weitergeleitet werden"
47
+ "Select which page to redirect a user to when they try to add an invalid product to their cart.","Wählen Sie eine Seite, zu der ein Nutzer weitergeleitet werden soll, wenn versucht wurde, ein ungültiges Produkt in den Warenkorb zu legen."
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sitewards_B2BProfessional</name>
4
- <version>2.1.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
@@ -20,11 +20,12 @@ Features of the B2BProfessional Extension:&#xD;
20
  &#xB7; Activation for specific product categories&#xD;
21
  &#xB7; Activation for specific customer groups&#xD;
22
  &#xB7; Optional require login to access store</description>
23
- <notes>Update the dependency with Netzarbeiter_CustomerActivation</notes>
 
24
  <authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
25
- <date>2013-04-26</date>
26
- <time>07:35:23</time>
27
- <contents><target name="magecommunity"><dir name="Sitewards"><dir name="B2BProfessional"><dir name="Block"><dir name="Bundle"><dir name="Catalog"><file name="Price.php" hash="cd4834ed53163f101e110d5d67f5ce20"/><dir name="Product"><dir name="View"><dir name="Type"><dir name="Bundle"><dir name="Option"><file name="Checkbox.php" hash="97e3e7ce97a873c0bf438dcbb9d63538"/><file name="Multi.php" hash="aade197dae894c11df15ded6b90c5fa6"/><file name="Radio.php" hash="6bae85356183c20b8f7327018f4939fe"/><file name="Select.php" hash="b90a778084796edf552d6c87e888404f"/></dir></dir></dir></dir></dir></dir></dir><dir name="Checkout"><file name="Links.php" hash="a490e593b528f8c052c5af1201e197d4"/></dir></dir><dir name="Helper"><file name="Data.php" hash="56afc1ad68b3be5c842ec5f193f9cc9f"/></dir><dir name="Model"><file name="Customer.php" hash="5b78023593622c28dc6ee1b02d89aa26"/><file name="Observer.php" hash="ed2440ff6eb6ee8f33214703f8ca2e21"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Category.php" hash="115526ef80ee1f799e0c68f81a45fc9f"/><file name="Identifiers.php" hash="ef44dbc149afe51204c2f72d9fdfcd2e"/><file name="Page.php" hash="042ef4e679e8e8c7b6a2c696119712b3"/><file name="Tags.php" hash="af72690991f6f91a5aecb5f5fd7f621a"/></dir></dir></dir></dir><dir name="controllers"><file name="CartController.php" hash="08fa77e79f8769027bd467b02cf73670"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4532de80b3439c3047ea70776b8420a5"/><file name="config.xml" hash="73d99df4902fc48a4f89942c9cb08a65"/><file name="system.xml" hash="3e4bf681a41610c860fc3e07ae27363f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_B2BProfessional.xml" hash="3eb7e7a0f796d39faf60cf3f30c40ff2"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Sitewards_B2BProfessional.csv" hash="9190bb3526e2c82b3ac4daed57df715a"/></dir><dir name="en_US"><file name="Sitewards_B2BProfessional.csv" hash="5b6a370b2c2790ff1cb3954b8180ff81"/></dir></target></contents>
28
  <compatible/>
29
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Netzarbeiter_CustomerActivation</name><channel>community</channel><min>0.3.0</min><max>0.4.4</max></package></required></dependencies>
30
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sitewards_B2BProfessional</name>
4
+ <version>2.2.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
20
  &#xB7; Activation for specific product categories&#xD;
21
  &#xB7; Activation for specific customer groups&#xD;
22
  &#xB7; Optional require login to access store</description>
23
+ <notes>Add documentation and fix a bug with PHP 5.2&#xD;
24
+ </notes>
25
  <authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
26
+ <date>2013-06-13</date>
27
+ <time>17:19:33</time>
28
+ <contents><target name="magecommunity"><dir name="Sitewards"><dir name="B2BProfessional"><dir name="Block"><dir name="Catalog"><dir name="Product"><file name="List.php" hash="4c8e213915c4c7c177b503916921a392"/><file name="New.php" hash="3da0bc1cb1bd562f1a41e2169f6da061"/><dir name="Widget"><file name="New.php" hash="f263ee41756685c78959082ff2a38b5a"/></dir></dir></dir><dir name="Checkout"><file name="Links.php" hash="f88d8e603f98a282b2d6f678f03d974d"/></dir><dir name="Reports"><dir name="Product"><file name="Compared.php" hash="abe90ddad8722f7f3b41eef2cf9d7411"/><file name="Viewed.php" hash="c89044322ca310b450e7e8b95c17de69"/><dir name="Widget"><file name="Compared.php" hash="427bd3640335044572ccb4a6966d1d31"/><file name="Viewed.php" hash="f943f7cff7e0858c23527bcdf82f4b19"/></dir></dir></dir></dir><dir name="Docs"><file name="Sitewards B2B Professional_Deutsch V4.pdf" hash="69c5aabb9eba3cb4d060206f68bfffa9"/><file name="Sitewards B2B Professional_ENG_V4.pdf" hash="ec57137d81856521207e5014dfad133d"/></dir><dir name="Helper"><dir name="Catalog"><dir name="Product"><file name="Compare.php" hash="29d7ee722666ceeed48ac0e43c937b1d"/></dir></dir><file name="Category.php" hash="c7ac2551cc37516ea44002b08021c27b"/><file name="Core.php" hash="8a9ed86d5aead09fad8a6c372904005d"/><file name="Customer.php" hash="6664c3fa3745cd1df1220bc4bff02d0a"/><file name="Data.php" hash="91d9e909fe1e5a4af3e8c6b2fef1e448"/><file name="Messages.php" hash="54ce3aae10919721bb3545988d6aa564"/><file name="Redirects.php" hash="5670879b38bc078e36fb32f739b3a1f5"/><file name="Replacements.php" hash="cb5b3162388618b1d8c512c5b83918a0"/></dir><dir name="Model"><file name="Customer.php" hash="ceb9778dfb4725c8cd087f2595b3ccff"/><file name="Observer.php" hash="ac18fa24b508234a8d4a9cb4ce23769b"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Category.php" hash="e9642d20bb0bc0f542b07ecdf8d021c5"/><file name="Identifiers.php" hash="018e168fb31fffa33b3889612e0336be"/><file name="Page.php" hash="042ef4e679e8e8c7b6a2c696119712b3"/><file name="Tags.php" hash="af72690991f6f91a5aecb5f5fd7f621a"/></dir></dir></dir></dir><dir name="controllers"><file name="CartController.php" hash="cdd3521bb44a4fa3d8dd12b34535a740"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1c7cde3689b2da69458c39c3508f7e1a"/><file name="config.xml" hash="387b508a1d852854fd70b519ea05eec6"/><file name="system.xml" hash="4fab54ee0344d8186a4f56081b714a9f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_B2BProfessional.xml" hash="3eb7e7a0f796d39faf60cf3f30c40ff2"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Sitewards_B2BProfessional.csv" hash="065dc3c6b906c8b2e4a974829ed6577a"/></dir><dir name="en_US"><file name="Sitewards_B2BProfessional.csv" hash="5b6a370b2c2790ff1cb3954b8180ff81"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="sitewards"><dir name="b2bprofessional"><dir name="catalog"><dir name="product"><dir name="view"><dir name="type"><dir name="bundle"><dir name="option"><file name="checkbox.phtml" hash="43233f86f7e8529e5bc997f448ca250a"/><file name="multi.phtml" hash="43797266868e249b34a228a4ad9797e7"/><file name="radio.phtml" hash="770363afcc009271d58a15f02ae4fdbe"/><file name="select.phtml" hash="47b3b35fe986ab31fdc8e239e8ec9bb1"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
29
  <compatible/>
30
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Netzarbeiter_CustomerActivation</name><channel>community</channel><min>0.3.0</min><max>0.4.6</max></package></required></dependencies>
31
  </package>