N98_CustomerGroupCheckout - Version 1.1.0

Version Notes

Added PayPal support.

Download this release

Release Info

Developer netz98 new media GmbH
Extension N98_CustomerGroupCheckout
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.2 to 1.1.0

app/code/community/N98/CustomerGroupCheckout/Block/Adminhtml/System/Config/Form.php CHANGED
@@ -51,25 +51,65 @@ class N98_CustomerGroupCheckout_Block_Adminhtml_System_Config_Form
51
  * Check if we are in sales tab and sub-tab payment or shipping.
52
  * Then we create SimpleXMLElements for form init.
53
  */
54
- if ($sections->tab == 'sales' && in_array($sections->label, array('Payment Methods', 'Shipping Methods'))) {
 
 
 
55
  foreach ($sections->groups as $group) {
56
  foreach ($group as $subGroup) {
57
  if (isset($subGroup->fields)) {
58
- $customerGroup = $subGroup->fields->addChild('available_for_customer_groups');
59
- $customerGroup->addAttribute('translate', 'label');
60
- /* @var $customerGroup Mage_Core_Model_Config_Element */
61
- $customerGroup->addChild('label', 'Customer Group');
62
- $customerGroup->addChild('frontend_type', 'multiselect');
63
- $customerGroup->addChild('source_model', 'adminhtml/system_config_source_customer_group');
64
- $customerGroup->addChild('sort_order', 1000);
65
- $customerGroup->addChild('show_in_default', 1);
66
- $customerGroup->addChild('show_in_website', 1);
67
- $customerGroup->addChild('show_in_store', 1);
68
  }
69
  }
70
  }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  return $this;
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
51
  * Check if we are in sales tab and sub-tab payment or shipping.
52
  * Then we create SimpleXMLElements for form init.
53
  */
54
+ if ($sections->tab == 'sales' && in_array($sections->getName(), array('payment', 'carriers'))) {
55
+ //
56
+ // Standard payment and shipping sections
57
+ //
58
  foreach ($sections->groups as $group) {
59
  foreach ($group as $subGroup) {
60
  if (isset($subGroup->fields)) {
61
+ $this->_addFieldToConfigGroup($subGroup);
 
 
 
 
 
 
 
 
 
62
  }
63
  }
64
  }
65
+ } elseif ($sections->tab == 'sales' && $sections->getName() == 'paypal') {
66
+ ///
67
+ // PayPal
68
+ //
69
+ if (isset($sections->groups->express)) {
70
+ $this->_addFieldToConfigGroup($sections->groups->express);
71
+ }
72
+ if (isset($sections->groups->wps)) {
73
+ $this->_addFieldToConfigGroup($sections->groups->wps);
74
+ }
75
+ }/* elseif ($sections->tab == 'sales' && $sections->getName() == 'google') {
76
+ //
77
+ // Google checkout and shipping
78
+ //
79
+ if (isset($sections->groups->checkout)) {
80
+ $this->_addFieldToConfigGroup($sections->groups->checkout);
81
+ }
82
+ if (isset($sections->groups->checkout_shipping_merchant)) {
83
+ $this->_addFieldToConfigGroup($sections->groups->checkout_shipping_merchant);
84
+ }
85
+ if (isset($sections->groups->checkout_shipping_carrier)) {
86
+ $this->_addFieldToConfigGroup($sections->groups->checkout_shipping_carrier);
87
+ }
88
+ if (isset($sections->groups->checkout_shipping_flatrate)) {
89
+ $this->_addFieldToConfigGroup($sections->groups->checkout_shipping_flatrate);
90
+ }
91
+ if (isset($sections->groups->checkout_shipping_virtual)) {
92
+ $this->_addFieldToConfigGroup($sections->groups->checkout_shipping_virtual);
93
+ }
94
+ }*/
95
 
96
  return $this;
97
  }
98
+
99
+ /**
100
+ * @param $subGroup
101
+ */
102
+ protected function _addFieldToConfigGroup($subGroup)
103
+ {
104
+ $customerGroup = $subGroup->fields->addChild('available_for_customer_groups');
105
+ $customerGroup->addAttribute('translate', 'label');
106
+ /* @var $customerGroup Mage_Core_Model_Config_Element */
107
+ $customerGroup->addChild('label', 'Customer Group');
108
+ $customerGroup->addChild('frontend_type', 'multiselect');
109
+ $customerGroup->addChild('source_model', 'adminhtml/system_config_source_customer_group');
110
+ $customerGroup->addChild('sort_order', 1000);
111
+ $customerGroup->addChild('show_in_default', 1);
112
+ $customerGroup->addChild('show_in_website', 1);
113
+ $customerGroup->addChild('show_in_store', 1);
114
+ }
115
  }
app/code/community/N98/CustomerGroupCheckout/Model/Payment/Observer.php CHANGED
@@ -57,7 +57,15 @@ class N98_CustomerGroupCheckout_Model_Payment_Observer
57
  $customer = Mage::helper('customer')->getCustomer();
58
  /* @var $customer Mage_Customer_Model_Customer */
59
 
60
- $customerGroupConfig = $paymentMethodInstance->getConfigData(self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
 
 
 
 
 
 
 
 
61
  if (!empty($customerGroupConfig)) {
62
  $methodCustomerGroups = explode(',', $customerGroupConfig);
63
  if (count($methodCustomerGroups) > 0) {
57
  $customer = Mage::helper('customer')->getCustomer();
58
  /* @var $customer Mage_Customer_Model_Customer */
59
 
60
+ if ($paymentMethodInstance instanceof Mage_Paypal_Model_Standard) {
61
+ $customerGroupConfig = Mage::getStoreConfig('paypal/wps/' . self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
62
+ } elseif ($paymentMethodInstance instanceof Mage_Paypal_Model_Express) {
63
+ $customerGroupConfig = Mage::getStoreConfig('paypal/express/' . self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
64
+ } elseif ($paymentMethodInstance instanceof Mage_GoogleCheckout_Model_Payment) {
65
+ $customerGroupConfig = Mage::getStoreConfig('google/checkout/' . self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
66
+ } else {
67
+ $customerGroupConfig = $paymentMethodInstance->getConfigData(self::XML_CUSTOMER_GROUP_CONFIG_FIELD);
68
+ }
69
  if (!empty($customerGroupConfig)) {
70
  $methodCustomerGroups = explode(',', $customerGroupConfig);
71
  if (count($methodCustomerGroups) > 0) {
app/code/community/N98/CustomerGroupCheckout/Model/Shipping/Shipping.php CHANGED
@@ -46,7 +46,7 @@ class N98_CustomerGroupCheckout_Model_Shipping_Shipping
46
  /**
47
  * @param string $carrierCode
48
  * @param Varien_Object $request
49
- * @return Netz98_CustomerGroupCheckout_Model_Shipping_Shipping
50
  */
51
  public function collectCarrierRates($carrierCode, $request)
52
  {
46
  /**
47
  * @param string $carrierCode
48
  * @param Varien_Object $request
49
+ * @return N98_CustomerGroupCheckout_Model_Shipping_Shipping
50
  */
51
  public function collectCarrierRates($carrierCode, $request)
52
  {
app/code/community/N98/CustomerGroupCheckout/etc/config.xml CHANGED
@@ -1,15 +1,15 @@
1
  <?xml version="1.0"?>
2
  <!--
3
  /**
4
- * @category Netz98
5
- * @package Netz98_CustomerGroupCheckout
6
  */
7
  -->
8
  <config>
9
  <modules>
10
- <Netz98_CustomerGroupCheckout>
11
- <version>1.0.2</version>
12
- </Netz98_CustomerGroupCheckout>
13
  </modules>
14
  <global>
15
  <blocks>
1
  <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * @category N98
5
+ * @package N98_CustomerGroupCheckout
6
  */
7
  -->
8
  <config>
9
  <modules>
10
+ <N98_CustomerGroupCheckout>
11
+ <version>1.1.0</version>
12
+ </N98_CustomerGroupCheckout>
13
  </modules>
14
  <global>
15
  <blocks>
app/etc/modules/N98_CustomerGroupCheckout.xml CHANGED
@@ -12,8 +12,6 @@
12
  <codePool>community</codePool>
13
  <depends>
14
  <Mage_Adminhtml />
15
- <Mage_Sales />
16
- <Mage_Shipping />
17
  </depends>
18
  </N98_CustomerGroupCheckout>
19
  </modules>
12
  <codePool>community</codePool>
13
  <depends>
14
  <Mage_Adminhtml />
 
 
15
  </depends>
16
  </N98_CustomerGroupCheckout>
17
  </modules>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>N98_CustomerGroupCheckout</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.netz98.de/licenses/opensource.html">netz98 open source license</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Limit access to payments and shipping methods by customer groups.</summary>
10
- <description>Limit payments and shipping methods by customer groups.</description>
11
- <notes>Initial release.</notes>
12
- <authors><author><name>netz98 new media GmbH</name><user>netz98</user><email>magento@netz98.de</email></author></authors>
13
- <date>2011-08-05</date>
14
- <time>12:52:14</time>
15
- <contents><target name="magecommunity"><dir name="N98"><dir name="CustomerGroupCheckout"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Form.php" hash="f87f8c5acb66ccf2db8923cadb8afa4d"/></dir></dir></dir></dir><dir name="Model"><dir name="Payment"><file name="Observer.php" hash="05e0e0f82372bb6dd3c15f8b3544608a"/></dir><dir name="Shipping"><file name="Shipping.php" hash="46c1b8cf5c61f6ead461e2b2260acddb"/></dir></dir><dir name="etc"><file name="config.xml" hash="a9360004700e25b0632515eb2bfe925d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="N98_CustomerGroupCheckout.xml" hash="83c850d7c7fec7ae4a602f325fb9a411"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>N98_CustomerGroupCheckout</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Limit payment and shipping methods by customer groups.</summary>
10
+ <description>Limit payment and shipping methods by customer groups.</description>
11
+ <notes>Added PayPal support.</notes>
12
+ <authors><author><name>netz98 new media GmbH</name><user>netz98magento</user><email>magento@netz98.de</email></author></authors>
13
+ <date>2012-02-21</date>
14
+ <time>16:32:07</time>
15
+ <contents><target name="magecommunity"><dir name="N98"><dir name="CustomerGroupCheckout"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Form.php" hash="f76ae162889d6ee1f0555baa789ba5b5"/></dir></dir></dir></dir><dir name="Model"><dir name="Payment"><file name="Observer.php" hash="495c0b0d2576bd73be90b9749938e229"/></dir><dir name="Shipping"><file name="Shipping.php" hash="d9c7c780b9f6cef07253d4e22b243ae9"/></dir></dir><dir name="etc"><file name="config.xml" hash="f3ccdb06ed74cb01f94fdbbce29aa3d8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="N98_CustomerGroupCheckout.xml" hash="beb679c904ac77f41e42a80340fe9aae"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>