Sitewards_B2BProfessional - Version 2.1.3

Version Notes

Add ability to configure the removal of cart information via the system config section.

Download this release

Release Info

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


Code changes from version 2.1.2 to 2.1.3

app/code/community/Sitewards/B2BProfessional/Block/Bundle/Catalog/Price.php CHANGED
@@ -26,20 +26,16 @@ class Sitewards_B2BProfessional_Block_Bundle_Catalog_Price extends Mage_Bundle_B
26
  $sPriceHtml = parent::_toHtml();
27
  $iCurrentProductId = $this->getProduct()->getId();
28
 
29
- if (Mage::helper('b2bprofessional')->checkActive($iCurrentProductId)) {
 
 
30
  if ($iCurrentProductId == self::$_iLastProductId) {
31
  return '';
32
  }
33
  self::$_iLastProductId = $iCurrentProductId;
34
 
35
- // text displayed instead of price
36
- if (Mage::getStoreConfig('b2bprofessional/languagesettings/languageoverride') == 1) {
37
- $sReplacementText = Mage::getStoreConfig('b2bprofessional/languagesettings/logintext');
38
- } else {
39
- $sReplacementText = $this->__('Please login');
40
- }
41
- return $sReplacementText;
42
  }
43
  return $sPriceHtml;
44
  }
45
- }
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/Checkout/Links.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Block_Checkout_Links
4
+ * - Override the addCheckoutLink to validate the current cart
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
+ /**
12
+ * Validate the user's cart
13
+ * - when inactive remove the link
14
+ * - when active continue to the parent function
15
+ *
16
+ * @return Mage_Checkout_Block_Links
17
+ */
18
+ public function addCheckoutLink() {
19
+ /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
20
+ $oB2BHelper = Mage::helper('b2bprofessional');
21
+
22
+ if (!$oB2BHelper->hasValidCart()) {
23
+ return $this;
24
+ } else {
25
+ return parent::addCheckoutLink();
26
+ }
27
+ }
28
+ }
app/code/community/Sitewards/B2BProfessional/Helper/Data.php CHANGED
@@ -8,12 +8,18 @@
8
  * - Check module global flag,
9
  * - Check that customer is logged in and active,
10
  * - Check that the product/customer is activated,
 
11
  *
12
  * @category Sitewards
13
  * @package Sitewards_B2BProfessional
14
  * @copyright Copyright (c) 2012 Sitewards GmbH (http://www.sitewards.com/)
15
  */
16
  class Sitewards_B2BProfessional_Helper_Data extends Mage_Core_Helper_Abstract {
 
 
 
 
 
17
  /**
18
  * Check to see if the website is set-up to require a user login to view pages
19
  *
@@ -292,4 +298,164 @@ class Sitewards_B2BProfessional_Helper_Data extends Mage_Core_Helper_Abstract {
292
  }
293
  return Mage::getUrl($sRedirectPath);
294
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  }
8
  * - Check module global flag,
9
  * - Check that customer is logged in and active,
10
  * - Check that the product/customer is activated,
11
+ * - Check that the current cart is valid,
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
  *
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
305
+ *
306
+ * @return bool
307
+ */
308
+ public function hasValidCart() {
309
+ $bValidCart = true;
310
+ /* @var $oQuote Mage_Sales_Model_Quote */
311
+ $oQuote = Mage::getSingleton('checkout/session')->getQuote();
312
+ foreach($oQuote->getAllItems() as $oItem) {
313
+ /* @var $oItem Mage_Sales_Model_Quote_Item */
314
+ $iProductId = $oItem->getProductId();
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
  }
app/code/community/Sitewards/B2BProfessional/Model/Observer.php CHANGED
@@ -26,13 +26,14 @@ class Sitewards_B2BProfessional_Model_Observer {
26
  /* @var $oHelper Sitewards_B2BProfessional_Helper_Data */
27
  $oHelper = Mage::helper('b2bprofessional');
28
  if($oHelper->checkGlobalActive() == true) {
 
 
 
29
  /*
30
  * Check to see if the system requires a login
31
  * And there is no logged in user
32
  */
33
  if($oHelper->checkRequireLogin() == true && !Mage::getSingleton('customer/session')->isLoggedIn()) {
34
- /* @var $oControllerAction Mage_Core_Controller_Front_Action */
35
- $oControllerAction = $oObserver->getData('controller_action');
36
  /*
37
  * Check to see if the controller is:
38
  * 1) Cms related for cms pages,
@@ -63,6 +64,33 @@ class Sitewards_B2BProfessional_Model_Observer {
63
  $oSession->addNotice($oHelper->getRequireLoginMessage());
64
  session_write_close();
65
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
  }
68
  }
@@ -79,32 +107,57 @@ class Sitewards_B2BProfessional_Model_Observer {
79
  $oBlock = $oObserver->getData('block');
80
  $oTransport = $oObserver->getData('transport');
81
 
 
 
 
82
  if($oBlock instanceof Mage_Catalog_Block_Product_Price) {
83
  $oProduct = $oBlock->getProduct();
84
  $iCurrentProductId = $oProduct->getId();
85
 
86
- /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
87
- $oB2BHelper = Mage::helper('b2bprofessional');
88
-
89
  if ($oB2BHelper->checkActive($iCurrentProductId)) {
90
  // To stop duplicate information being displayed validate that we only do this once per product
91
  if ($iCurrentProductId != self::$_iLastProductId) {
92
  self::$_iLastProductId = $iCurrentProductId;
93
 
94
- // text displayed instead of price
95
- if (Mage::getStoreConfig('b2bprofessional/languagesettings/languageoverride') == 1) {
96
- $sReplacementText = Mage::getStoreConfig('b2bprofessional/languagesettings/logintext');
97
- } else {
98
- $sReplacementText = $oB2BHelper->__('Please login');
99
- }
100
-
101
- $oTransport->setHtml($sReplacementText);
102
  } else {
103
  $oTransport->setHtml('');
104
  }
105
  // Set can show price to false to stop tax being displayed via Symmetrics_TweaksGerman_Block_Tax
106
  $oProduct->setCanShowPrice(false);
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  }
110
 
@@ -130,7 +183,7 @@ class Sitewards_B2BProfessional_Model_Observer {
130
 
131
  /**
132
  * On the event catalog_product_type_configurable_price
133
- * Set the COnfigurable price of a product to 0 to stop the changed price showing up in the drop down
134
  *
135
  * @param Varien_Event_Observer $oObserver
136
  */
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,
64
  $oSession->addNotice($oHelper->getRequireLoginMessage());
65
  session_write_close();
66
  }
67
+ /*
68
+ * On Multishipping or Onepage actions
69
+ * - validate that the cart is valid
70
+ * - if not redirect the user to the account section and display message
71
+ */
72
+ } elseif(
73
+ $oControllerAction instanceof Mage_Checkout_MultishippingController
74
+ ||
75
+ $oControllerAction instanceof Mage_Checkout_OnepageController
76
+ ) {
77
+ if (!$oHelper->hasValidCart()) {
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
+ }
85
+ /*
86
+ * On Cart action
87
+ * - validate that the cart is valid
88
+ * - add message to the checkout session
89
+ */
90
+ } elseif($oControllerAction instanceof Mage_Checkout_CartController) {
91
+ if (!$oHelper->hasValidCart()) {
92
+ Mage::getSingleton('checkout/session')->addError($oHelper->getCheckoutMessage());
93
+ }
94
  }
95
  }
96
  }
107
  $oBlock = $oObserver->getData('block');
108
  $oTransport = $oObserver->getData('transport');
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
+ ||
132
+ $oBlock instanceof Mage_Checkout_Block_Onepage_Link
133
+ ||
134
+ $oBlock instanceof Mage_Checkout_Block_Multishipping_Link
135
+ ) {
136
+ /*
137
+ * If the current cart is not valid
138
+ * - remove the block html
139
+ */
140
+ if (!$oB2BHelper->hasValidCart()) {
141
+ $oTransport->setHtml('');
142
+ }
143
+ } elseif (
144
+ $oBlock instanceof Mage_Checkout_Block_Cart_Sidebar
145
+ ) {
146
+ $aSections = array(
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
+ ) {
155
+ $iProductId = $oBlock->getItem()->getProductId();
156
+ $aSections = array(
157
+ 'cart_item_price'
158
+ );
159
+ $sOriginalHtml = $oB2BHelper->replaceSections($aSections, $oTransport->getHtml(), $iProductId);
160
+ $oTransport->setHtml($sOriginalHtml);
161
  }
162
  }
163
 
183
 
184
  /**
185
  * On the event catalog_product_type_configurable_price
186
+ * Set the Configurable price of a product to 0 to stop the changed price showing up in the drop down
187
  *
188
  * @param Varien_Event_Observer $oObserver
189
  */
app/code/community/Sitewards/B2BProfessional/Model/System/Config/Source/Identifiers.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Model_System_Config_Source_Identifiers
4
+ * - Create an options array with the current identifiers allowed in the system config
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_Identifiers {
11
+ /**
12
+ * Options array for the source model
13
+ *
14
+ * @var array
15
+ */
16
+ protected $_aOptions;
17
+
18
+ /**
19
+ * Create an array with all the allowed identifiers
20
+ *
21
+ * @return array
22
+ */
23
+ public function toOptionArray() {
24
+ if (!$this->_aOptions) {
25
+ $this->_aOptions = array(
26
+ array(
27
+ 'value' => 'id',
28
+ 'label' => 'id'
29
+ ),
30
+ array(
31
+ 'value' => 'class',
32
+ 'label' => 'class'
33
+ ),
34
+ );
35
+ }
36
+ return $this->_aOptions;
37
+ }
38
+ }
app/code/community/Sitewards/B2BProfessional/Model/System/Config/Source/Tags.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_Model_System_Config_Source_Tags
4
+ * - Create an options array with the current tags allowed in the system config
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_Tags {
11
+ /**
12
+ * Options array for the source model
13
+ *
14
+ * @var array
15
+ */
16
+ protected $_aOptions;
17
+
18
+ /**
19
+ * Create an array with all the allowed tags
20
+ *
21
+ * @return array
22
+ */
23
+ public function toOptionArray() {
24
+ if (!$this->_aOptions) {
25
+ $this->_aOptions = array(
26
+ array(
27
+ 'value' => 'a',
28
+ 'label' => '<a>'
29
+ ),
30
+ array(
31
+ 'value' => 'div',
32
+ 'label' => '<div>'
33
+ ),
34
+ array(
35
+ 'value' => 'p',
36
+ 'label' => '<p>'
37
+ ),
38
+ array(
39
+ 'value' => 'span',
40
+ 'label' => '<span>'
41
+ ),
42
+ array(
43
+ 'value' => 'button',
44
+ 'label' => '<button>'
45
+ ),
46
+ );
47
+ }
48
+ return $this->_aOptions;
49
+ }
50
+ }
app/code/community/Sitewards/B2BProfessional/controllers/CartController.php CHANGED
@@ -1,26 +1,26 @@
1
- <?php
2
- /**
3
- * Sitewards_B2BProfessional_CartController
4
- * - Add product check on the preDispatch function
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 {
12
- /**
13
- * On checkout cart controller preDispatch
14
- * - validate that all products are active for customer/customer group,
15
- * - assign error message,
16
- * - redirect to customer login page,
17
  */
18
  public function preDispatch() {
19
  parent::preDispatch ();
20
 
21
  $oRequest = $this->getRequest();
22
- $iProductId = $oRequest->get('product');
23
- /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
24
  $oB2BHelper = Mage::helper('b2bprofessional');
25
 
26
  // check for grouped products
@@ -38,11 +38,7 @@ class Sitewards_B2BProfessional_CartController extends Mage_Checkout_CartControl
38
 
39
  if ((!empty($iProductId) && $oB2BHelper->checkActive($iProductId)) || ! $bAllowed) {
40
  $this->setFlag('', 'no-dispatch', true);
41
- if (Mage::getStoreConfig('b2bprofessional/languagesettings/languageoverride') == 1) {
42
- Mage::getSingleton('customer/session')->addError(Mage::getStoreConfig('b2bprofessional/languagesettings/errortext'));
43
- } else {
44
- Mage::getSingleton('customer/session')->addError($this->__('Your account is not allowed to access this store.'));
45
- }
46
  Mage::app()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'))->sendHeaders();
47
  }
48
  }
1
+ <?php
2
+ /**
3
+ * Sitewards_B2BProfessional_CartController
4
+ * - Add product check on the preDispatch function
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 {
12
+ /**
13
+ * On checkout cart controller preDispatch
14
+ * - validate that all products are active for customer/customer group,
15
+ * - assign error message,
16
+ * - redirect to customer login page,
17
  */
18
  public function preDispatch() {
19
  parent::preDispatch ();
20
 
21
  $oRequest = $this->getRequest();
22
+ $iProductId = $oRequest->get('product');
23
+ /* @var $oB2BHelper Sitewards_B2BProfessional_Helper_Data */
24
  $oB2BHelper = Mage::helper('b2bprofessional');
25
 
26
  // check for grouped products
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
  }
app/code/community/Sitewards/B2BProfessional/etc/config.xml CHANGED
@@ -18,7 +18,7 @@
18
  <config>
19
  <modules>
20
  <Sitewards_B2BProfessional>
21
- <version>2.1.2</version>
22
  </Sitewards_B2BProfessional>
23
  </modules>
24
  <global>
@@ -35,6 +35,11 @@
35
  <b2bprofessional>
36
  <class>Sitewards_B2BProfessional_Block</class>
37
  </b2bprofessional>
 
 
 
 
 
38
  </blocks>
39
  <events>
40
  <controller_action_predispatch>
@@ -134,6 +139,36 @@
134
  <requireloginmessage>You do not have access to view this store.</requireloginmessage>
135
  <requireloginredirect>0</requireloginredirect>
136
  </languagesettings>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  </b2bprofessional>
138
  </default>
139
  </config>
18
  <config>
19
  <modules>
20
  <Sitewards_B2BProfessional>
21
+ <version>2.1.3</version>
22
  </Sitewards_B2BProfessional>
23
  </modules>
24
  <global>
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>
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:
145
+ replace: flag for if the section will be replaced
146
+ tag: which html tag to look for <p> == p
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>
153
+ <tag>p</tag>
154
+ <id>class</id>
155
+ <value>subtotal</value>
156
+ <remove />
157
+ </cart_sidebar_totals>
158
+ <cart_sidebar_actions>
159
+ <replace>1</replace>
160
+ <tag>div</tag>
161
+ <id>class</id>
162
+ <value>actions</value>
163
+ <remove>1</remove>
164
+ </cart_sidebar_actions>
165
+ <cart_item_price>
166
+ <replace>1</replace>
167
+ <tag>span</tag>
168
+ <id>class</id>
169
+ <value>price</value>
170
+ <remove />
171
+ </cart_item_price>
172
  </b2bprofessional>
173
  </default>
174
  </config>
app/code/community/Sitewards/B2BProfessional/etc/system.xml CHANGED
@@ -185,6 +185,168 @@
185
  </activecustomers>
186
  </fields>
187
  </activatebycustomersettings>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  </groups>
189
  </b2bprofessional>
190
  </sections>
185
  </activecustomers>
186
  </fields>
187
  </activatebycustomersettings>
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>
195
+ <fields>
196
+ <replace translate="label,comment">
197
+ <label>Replace the sidebar totals</label>
198
+ <frontend_type>select</frontend_type>
199
+ <source_model>adminhtml/system_config_source_yesno</source_model>
200
+ <sort_order>1</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>1</show_in_store>
204
+ </replace>
205
+ <tag translate="label comment">
206
+ <label>What tag wraps the sidebar totals?</label>
207
+ <frontend_type>select</frontend_type>
208
+ <source_model>b2bprofessional/system_config_source_tags</source_model>
209
+ <sort_order>2</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>1</show_in_store>
213
+ </tag>
214
+ <id translate="label comment">
215
+ <label>What identifier does this tag have?</label>
216
+ <frontend_type>select</frontend_type>
217
+ <source_model>b2bprofessional/system_config_source_identifiers</source_model>
218
+ <sort_order>3</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>1</show_in_store>
222
+ </id>
223
+ <value translate="label comment">
224
+ <label>What value does this identifier have?</label>
225
+ <frontend_type>text</frontend_type>
226
+ <sort_order>4</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ </value>
231
+ <remove translate="label,comment">
232
+ <label>Do you want to remove this section completely?</label>
233
+ <frontend_type>select</frontend_type>
234
+ <source_model>adminhtml/system_config_source_yesno</source_model>
235
+ <sort_order>5</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </remove>
240
+ </fields>
241
+ </cart_sidebar_totals>
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>
249
+ <fields>
250
+ <replace translate="label,comment">
251
+ <label>Replace the sidebar actions section</label>
252
+ <frontend_type>select</frontend_type>
253
+ <source_model>adminhtml/system_config_source_yesno</source_model>
254
+ <sort_order>1</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>1</show_in_store>
258
+ </replace>
259
+ <tag translate="label comment">
260
+ <label>What tag wraps the sidebar actions?</label>
261
+ <frontend_type>select</frontend_type>
262
+ <source_model>b2bprofessional/system_config_source_tags</source_model>
263
+ <sort_order>2</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>1</show_in_store>
267
+ </tag>
268
+ <id translate="label comment">
269
+ <label>What identifier does this tag have?</label>
270
+ <frontend_type>select</frontend_type>
271
+ <source_model>b2bprofessional/system_config_source_identifiers</source_model>
272
+ <sort_order>3</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>1</show_in_store>
276
+ </id>
277
+ <value translate="label comment">
278
+ <label>What value does this identifier have?</label>
279
+ <frontend_type>text</frontend_type>
280
+ <sort_order>4</sort_order>
281
+ <show_in_default>1</show_in_default>
282
+ <show_in_website>1</show_in_website>
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>
290
+ <show_in_default>1</show_in_default>
291
+ <show_in_website>1</show_in_website>
292
+ <show_in_store>1</show_in_store>
293
+ </remove>
294
+ </fields>
295
+ </cart_sidebar_actions>
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>
303
+ <fields>
304
+ <replace translate="label,comment">
305
+ <label>Replace the cart item prices</label>
306
+ <frontend_type>select</frontend_type>
307
+ <source_model>adminhtml/system_config_source_yesno</source_model>
308
+ <sort_order>1</sort_order>
309
+ <show_in_default>1</show_in_default>
310
+ <show_in_website>1</show_in_website>
311
+ <show_in_store>1</show_in_store>
312
+ </replace>
313
+ <tag translate="label comment">
314
+ <label>What tag wraps the cart item prices?</label>
315
+ <frontend_type>select</frontend_type>
316
+ <source_model>b2bprofessional/system_config_source_tags</source_model>
317
+ <sort_order>2</sort_order>
318
+ <show_in_default>1</show_in_default>
319
+ <show_in_website>1</show_in_website>
320
+ <show_in_store>1</show_in_store>
321
+ </tag>
322
+ <id translate="label comment">
323
+ <label>What identifier does this tag have?</label>
324
+ <frontend_type>select</frontend_type>
325
+ <source_model>b2bprofessional/system_config_source_identifiers</source_model>
326
+ <sort_order>3</sort_order>
327
+ <show_in_default>1</show_in_default>
328
+ <show_in_website>1</show_in_website>
329
+ <show_in_store>1</show_in_store>
330
+ </id>
331
+ <value translate="label comment">
332
+ <label>What value does this identifier have?</label>
333
+ <frontend_type>text</frontend_type>
334
+ <sort_order>4</sort_order>
335
+ <show_in_default>1</show_in_default>
336
+ <show_in_website>1</show_in_website>
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>
344
+ <show_in_default>1</show_in_default>
345
+ <show_in_website>1</show_in_website>
346
+ <show_in_store>1</show_in_store>
347
+ </remove>
348
+ </fields>
349
+ </cart_item_price>
350
  </groups>
351
  </b2bprofessional>
352
  </sections>
app/locale/de_DE/Sitewards_B2BProfessional.csv CHANGED
@@ -27,4 +27,16 @@
27
  "Require User Login - Message","Nutzer muss sich einloggen - Nachricht"
28
  "Text to be displayed when the store requires a user to login to view pages<br />Only visible when language override is active.<br />Otherwise text in language file is used.<br />May contain HTML","Text der angezeigt wird, wenn der Nutzer sich einloggen muss, um eine bestimmte Seite im Shop zu betrachten.<br /> Wird nur verwendet, wenn die Sprache überschrieben wird.<br/>Ansonsten wird der Text aus der Sparchdatei benutzt.<br/> Dieser Text darf HTML beinhalten."
29
  "Redirect User To Page","Nutzer auf Seite weiterleiten"
30
- "Select which page to redirect a user to.","Wählen Sie die Seite, auf die der Nutzer weitergeleitet werden soll."
 
 
 
 
 
 
 
 
 
 
 
 
27
  "Require User Login - Message","Nutzer muss sich einloggen - Nachricht"
28
  "Text to be displayed when the store requires a user to login to view pages<br />Only visible when language override is active.<br />Otherwise text in language file is used.<br />May contain HTML","Text der angezeigt wird, wenn der Nutzer sich einloggen muss, um eine bestimmte Seite im Shop zu betrachten.<br /> Wird nur verwendet, wenn die Sprache überschrieben wird.<br/>Ansonsten wird der Text aus der Sparchdatei benutzt.<br/> Dieser Text darf HTML beinhalten."
29
  "Redirect User To Page","Nutzer auf Seite weiterleiten"
30
+ "Select which page to redirect a user to.","Wählen Sie die Seite, auf die der Nutzer weitergeleitet werden soll."
31
+ "Cart Sidebar Totals","Summen des Sidebar-Warenkorbs"
32
+ "Replace the sidebar totals","Summen des Sidebar-Warenkorbs ersetzen"
33
+ "What tag wraps the sidebar totals?","Welcher Tag umschließt die Summen des Sidebar-Warenkorbs?"
34
+ "What identifier does this tag have?","Welchen Identifier haben die umschließenden Tags?"
35
+ "What value does this identifier have?","Welchen Wert haben die Identifier?"
36
+ "Do you want to remove this section completely?","Wollen sie diesen Abschnitt komplett entfernen?"
37
+ "Cart Sidebar Actions","Aktionen des Sidebar-Warenkobs"
38
+ "Replace the sidebar actions section","Aktionen des Sidebar-Warenkobs ersetzen"
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?"
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sitewards_B2BProfessional</name>
4
- <version>2.1.2</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,11 @@ 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>Remove the price range from search pages when customer is not active.</notes>
24
  <authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
25
- <date>2013-03-22</date>
26
- <time>09:35:42</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="29947f4d2db1edb62d31ab2bb26d5612"/><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><dir name="Helper"><file name="Data.php" hash="248dd96fca4157eb7af8a25ff6f08478"/></dir><dir name="Model"><file name="Customer.php" hash="5b78023593622c28dc6ee1b02d89aa26"/><file name="Observer.php" hash="cb547c37164c243a179458ebd48b118a"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Category.php" hash="115526ef80ee1f799e0c68f81a45fc9f"/><file name="Page.php" hash="042ef4e679e8e8c7b6a2c696119712b3"/></dir></dir></dir></dir><dir name="controllers"><file name="CartController.php" hash="6dfb9530a9361dd2636ce5229369de3c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4532de80b3439c3047ea70776b8420a5"/><file name="config.xml" hash="13fe487a043b4559cb3da1d912862f2d"/><file name="system.xml" hash="61633ee9a60e9dd3158df36616804e5f"/></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="26108c182a96d9f4eb1df05f379105f7"/></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.1</max></package></required></dependencies>
30
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sitewards_B2BProfessional</name>
4
+ <version>2.1.3</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 ability to configure the removal of cart information via the system config section.</notes>
24
  <authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
25
+ <date>2013-04-19</date>
26
+ <time>12:58:46</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.1</max></package></required></dependencies>
30
  </package>