Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Coupon Class Reference
Inheritance diagram for Coupon:
AbstractHelper

Public Member Functions

 __construct (\Magento\Framework\App\Helper\Context $context, array $couponParameters)
 
 getFormatsList ()
 
 getDefaultLength ()
 
 getDefaultFormat ()
 
 getDefaultPrefix ()
 
 getDefaultSuffix ()
 
 getDefaultDashInterval ()
 
 getCharset ($format)
 
 getCodeSeparator ()
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Data Fields

const COUPON_FORMAT_ALPHANUMERIC = 'alphanum'
 
const COUPON_FORMAT_ALPHABETICAL = 'alpha'
 
const COUPON_FORMAT_NUMERIC = 'num'
 
const COUPON_TYPE_SPECIFIC_AUTOGENERATED = 1
 
const XML_PATH_SALES_RULE_COUPON_LENGTH = 'promo/auto_generated_coupon_codes/length'
 
const XML_PATH_SALES_RULE_COUPON_FORMAT = 'promo/auto_generated_coupon_codes/format'
 
const XML_PATH_SALES_RULE_COUPON_PREFIX = 'promo/auto_generated_coupon_codes/prefix'
 
const XML_PATH_SALES_RULE_COUPON_SUFFIX = 'promo/auto_generated_coupon_codes/suffix'
 
const XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL = 'promo/auto_generated_coupon_codes/dash'
 

Protected Attributes

 $_couponParameters
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Detailed Description

Helper for coupon codes creating and managing

@api

Since
100.0.2

Definition at line 15 of file Coupon.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Helper\Context  $context,
array  $couponParameters 
)
Parameters
\Magento\Framework\App\Helper\Context$context
array$couponParameters

Definition at line 53 of file Coupon.php.

56  {
57  $this->_couponParameters = $couponParameters;
58  parent::__construct($context);
59  }

Member Function Documentation

◆ getCharset()

getCharset (   $format)

Get Coupon's alphabet as array of chars

Parameters
string$format
Returns
array|bool

Definition at line 146 of file Coupon.php.

147  {
148  return str_split($this->_couponParameters['charset'][$format]);
149  }
$format
Definition: list.phtml:12

◆ getCodeSeparator()

getCodeSeparator ( )

Retrieve Separator

Returns
string

Definition at line 156 of file Coupon.php.

157  {
158  return $this->_couponParameters['separator'];
159  }

◆ getDefaultDashInterval()

getDefaultDashInterval ( )

Get dashes occurrences frequency in coupon code

Returns
int

Definition at line 132 of file Coupon.php.

133  {
134  return (int)$this->scopeConfig->getValue(
135  self::XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL,
136  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
137  );
138  }

◆ getDefaultFormat()

getDefaultFormat ( )

Get default coupon code format

Returns
int

Definition at line 93 of file Coupon.php.

94  {
95  return $this->scopeConfig->getValue(
96  self::XML_PATH_SALES_RULE_COUPON_FORMAT,
97  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
98  );
99  }

◆ getDefaultLength()

getDefaultLength ( )

Get default coupon code length

Returns
int

Definition at line 80 of file Coupon.php.

81  {
82  return (int)$this->scopeConfig->getValue(
83  self::XML_PATH_SALES_RULE_COUPON_LENGTH,
84  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
85  );
86  }

◆ getDefaultPrefix()

getDefaultPrefix ( )

Get default coupon code prefix

Returns
string

Definition at line 106 of file Coupon.php.

107  {
108  return $this->scopeConfig->getValue(
109  self::XML_PATH_SALES_RULE_COUPON_PREFIX,
110  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
111  );
112  }

◆ getDefaultSuffix()

getDefaultSuffix ( )

Get default coupon code suffix

Returns
string

Definition at line 119 of file Coupon.php.

120  {
121  return $this->scopeConfig->getValue(
122  self::XML_PATH_SALES_RULE_COUPON_SUFFIX,
123  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
124  );
125  }

◆ getFormatsList()

getFormatsList ( )

Get all possible coupon codes formats

Returns
array

Definition at line 66 of file Coupon.php.

67  {
68  return [
69  self::COUPON_FORMAT_ALPHANUMERIC => __('Alphanumeric'),
70  self::COUPON_FORMAT_ALPHABETICAL => __('Alphabetical'),
71  self::COUPON_FORMAT_NUMERIC => __('Numeric')
72  ];
73  }
__()
Definition: __.php:13

Field Documentation

◆ $_couponParameters

$_couponParameters
protected

Definition at line 47 of file Coupon.php.

◆ COUPON_FORMAT_ALPHABETICAL

const COUPON_FORMAT_ALPHABETICAL = 'alpha'

Definition at line 22 of file Coupon.php.

◆ COUPON_FORMAT_ALPHANUMERIC

const COUPON_FORMAT_ALPHANUMERIC = 'alphanum'

Constants which defines all possible coupon codes formats

Definition at line 20 of file Coupon.php.

◆ COUPON_FORMAT_NUMERIC

const COUPON_FORMAT_NUMERIC = 'num'

Definition at line 24 of file Coupon.php.

◆ COUPON_TYPE_SPECIFIC_AUTOGENERATED

const COUPON_TYPE_SPECIFIC_AUTOGENERATED = 1

Defines type of Coupon

Definition at line 29 of file Coupon.php.

◆ XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL

const XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL = 'promo/auto_generated_coupon_codes/dash'

Definition at line 42 of file Coupon.php.

◆ XML_PATH_SALES_RULE_COUPON_FORMAT

const XML_PATH_SALES_RULE_COUPON_FORMAT = 'promo/auto_generated_coupon_codes/format'

Definition at line 36 of file Coupon.php.

◆ XML_PATH_SALES_RULE_COUPON_LENGTH

const XML_PATH_SALES_RULE_COUPON_LENGTH = 'promo/auto_generated_coupon_codes/length'

XML paths to coupon codes generation options

Definition at line 34 of file Coupon.php.

◆ XML_PATH_SALES_RULE_COUPON_PREFIX

const XML_PATH_SALES_RULE_COUPON_PREFIX = 'promo/auto_generated_coupon_codes/prefix'

Definition at line 38 of file Coupon.php.

◆ XML_PATH_SALES_RULE_COUPON_SUFFIX

const XML_PATH_SALES_RULE_COUPON_SUFFIX = 'promo/auto_generated_coupon_codes/suffix'

Definition at line 40 of file Coupon.php.


The documentation for this class was generated from the following file: