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\DeprecatedVariables, craft\commerce\plugin\Routes, craft\commerce\plugin\Services
Since
2.0

View source

Public Properties

PropertyDescription
$addressescraft\commerce\services\Addresses – The address service
$aliasesarray – List of path aliases to be defined.
$availableShippingMethodsarray
$basePathstring – The root directory of the module.
$behaviorsyii\base\Behavior – List of behaviors attached to this component
$cartcraft\commerce\elements\Order
$cartscraft\commerce\services\Carts – The cart service
$changelogUrlstring, null – The plugin’s changelog URL
$componentsarray – The list of the component definitions or the loaded component instances (ID => definition or instance).
$controllerMaparray – Mapping from controller ID to controller configurations.
$controllerNamespacestring – The namespace that controller classes are in.
$controllerPathstring – The directory that contains the controller classes.
$countriescraft\commerce\services\Countries – The countries service
$countriesListarray – [id => name]
$cpNavItemarray, null
$currenciescraft\commerce\services\Currencies – The currencies service
$customercraft\commerce\models\Customer
$customerscraft\commerce\services\Customers – The customers service
$defaultRoutestring – The default route of this module.
$descriptionstring, null – The plugin’s description
$developerstring, null – The plugin developer’s name
$developerEmailstring, null – The plugin developer’s support email
$developerUrlstring, null – The plugin developer’s website URL
$discountscraft\commerce\services\Discounts – The discounts service
$documentationUrlstring, null – The plugin’s documentation URL
$downloadUrlstring, null – The plugin’s download URL
$emailscraft\commerce\services\Emails – The emails service
$gatewayscraft\commerce\services\Gateways – The gateways service
$handlestring – The plugin’s handle
$hasCpSectionboolean – Whether the plugin has its own section in the CP
$hasCpSettingsboolean – Whether the plugin has a settings page in the CP
$idstring – An ID that uniquely identifies this module among other modules which have the same parent.
$isInstalledboolean – Whether the plugin is currently installed.
$layoutstring, boolean – The layout that should be applied for views within this module.
$layoutPathstring – The root directory of layout files.
$lineItemscraft\commerce\services\LineItems – The lineItems service
$migratorcraft\db\MigrationManager – The plugin’s migration manager
$minVersionRequiredstring – The minimum required version the plugin has to be so it can be updated.
$moduleyii\base\Module – The parent module of this module.
$modulesarray – The modules (indexed by their IDs).
$namestring, null – The plugin’s display name
$orderAdjustmentscraft\commerce\services\OrderAdjustments – The orderAdjustments service
$orderHistoriescraft\commerce\services\OrderHistories – The orderHistories service
$orderSettingscraft\commerce\services\OrderSettings – The orderSettings service
$orderStatusescraft\commerce\services\OrderStatuses – The orderStatuses service
$orderscraft\commerce\services\Orders – The orders service
$packageNamestring, null – The plugin’s package name
$paramsarray – Custom module parameters (name => value).
$paymentCurrenciescraft\commerce\services\PaymentCurrencies – The paymentCurrencies service
$paymentSourcescraft\commerce\services\PaymentSources – The payment sources service
$paymentscraft\commerce\services\Payments – The payments service
$pdfcraft\commerce\services\Pdf – The PDF service
$planscraft\commerce\services\Plans – The subscription plans service
$primaryPaymentCurrency\craft\commerce\plugin\PaymentCurrency, null
$productTypescraft\commerce\services\ProductTypes – The productTypes service
$productscraft\commerce\services\Products – The products service
$purchasablescraft\commerce\services\Purchasables – The purchasables service
$reportscraft\commerce\services\Reports – The reports service
$salescraft\commerce\services\Sales – The sales service
$schemaVersionstring, null – The plugin’s schema version number
$settingscraft\base\Model, null – The model that the plugin’s settings should be stored on, if the plugin has settings
$settingsResponsemixed – The result that should be returned from craft\controllers\PluginsController::actionEditPluginSettings()
$shippingCategoriescraft\commerce\services\ShippingCategories – The shippingCategories service
$shippingMethodscraft\commerce\services\ShippingMethods – The shippingMethods service
$shippingRuleCategoriescraft\commerce\services\ShippingRuleCategories – The shippingRuleCategories service
$shippingRulescraft\commerce\services\ShippingRules – The shippingRules service
$shippingZonescraft\commerce\services\ShippingZones – The shippingZones service
$sourceLanguagestring – The language that the plugin’s messages were written in
$statescraft\commerce\services\States – The states service
$statesArrayarray – [countryId => [id => name]]
$subscriptionscraft\commerce\services\Subscriptions – The subscriptions service
$t9nCategorystring, null – The translation category that this plugin’s translation messages should use.
$taxCategoriescraft\commerce\services\TaxCategories – The taxCategories service
$taxRatescraft\commerce\services\TaxRates – The taxRates service
$taxZonescraft\commerce\services\TaxZones – The taxZones service
$transactionscraft\commerce\services\Transactions – The transactions service
$uniqueIdstring – The unique ID of the module.
$variantscraft\commerce\services\Variants – The variants service
$versionstring – The version of this module.
$viewPathstring – The root directory of view files.

$cpNavItem

Type
array, null
Access
Read-only

View source

Signature

public array, null getCpNavItem ( )

$hasCpSection

Type
boolean

Whether the plugin has its own section in the CP

View source

Signature

public boolean $hasCpSection = true

$hasCpSettings

Type
boolean

Whether the plugin has a settings page in the CP

View source

Signature

public boolean $hasCpSettings = true

$minVersionRequired

Type
string

The minimum required version the plugin has to be so it can be updated.

View source

Signature

public string $minVersionRequired = '1.2.1360'

$schemaVersion

Type
string, null

The plugin’s schema version number

View source

Signature

public string, null $schemaVersion = '2.0.52'

$settingsResponse

Type
mixed
Access
Read-only

The result that should be returned from craft\controllers\PluginsController::actionEditPluginSettings()

View source

Signature

public mixed getSettingsResponse ( )

Public Methods

MethodDescription
__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()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to 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.
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.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
get()Returns the component instance with the specified ID.
getAddresses()Returns the address service
getAvailableShippingMethods()Returns all available shipping methods for the current cart.
getBasePath()Returns the root directory of the module.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getCart()Returns the current Cart.
getCarts()Returns the cart 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.
getCountries()Returns the countries service
getCountriesList()Return an array of country names, indexed by ID.
getCpNavItem()Returns the CP nav item definition for this plugin’s CP section, if it has one.
getCurrencies()Returns the currencies service
getCustomer()Returns the current customer.
getCustomers()Returns the customers service
getDiscountByCode()Returns a discount by its code.
getDiscounts()Returns the discounts service
getEmails()Returns the emails 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.
getLayoutPath()Returns the directory that contains layout view files for this module.
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
getOrderSettings()Returns the orderSettings 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
getPdf()Returns the PDF service
getPlans()Returns the payment sources service
getPrimaryPaymentCurrency()Returns the primary payment currency.
getProductTypes()Returns the productTypes service
getProducts()Returns the products service
getPurchasables()Returns the purchasables service
getReports()Returns the reporting service
getSales()Returns the sales service
getSettings()Returns the model that the plugin’s settings should be stored on, if the plugin has settings.
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
getStates()Returns the states service
getStatesArray()Returns a 2D array of state names indexed by state ids, grouped by country ids.
getSubscriptions()Returns the subscriptions service
getTaxCategories()Returns the taxCategories service
getTaxRates()Returns the taxRates service
getTaxZones()Returns the taxZones service
getTransactions()Returns the transactions service
getUniqueId()Returns an ID that uniquely identifies this module among all modules within the current application.
getVariants()Returns the variants service
getVersion()Returns current module version.
getViewPath()Returns the directory that contains the view files for this module.
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.
init()Initializes the module.
install()Installs the plugin.
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.
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.

View source

Returns

boolean – Whether the plugin should be installed

Signature

public boolean beforeInstall ( )

getCpNavItem()

Returns the CP nav item definition for this plugin’s CP section, if it has one.

View source

Returns

array, null

Signature

public array, null getCpNavItem ( )

getSettingsResponse()

Returns the settings page response.

View source

Returns

mixed – The result that should be returned from craft\controllers\PluginsController::actionEditPluginSettings()

Signature

public mixed getSettingsResponse ( )

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.

View source

Signature

public void init ( )

Protected Methods

MethodDescription
afterInstall()Performs actions after the plugin is installed.
afterUninstall()Performs actions after the plugin is installed.
beforeUninstall()Performs actions before the plugin is installed.
cpNavIconPath()Returns the path to the SVG icon that should be used in the plugin’s CP nav item.
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.

View source

Returns

craft\base\Model, null

Signature

protected craft\base\Model, null createSettingsModel ( )