Plugin ​
- Type
- Class
- Namespace
- craft\commerce
- Inherits
- craft\commerce\Plugin » craft\base\Plugin » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject
- Implements
- craft\base\PluginInterface, yii\base\Configurable
- Uses traits
- craft\base\PluginTrait, craft\commerce\plugin\Routes, craft\commerce\plugin\Services, craft\commerce\plugin\Variables
- Since
- 2.0
Public Properties ​
Property | Description |
---|---|
aliases | array – List of path aliases to be defined. |
basePath | string – The root directory of the module. |
behaviors | yii\base\Behavior – List of behaviors attached to this component. |
cart | craft\commerce\services\Carts – the cart service |
carts | craft\commerce\services\Carts – The cart service |
catalogPricing | craft\commerce\services\CatalogPricing – the catalog pricing rules service |
catalogPricingRules | craft\commerce\services\CatalogPricingRules – the catalog pricing rules service |
changelogUrl | string, null – The plugin’s changelog URL. |
components | array – The list of the component definitions or the loaded component instances (ID => definition or instance). |
controllerMap | array – Mapping from controller ID to controller configurations. |
controllerNamespace | string, null – The namespace that controller classes are in. |
controllerPath | string – The directory that contains the controller classes. |
coupons | craft\commerce\services\Coupons – The countries service |
cpNavItem | array – the control panel navigation menu |
currencies | craft\commerce\services\Currencies – the currencies service |
customers | craft\commerce\services\Customers – the customers service |
defaultRoute | string – The default route of this module. |
description | string, null – The plugin’s description |
developer | string, null – The plugin developer’s name |
developerEmail | string, null – The plugin developer’s support email |
developerUrl | string, null – The plugin developer’s website URL |
discounts | craft\commerce\services\Discounts – the discounts service |
documentationUrl | string, null – The plugin’s documentation URL |
donation | craft\commerce\elements\Donation – the address service |
downloadUrl | string, null – The plugin’s download URL |
edition | string – The active edition. |
emails | craft\commerce\services\Emails – the emails service |
formulas | craft\commerce\services\Formulas – The formulas service |
gateways | craft\commerce\services\Gateways – the gateways service |
handle | string – The plugin’s handle (alias of id) |
hasCpSection | boolean – Whether the plugin has its own section in the control panel |
hasCpSettings | boolean – Whether the plugin has a settings page in the control panel |
id | string – An ID that uniquely identifies this module among other modules which have the same parent. |
inventory | craft\commerce\services\Inventory – The inventory service |
inventoryLocations | craft\commerce\services\InventoryLocations – The inventory locations service |
isInstalled | boolean – Whether the plugin is currently installed. |
layout | string, boolean, null – The layout that should be applied for views within this module. |
layoutPath | string – The root directory of layout files. |
lineItemStatuses | craft\commerce\services\LineItemStatuses – The lineItems service |
lineItems | craft\commerce\services\LineItems – the line items service |
migrator | craft\db\MigrationManager – The plugin’s migration manager |
minCmsEdition | \craft\enums\CmsEdition – The minimum required Craft CMS edition. |
minVersionRequired | string – The minimum required version the plugin has to be so it can be updated. |
module | yii\base\Module, null – The parent module of this module. |
modules | array – The modules (indexed by their IDs). |
name | string, null – The plugin’s display name |
orderAdjustments | craft\commerce\services\OrderAdjustments – the order adjustments service |
orderHistories | craft\commerce\services\OrderHistories – the order histories service |
orderNotices | craft\commerce\services\OrderStatuses – the order notices service |
orderStatuses | craft\commerce\services\OrderStatuses – the orderStatuses service |
orders | craft\commerce\services\Orders – the orders service |
packageName | string, null – The plugin’s package name |
params | array – Custom module parameters (name => value). |
paymentCurrencies | craft\commerce\services\PaymentCurrencies – the paymentCurrencies service |
paymentSources | craft\commerce\services\PaymentSources – the payment sources service |
payments | craft\commerce\services\Payments – the payments service |
craft\commerce\services\Pdfs – the pdf service | |
pdfs | craft\commerce\services\Pdfs – The PDFs service |
plans | craft\commerce\services\Plans – the plans service |
productTypes | craft\commerce\services\ProductTypes – the product types service |
products | craft\commerce\services\Products – the products service |
purchasables | craft\commerce\services\Purchasables – the purchasables service |
sales | craft\commerce\services\Sales – the sales service |
schemaVersion | string – The plugin’s schema version number |
settings | craft\commerce\models\Settings |
settingsResponse | mixed – the settings page response |
shippingCategories | craft\commerce\services\ShippingCategories – the shipping categories service |
shippingMethods | craft\commerce\services\ShippingMethods – the shipping methods service |
shippingRuleCategories | craft\commerce\services\ShippingRuleCategories – the shipping rule categories service |
shippingRules | craft\commerce\services\ShippingRules – the shipping rules service |
shippingZones | craft\commerce\services\ShippingZones – the shipping zones service |
sourceLanguage | string – The language that the plugin’s messages were written in |
store | craft\commerce\services\Store – The store service |
storeSettings | craft\commerce\services\StoreSettings – The store service |
stores | craft\commerce\services\Stores – The stores service |
subscriptions | craft\commerce\services\Subscriptions – the subscriptions service |
t9nCategory | string, null – The translation category that this plugin’s translation messages should use. |
taxCategories | craft\commerce\services\TaxCategories – the taxCategories service |
taxRates | craft\commerce\services\TaxRates – the taxRates service |
taxZones | craft\commerce\services\TaxZones – the taxZones service |
taxes | craft\commerce\services\Taxes – The taxes service |
transactions | craft\commerce\services\Transactions – the transactions service |
transfers | craft\commerce\services\Transfers – The transfers service |
uniqueId | string – The unique ID of the module. |
variants | craft\commerce\services\Variants – the variants service |
vat | craft\commerce\services\Vat – The VAT service |
version | string – The version of this module. |
viewPath | string – The root directory of view files. |
webhooks | craft\commerce\services\Webhooks – The variants service |
cpNavItem
​
- Type
- array
- Default value
null
the control panel navigation menu
hasCpSection
​
- Type
- boolean
- Default value
true
Whether the plugin has its own section in the control panel
hasCpSettings
​
- Type
- boolean
- Default value
true
Whether the plugin has a settings page in the control panel
minCmsEdition
​
- Type
\craft\enums\CmsEdition
- Default value
\craft\enums\CmsEdition::Pro
The minimum required Craft CMS edition.
minVersionRequired
​
- Type
- string
- Default value
'3.4.11'
The minimum required version the plugin has to be so it can be updated.
schemaVersion
​
- Type
- string
- Default value
'5.2.7.1'
The plugin’s schema version number
settings
​
- Type
- craft\commerce\models\Settings
- Default value
null
settingsResponse
​
- Type
mixed
- Default value
null
the settings page response
Public Methods ​
Method | Description |
---|---|
__call() | Calls the named method which is not a class method. |
__clone() | This method is called after the object is created by cloning an existing one. |
__construct() | Constructor. |
__get() | Getter magic method. |
__isset() | Checks if a property value is null. |
__set() | Sets the value of a component property. |
__unset() | Sets a component property to be null. |
afterAction() | This method is invoked right after an action within this module is executed. |
afterSaveSettings() | Performs actions after the plugin’s settings are saved. |
attachBehavior() | Attaches a behavior to this component. |
attachBehaviors() | Attaches a list of behaviors to the component. |
beforeAction() | This method is invoked right before an action within this module is executed. |
beforeInstall() | Performs actions before the plugin is installed. |
beforeSaveSettings() | Performs actions before the plugin’s settings are saved. |
behaviors() | Returns a list of behaviors that this component should behave as. |
canGetProperty() | Returns a value indicating whether a property can be read. |
canSetProperty() | Returns a value indicating whether a property can be set. |
className() | Returns the fully qualified name of this class. |
clear() | Removes the component from the locator. |
config() | |
createController() | Creates a controller instance based on the given route. |
createControllerByID() | Creates a controller based on the given controller ID. |
detachBehavior() | Detaches a behavior from the component. |
detachBehaviors() | Detaches all behaviors from the component. |
editions() | Returns the editions for Craft Commerce |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. |
get() | Returns the component instance with the specified ID. |
getBasePath() | Returns the root directory of the module. |
getBehavior() | Returns the named behavior object. |
getBehaviors() | Returns all behaviors attached to this component. |
getCarts() | Returns the cart service |
getCatalogPricing() | Returns the catalog pricing service |
getCatalogPricingRules() | Returns the catalog pricing rules service |
getComponents() | Returns the list of the component definitions or the loaded component instances. |
getControllerPath() | Returns the directory that contains the controller classes according to controllerNamespace. |
getCoupons() | Returns the coupons service |
getCpNavItem() | Returns the control panel nav item definition for this plugin, if it has a section in the control panel. |
getCurrencies() | Returns the currencies service |
getCustomers() | Returns the customers service |
getDiscounts() | Returns the discounts service |
getDonation() | Returns the donation purchasable |
getEmails() | Returns the emails service |
getFormulas() | Returns the formulas service |
getGateways() | Returns the gateways service |
getHandle() | Returns the plugin’s handle (really just an alias of yii\base\Module::$id). |
getInstance() | Returns the currently requested instance of this module class. |
getInventory() | Returns the inventory service |
getInventoryLocations() | Returns the inventory locations service |
getLayoutPath() | Returns the directory that contains layout view files for this module. |
getLineItemStatuses() | Returns the lineItems statuses service |
getLineItems() | Returns the lineItems service |
getMigrator() | Returns the plugin’s migration manager |
getModule() | Retrieves the child module of the specified ID. |
getModules() | Returns the sub-modules in this module. |
getOrderAdjustments() | Returns the orderAdjustments service |
getOrderHistories() | Returns the orderHistories service |
getOrderNotices() | Returns the OrderNotices service |
getOrderStatuses() | Returns the OrderStatuses service |
getOrders() | Returns the orders service |
getPaymentCurrencies() | Returns the paymentCurrencies service |
getPaymentSources() | Returns the payment sources service |
getPayments() | Returns the payments service |
getPdfs() | Returns the PDFs service |
getPlans() | Returns the payment sources service |
getProductTypes() | Returns the productTypes service |
getProducts() | Returns the products service |
getPurchasables() | Returns the purchasables service |
getSales() | Returns the sales service |
getSettings() | |
getSettingsResponse() | Returns the settings page response. |
getShippingCategories() | Returns the shippingCategories service |
getShippingMethods() | Returns the shippingMethods service |
getShippingRuleCategories() | Returns the shippingRules service |
getShippingRules() | Returns the shippingRules service |
getShippingZones() | Returns the shippingZones service |
getStore() | Returns the stores service |
getStoreSettings() | Returns the store service |
getStores() | Returns the stores service |
getSubscriptions() | Returns the subscriptions service |
getTaxCategories() | Returns the taxCategories service |
getTaxRates() | Returns the taxRates service |
getTaxZones() | Returns the taxZones service |
getTaxes() | Returns the taxes service |
getTransactions() | Returns the transactions service |
getTransfers() | Returns the transfers service |
getUniqueId() | Returns an ID that uniquely identifies this module among all modules within the current application. |
getVariants() | Returns the variants service |
getVat() | Returns the VAT service |
getVersion() | Returns current module version. |
getViewPath() | Returns the directory that contains the view files for this module. |
getWebhooks() | Returns the webhooks service |
has() | Returns a value indicating whether the locator has the specified component definition or has instantiated the component. |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. |
hasMethod() | Returns a value indicating whether a method is defined. |
hasModule() | Checks whether the child module of the specified ID exists. |
hasProperty() | Returns a value indicating whether a property is defined for this component. |
init() | Initializes the module. |
install() | Installs the plugin. |
is() | Compares the active edition with the given edition. |
off() | Detaches an existing event handler from this component. |
on() | Attaches an event handler to an event. |
runAction() | Runs a controller action specified by a route. |
set() | Registers a component definition with this locator. |
setAliases() | Defines path aliases. |
setBasePath() | Sets the root directory of the module. |
setComponents() | Registers a set of component definitions in this locator. |
setControllerPath() | Sets the directory that contains the controller classes. |
setInstance() | Sets the currently requested instance of this module class. |
setLayoutPath() | Sets the directory that contains the layout files. |
setModule() | Adds a sub-module to this module. |
setModules() | Registers sub-modules in the current module. |
setSettings() | Sets the plugin settings |
setVersion() | Sets current module version. |
setViewPath() | Sets the directory that contains the view files. |
trigger() | Triggers an event. |
uninstall() | Uninstalls the plugin. |
beforeInstall()
​
Performs actions before the plugin is installed.
config()
​
editions()
​
Returns the editions for Craft Commerce
Returns ​
string[]
getCpNavItem()
​
Returns the control panel nav item definition for this plugin, if it has a section in the control panel.
The returned array should contain the following keys:
label
– The human-facing nav item labelurl
– The URL the nav item should link toid
– The HTMLid
attribute the nav item should have (optional)icon
– The path to an SVG file that should be used as the nav item icon (optional)fontIcon
– A character/ligature from Craft’s font icon set (optional)badgeCount
– A number that should be displayed beside the nav item when unselectedsubnav
– A sub-array of subnav items
The subnav array should be associative, with identifiable keys set to sub-arrays with the following keys:
label
– The human-facing subnav item labelurl
– The URL the subnav item should link to
For example:
return [
'label' => 'Commerce',
'url' => 'commerce',
'subnav' => [
'orders' => ['label' => 'Orders', 'url' => 'commerce/orders',
'discounts' => ['label' => 'Discounts', 'url' => 'commerce/discounts',
],
];
Control panel templates can specify which subnav item is selected by defining a selectedSubnavItem
variable.
{% set selectedSubnavItem = 'orders' %}
Returns ​
getSettings()
​
Returns ​
craft\commerce\models\Settings –
getSettingsResponse()
​
Returns the settings page response.
Returns ​
mixed
– The result that should be returned from craft\controllers\PluginsController::actionEditPluginSettings()
init()
​
Initializes the module.
This method is called after the module is created and initialized with property values given in configuration. The default implementation will initialize controllerNamespace if it is not set.
If you override this method, please make sure you call the parent implementation.
Protected Methods ​
Method | Description |
---|---|
afterInstall() | Performs actions after the plugin is installed. |
afterUninstall() | Performs actions after the plugin is uninstalled. |
beforeUninstall() | Performs actions before the plugin is uninstalled. |
cpNavIconPath() | Returns the path to the SVG icon that should be used in the plugin’s nav item in the control panel. |
createInstallMigration() | Instantiates and returns the plugin’s installation migration, if it has one. |
createSettingsModel() | Creates and returns the model used to store the plugin’s settings. |
defaultVersion() | Returns default module version. |
settingsHtml() | Returns the rendered settings HTML, which will be inserted into the content block on the settings page. |
createSettingsModel()
​
Creates and returns the model used to store the plugin’s settings.
Returns ​
Constants ​
Constant | Description |
---|---|
EDITION_ENTERPRISE | |
EDITION_PRO | |
EDITION_PRO_STORE_LIMIT |