eyemaginesrobbins

magento-b2b-helper

Aug 7th, 2013
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * EYEMAGINE - The leading Magento Solution Partner
  4.  *
  5.  * B2B Customer Restrictions
  6.  *
  7.  * @author    EYEMAGINE <magento@eyemaginetech.com>
  8.  * @category  Eyemagine
  9.  * @package   Eyemagine_B2b
  10.  * @copyright Copyright (c) 2013 EYEMAGINE Technology, LLC (http://www.eyemaginetech.com)
  11.  * @license   http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
  12.  */
  13.  
  14. class Eyemagine_B2b_Helper_Data extends Mage_Core_Helper_Abstract
  15. {
  16.     const MODULE_CONFIG_SECTION = 'sales';
  17.     /**
  18.      * Checks if the module is enabled
  19.      *
  20.      * @return int
  21.      */
  22.     public function isEnabled()
  23.     {
  24.         return $this->_getConfig("enabled");
  25.     }
  26.     /**
  27.      * Retrieves the configured B2B customer groups
  28.      *
  29.      * @return array
  30.      */
  31.     public function getB2bCustomerGroupIds()
  32.     {
  33.         return explode(",", $this->_getConfig("b2b_customer_groups"));
  34.     }
  35.     /**
  36.      * Fetches the minimum total required for first order
  37.      *
  38.      * @return int
  39.      */
  40.     public function getSubtotalMin()
  41.     {
  42.         return $this->_getConfig("subtotal_min");
  43.     }
  44.     /**
  45.      * Fetches the minimum total required for subsequent orders
  46.      *
  47.      * @return int
  48.      */
  49.     public function getSubtotalMinSubsequent()
  50.     {
  51.         return $this->_getConfig("subtotal_min_subsequent");
  52.     }
  53.     /**
  54.      * Fetches the error message
  55.      *
  56.      * @return string
  57.      */
  58.     public function getErrorMessage()
  59.     {
  60.         return $this->_getConfig("error_message");
  61.     }
  62.     /**
  63.      * Config fetcher
  64.      *
  65.      * @param string $field
  66.      * @param string $group
  67.      *
  68.      * @return int|string
  69.      */
  70.     protected function _getConfig($field, $group = 'b2b')
  71.     {
  72.         return Mage::getStoreConfig(self::MODULE_CONFIG_SECTION . "/$group/$field");
  73.     }
  74. }
RAW Paste Data