I'm now working on generating transactional data on the checkout SUCCESS page.
This location is important. I've mentioned a number of times throughout this process that analytic software should only report success after the confirmation is received and the payment processed.
I'm currently using:
public function onControllerPagesCheckoutSuccess_InitData() {
$registry = Registry::getInstance();
$script_html = 'SCRIPT TAG';
if (isset($this->session->data['order_id'])) {
$order_id = $registry->get('session')->data['order_id'];
$order_info = $registry->get('model_checkout_order')->getOrder($order_id);
$webpropertyid = $this->baseObject->get('config')->get('strikehawk_ganalytics_webpropertyid');
$script_html = "Place Some html Here, for ex: <script> alert('Order Total: " . $order_info['total'] . "')</script>";
}
$this->baseObject->view->addHookVar('payment_analytics', $script_html);
return;
}
as opposed to the suggested:
public function onControllerPagesCheckoutConfirm_UpdateData() {
$registry = Registry::getInstance();
$order_id = $registry->get('session')->data['order_id'];
$order_info = $registry->get('model_checkout_order')->getOrder($order_id);
$webpropertyid = $this->baseObject->get('config')->get('strikehawk_ganalytics_webpropertyid');
$script_html = "Place Some html Here, for ex: <script> alert('Order Total: " . $order_info['total'] . "')</script>";
$this->baseObject->view->addHookVar('payment_analytics', $script_html);
return;
}
In either case, I'm getting an error similar to this:
Fatal error: Call to a member function getOrder() on a non-object in extensions/strikehawk_ganalytics/core/strikehawk_ganalytics.php on line 27
which refers to the line:
$order_info = $registry->get('model_checkout_order')->getOrder($order_id);
My diagnostic code (echoing the $order_id variable) indicates that I do have a valid order ID in the session. So, it appears that this is not the correct way to invoke the checkout order model...
David