abstract class CommerceGoogleTagManagerBaseAction in Commerce Google Tag Manager 7.2
@file This file contains the base class for CommerceGoogleTagManager actions.
Hierarchy
- class \RulesPluginHandlerBase extends \FacesExtender implements RulesPluginHandlerInterface
- class \RulesActionHandlerBase implements RulesActionHandlerInterface
Expanded class hierarchy of CommerceGoogleTagManagerBaseAction
File
- includes/
CommerceGoogleTagManagerBaseAction.php, line 7 - This file contains the base class for CommerceGoogleTagManager actions.
View source
abstract class CommerceGoogleTagManagerBaseAction extends RulesActionHandlerBase {
/**
* Returns the commerce event's name to be sent.
*
* @return string
*/
public abstract function getCommerceEventName();
/**
* Get the default Rule's info.
*
* @return array
*/
protected static function getDefaultsInfo() {
return array(
'group' => t('Commerce Google-TagManager'),
'name' => get_called_class(),
);
}
/**
* Builds and pushes the current commerce data.
*
* @param array $commerceData
*/
protected function pushCommerceData(array $commerceData) {
$script = 'var dataLayer = dataLayer || []; ';
$data = array(
'event' => $this
->getCommerceEventName(),
'ecommerce' => $commerceData,
);
$context = array(
'event' => $this
->getCommerceEventName(),
);
// Allow other modules to alter this data before sending to DataLayer
drupal_alter('commerce_google_tag_manager_commmerce_data', $data, $context);
// Add the data line to the JS array.
$_SESSION['commerce_google_tag_manager'][] = $script . 'dataLayer.push(' . drupal_json_encode($data) . ');';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommerceGoogleTagManagerBaseAction:: |
abstract public | function | Returns the commerce event's name to be sent. | 4 |
CommerceGoogleTagManagerBaseAction:: |
protected static | function | Get the default Rule's info. | |
CommerceGoogleTagManagerBaseAction:: |
protected | function | Builds and pushes the current commerce data. | |
RulesPluginHandlerBase:: |
protected | property | ||
RulesPluginHandlerBase:: |
public | function |
Implements RulesPluginImplInterface::access(). Overrides RulesPluginHandlerInterface:: |
|
RulesPluginHandlerBase:: |
public | function |
Returns an array of info assertions for the specified parameters. Overrides RulesPluginHandlerInterface:: |
1 |
RulesPluginHandlerBase:: |
public | function |
Returns an array of required modules. Overrides RulesPluginHandlerInterface:: |
|
RulesPluginHandlerBase:: |
public | function |
Alters the generated configuration form of the element. Overrides RulesPluginHandlerInterface:: |
|
RulesPluginHandlerBase:: |
public | function |
Allows altering of the element's action/condition info. Overrides RulesPluginHandlerInterface:: |
|
RulesPluginHandlerBase:: |
public | function |
Processes settings independent from a form submission. Overrides RulesPluginHandlerInterface:: |
|
RulesPluginHandlerBase:: |
public | function |
Validates $settings independent from a form submission. Overrides RulesPluginHandlerInterface:: |
|
RulesPluginHandlerBase:: |
public | function | Overridden to provide $this->element to make the code more meaningful. |