public function CommerceGoogleTagManagerActionCheckout::execute in Commerce Google Tag Manager 7.2
Executes the action.
Parameters
array $order The Order being checked out:
string $step The checkout step:
string $option Any checkout action related to the step.:
File
- includes/
rules/ CommerceGoogleTagManagerActionCheckout.php, line 50 - This file contains the "Send Checkout event to GTM" action definition.
Class
- CommerceGoogleTagManagerActionCheckout
- @file This file contains the "Send Checkout event to GTM" action definition.
Code
public function execute($order, $step = null, $option = null) {
$order = CommerceGoogleTagManagerHelper::getWrappedOrder($order);
$productsData = CommerceGoogleTagManagerHelper::getLineItemsData($order, $this
->getCommerceEventName());
$currencyCode = $order->commerce_order_total->currency_code
->value();
$data = array(
'currencyCode' => $currencyCode,
'checkout' => array(
'products' => $productsData,
),
);
if (!is_null($step)) {
$data['checkout']['actionField']['step'] = $step;
}
if (!is_null($option)) {
$data['checkout']['actionField']['option'] = $option;
}
// Push the commerce-data.
$this
->pushCommerceData($data);
}