Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_SalesRule_Exception
  • Mage_SalesRule_Helper_Coupon
  • Mage_SalesRule_Helper_Data
  • Mage_SalesRule_Model_Coupon
  • Mage_SalesRule_Model_Coupon_Codegenerator
  • Mage_SalesRule_Model_Coupon_Massgenerator
  • Mage_SalesRule_Model_Mysql4_Coupon
  • Mage_SalesRule_Model_Mysql4_Coupon_Collection
  • Mage_SalesRule_Model_Mysql4_Coupon_Usage
  • Mage_SalesRule_Model_Mysql4_Report_Collection
  • Mage_SalesRule_Model_Mysql4_Report_Rule
  • Mage_SalesRule_Model_Mysql4_Report_Updatedat_Collection
  • Mage_SalesRule_Model_Mysql4_Rule
  • Mage_SalesRule_Model_Mysql4_Rule_Collection
  • Mage_SalesRule_Model_Mysql4_Rule_Customer
  • Mage_SalesRule_Model_Mysql4_Rule_Customer_Collection
  • Mage_SalesRule_Model_Mysql4_Rule_Product
  • Mage_SalesRule_Model_Mysql4_Rule_Product_Collection
  • Mage_SalesRule_Model_Observer
  • Mage_SalesRule_Model_Quote_Discount
  • Mage_SalesRule_Model_Quote_Freeshipping
  • Mage_SalesRule_Model_Quote_Nominal_Discount
  • Mage_SalesRule_Model_Resource_Coupon
  • Mage_SalesRule_Model_Resource_Coupon_Collection
  • Mage_SalesRule_Model_Resource_Coupon_Usage
  • Mage_SalesRule_Model_Resource_Report_Collection
  • Mage_SalesRule_Model_Resource_Report_Rule
  • Mage_SalesRule_Model_Resource_Report_Rule_Createdat
  • Mage_SalesRule_Model_Resource_Report_Rule_Updatedat
  • Mage_SalesRule_Model_Resource_Report_Updatedat_Collection
  • Mage_SalesRule_Model_Resource_Rule
  • Mage_SalesRule_Model_Resource_Rule_Collection
  • Mage_SalesRule_Model_Resource_Rule_Customer
  • Mage_SalesRule_Model_Resource_Rule_Customer_Collection
  • Mage_SalesRule_Model_Resource_Rule_Product
  • Mage_SalesRule_Model_Resource_Rule_Product_Collection
  • Mage_SalesRule_Model_Rule
  • Mage_SalesRule_Model_Rule_Action_Collection
  • Mage_SalesRule_Model_Rule_Action_Product
  • Mage_SalesRule_Model_Rule_Condition_Address
  • Mage_SalesRule_Model_Rule_Condition_Combine
  • Mage_SalesRule_Model_Rule_Condition_Product
  • Mage_SalesRule_Model_Rule_Condition_Product_Combine
  • Mage_SalesRule_Model_Rule_Condition_Product_Found
  • Mage_SalesRule_Model_Rule_Condition_Product_Subselect
  • Mage_SalesRule_Model_Rule_Customer
  • Mage_SalesRule_Model_Rule_Product
  • Mage_SalesRule_Model_System_Config_Source_Coupon_Format
  • Mage_SalesRule_Model_Validator

Interfaces

  • Mage_SalesRule_Model_Coupon_CodegeneratorInterface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_SalesRule
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Helper for coupon codes creating and managing
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_SalesRule
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_SalesRule_Helper_Coupon extends Mage_Core_Helper_Abstract
 35: {
 36:     /**
 37:      * Constants which defines all possible coupon codes formats
 38:      */
 39:     const COUPON_FORMAT_ALPHANUMERIC    = 'alphanum';
 40:     const COUPON_FORMAT_ALPHABETICAL    = 'alpha';
 41:     const COUPON_FORMAT_NUMERIC         = 'num';
 42: 
 43:     /**
 44:      * Defines type of Coupon
 45:      */
 46:     const COUPON_TYPE_SPECIFIC_AUTOGENERATED = 1;
 47: 
 48:     /**
 49:      * XML paths to coupon codes generation options
 50:      */
 51:     const XML_PATH_SALES_RULE_COUPON_LENGTH        = 'promo/auto_generated_coupon_codes/length';
 52:     const XML_PATH_SALES_RULE_COUPON_FORMAT        = 'promo/auto_generated_coupon_codes/format';
 53:     const XML_PATH_SALES_RULE_COUPON_PREFIX        = 'promo/auto_generated_coupon_codes/prefix';
 54:     const XML_PATH_SALES_RULE_COUPON_SUFFIX        = 'promo/auto_generated_coupon_codes/suffix';
 55:     const XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL = 'promo/auto_generated_coupon_codes/dash';
 56: 
 57:     /**
 58:      * Config path for character set and separator
 59:      */
 60:     const XML_CHARSET_NODE      = 'global/salesrule/coupon/charset/%s';
 61:     const XML_CHARSET_SEPARATOR = 'global/salesrule/coupon/separator';
 62: 
 63:     /**
 64:      * Get all possible coupon codes formats
 65:      *
 66:      * @return array
 67:      */
 68:     public function getFormatsList()
 69:     {
 70:         return array(
 71:             self::COUPON_FORMAT_ALPHANUMERIC => $this->__('Alphanumeric'),
 72:             self::COUPON_FORMAT_ALPHABETICAL => $this->__('Alphabetical'),
 73:             self::COUPON_FORMAT_NUMERIC      => $this->__('Numeric'),
 74:         );
 75:     }
 76: 
 77:     /**
 78:      * Get default coupon code length
 79:      *
 80:      * @return int
 81:      */
 82:     public function getDefaultLength()
 83:     {
 84:         return (int)Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_LENGTH);
 85:     }
 86: 
 87:     /**
 88:      * Get default coupon code format
 89:      *
 90:      * @return int
 91:      */
 92:     public function getDefaultFormat()
 93:     {
 94:         return Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_FORMAT);
 95:     }
 96: 
 97:     /**
 98:      * Get default coupon code prefix
 99:      *
100:      * @return string
101:      */
102:     public function getDefaultPrefix()
103:     {
104:         return Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_PREFIX);
105:     }
106: 
107:     /**
108:      * Get default coupon code suffix
109:      *
110:      * @return string
111:      */
112:     public function getDefaultSuffix()
113:     {
114:         return Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_SUFFIX);
115:     }
116: 
117:     /**
118:      * Get dashes occurrences frequency in coupon code
119:      *
120:      * @return int
121:      */
122:     public function getDefaultDashInterval()
123:     {
124:         return (int)Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL);
125:     }
126: 
127:     /**
128:      * Get Coupon's alphabet as array of chars
129:      *
130:      * @param string $format
131:      * @return array|bool
132:      */
133:     public function getCharset($format)
134:     {
135:         return str_split((string) Mage::app()->getConfig()->getNode(sprintf(self::XML_CHARSET_NODE, $format)));
136:     }
137: 
138:     /**
139:      * Retrieve Separator from config
140:      *
141:      * @return string
142:      */
143:     public function getCodeSeparator()
144:     {
145:         return (string) Mage::app()->getConfig()->getNode(Mage_SalesRule_Helper_Coupon::XML_CHARSET_SEPARATOR);
146:     }
147: }
148: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0