DiscountsController
- Type
- Class
- Namespace
- craft\commerce\controllers
- Inherits
- craft\commerce\controllers\DiscountsController » craft\commerce\controllers\BaseCpController » craft\commerce\controllers\BaseController » craft\web\Controller (opens new window) » yii\web\Controller (opens new window) » yii\base\Controller (opens new window) » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
- Implements
- yii\base\Configurable (opens new window), yii\base\ViewContextInterface (opens new window)
- Since
- 2.0
Class Discounts Controller
View source (opens new window)
# Public Properties
# Protected Properties
Property | Description |
---|---|
allowAnonymous (opens new window) | integer (opens new window), boolean (opens new window), integer (opens new window)[], string (opens new window)[] – Whether this controller’s actions can be accessed anonymously. |
# Public Methods
Method | Description |
---|---|
__call() (opens new window) | Calls the named method which is not a class method. |
__clone() (opens new window) | This method is called after the object is created by cloning an existing one. |
__construct() (opens new window) | |
__get() (opens new window) | Returns the value of a component property. |
__isset() (opens new window) | Checks if a property is set, i.e. defined and not null. |
__set() (opens new window) | Sets the value of a component property. |
__unset() (opens new window) | Sets a component property to be null. |
actionClearDiscountUses() | |
actionDelete() | |
actionEdit() | |
actionGenerateCoupons() | |
actionGetDiscountsByPurchasableId() | |
actionIndex() | |
actionReorder() | |
actionSave() | |
actionUpdateStatus() | |
actions() (opens new window) | Declares external actions for the controller. |
afterAction() (opens new window) | This method is invoked right after an action is executed. |
asCpScreen() (opens new window) | Sends a control panel screen response. |
asErrorJson() (opens new window) | Responds to the request with a JSON error message. |
asFailure() (opens new window) | Sends a failure response. |
asJson() (opens new window) | Send data formatted as JSON. |
asJsonP() (opens new window) | Sets the response format of the given data as JSONP. |
asModelFailure() (opens new window) | Sends a failure response for a model. |
asModelSuccess() (opens new window) | Sends a success response for a model. |
asRaw() (opens new window) | Sets the response format of the given data as RAW. |
asSuccess() (opens new window) | Sends a success response. |
asXml() (opens new window) | Send data formatted as XML. |
attachBehavior() (opens new window) | Attaches a behavior to this component. |
attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
beforeAction() (opens new window) | This method is invoked right before an action is executed. |
behaviors() (opens new window) | Returns a list of behaviors that this component should behave as. |
bindActionParams() (opens new window) | Binds the parameters to the action. |
canGetProperty() (opens new window) | Returns a value indicating whether a property can be read. |
canSetProperty() (opens new window) | Returns a value indicating whether a property can be set. |
className() (opens new window) | Returns the fully qualified name of this class. |
createAction() (opens new window) | Creates an action based on the given action ID. |
currentUser() (opens new window) | Returns the currently logged-in user. |
detachBehavior() (opens new window) | Detaches a behavior from the component. |
detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
ensureBehaviors() (opens new window) | Makes sure that the behaviors declared in behaviors() (opens new window) are attached to this component. |
findLayoutFile() (opens new window) | Finds the applicable layout file. |
getBehavior() (opens new window) | Returns the named behavior object. |
getBehaviors() (opens new window) | Returns all behaviors attached to this component. |
getModules() (opens new window) | Returns all ancestor modules of this controller. |
getRoute() (opens new window) | Returns the route of the current request. |
getUniqueId() (opens new window) | Returns the unique ID of the controller. |
getView() (opens new window) | Returns the view object that can be used to render views or view files |
getViewPath() (opens new window) | Returns the directory containing view files for this controller. |
goBack() (opens new window) | Redirects the browser to the last visited page. |
goHome() (opens new window) | Redirects the browser to the home page. |
hasEventHandlers() (opens new window) | Returns a value indicating whether there is any handler attached to the named event. |
hasMethod() (opens new window) | Returns a value indicating whether a method is defined. |
hasProperty() (opens new window) | Returns a value indicating whether a property is defined for this component. |
init() | Initializes the object. |
off() (opens new window) | Detaches an existing event handler from this component. |
on() (opens new window) | Attaches an event handler to an event. |
redirect() (opens new window) | Redirects the browser to the specified URL. |
redirectToPostedUrl() (opens new window) | Redirects to the URI specified in the POST. |
refresh() (opens new window) | Refreshes the current page. |
render() (opens new window) | Renders a view and applies layout if available. |
renderAjax() (opens new window) | Renders a view in response to an AJAX request. |
renderContent() (opens new window) | Renders a static string by applying a layout. |
renderFile() (opens new window) | Renders a view file. |
renderPartial() (opens new window) | Renders a view without applying layout. |
renderTemplate() (opens new window) | Sends a rendered template response. |
requireAcceptsJson() (opens new window) | Throws a 400 error if the request doesn't accept JSON. |
requireAdmin() (opens new window) | Throws a 403 error if the current user is not an admin. |
requireAuthorization() (opens new window) | Checks whether the current user can perform a given action, and ends the request with a 403 error if they don’t. |
requireCpRequest() (opens new window) | Throws a 400 error if the current request isn’t a control panel request. |
requireElevatedSession() (opens new window) | Requires that the user has an elevated session. |
requireGuest() (opens new window) | Redirects the user to the account template if they are logged in. |
requireLogin() (opens new window) | Redirects the user to the login template if they're not logged in. |
requirePermission() (opens new window) | Checks whether the current user has a given permission, and ends the request with a 403 error if they don’t. |
requirePostRequest() (opens new window) | Throws a 400 error if this isn’t a POST request |
requireSiteRequest() (opens new window) | Throws a 400 error if the current request isn’t a site request. |
requireToken() (opens new window) | Throws a 400 error if the current request doesn’t have a valid Craft token. |
run() (opens new window) | Runs a request specified in terms of a route. |
runAction() (opens new window) | Runs an action within this controller with the specified action ID and parameters. |
setFailFlash() (opens new window) | Sets an error flash message on the user session. |
setSuccessFlash() (opens new window) | Sets a success flash message on the user session. |
setView() (opens new window) | Sets the view object to be used by this controller. |
setViewPath() (opens new window) | Sets the directory that contains the view files. |
trigger() (opens new window) | Triggers an event. |
# actionClearDiscountUses()
- Since
- 3.0
View source (opens new window)
Throws
# actionDelete()
View source (opens new window)
Throws
# actionEdit()
View source (opens new window)
Arguments
$id
(integer (opens new window), null (opens new window))$discount
(craft\commerce\models\Discount, null (opens new window))
Throws
# actionGenerateCoupons()
- Since
- 4.0
View source (opens new window)
Returns
yii\web\Response (opens new window)
Throws
# actionGetDiscountsByPurchasableId()
View source (opens new window)
Throws
# actionIndex()
View source (opens new window)
Throws
# actionReorder()
View source (opens new window)
Throws
# actionSave()
View source (opens new window)
Throws
# actionUpdateStatus()
- Since
- 3.0
View source (opens new window)
Throws
- craft\errors\MissingComponentException (opens new window)
- yii\db\Exception (opens new window)
- yii\web\BadRequestHttpException (opens new window)
- yii\web\ForbiddenHttpException (opens new window)
# init()
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
View source (opens new window)
Throws
# Protected Methods
Method | Description |
---|---|
bindInjectedParams() (opens new window) | Fills parameters based on types and names in action method signature. |
defineBehaviors() (opens new window) | Returns the behaviors to attach to this class. |
getPostedRedirectUrl() (opens new window) | Gets the redirect param specified in the POST data. |
# Constants
Constant | Description |
---|---|
ALLOW_ANONYMOUS_LIVE | |
ALLOW_ANONYMOUS_NEVER | |
ALLOW_ANONYMOUS_OFFLINE | |
DISCOUNT_COUNTER_TYPE_CUSTOMER | |
DISCOUNT_COUNTER_TYPE_EMAIL | |
DISCOUNT_COUNTER_TYPE_TOTAL |