vzero Posted November 16, 2009 Share Posted November 16, 2009 hello I am trying to get the orderconfirmation hook that calls the google analytics to work on a thank-you page generated by the authorize.net module.I am using 1.2.5 and cant get the call to happen. Anyone know how to get this hook to show up?the thankyoupage now is <?php /** * Authorize.net payment module thank-you page * * @author Geoff Woodburn [http://www.woodburndesigns.com] * @author Jesse Hemingway [http://www.jirosoft.net] * @version 0.91 */ /* SSL Management */ $useSSL = true; include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../header.php'); if (!$cookie->isLogged()) Tools::redirect('authentication.php?back=order.php'); $id_cart = intval(Tools::getValue('id_cart', 0)); $id_module = intval(Tools::getValue('id_module', 0)); $id_order = Order::getOrderByCartId(intval($id_cart)); $smarty->assign(array( 'HOOK_ORDER_CONFIRMATION' => Module::hookExec('orderConfirmation'))); $smarty->display(dirname(__FILE__).'/thank-you.tpl'); include_once(dirname(__FILE__).'/../../footer.php'); ?> and the tpl file is {capture name=path}{l s='Payment'}{/capture} {include file=$tpl_dir./breadcrumb.tpl} {l s='Thank You for Your Order.'} {assign var='current_step' value='payment'} {include file=$tpl_dir./order-steps.tpl} {l s='Your Order has Been Processed' mod='payauthorizenet'} {l s='Thank you for your purchase. We have successfully processed your order.' mod='payauthorizenet'} View your order history please {$HOOK_ORDER_CONFIRMATION} What I want to pull is from gsanaltyics function hookOrderConfirmation($params) { global $protocol_content; $order = $params['objOrder']; if (Validate::isLoadedObject($order)) { $deliveryAddress = new Address(intval($order->id_address_delivery)); /* Order general informations */ $output = ' [removed][removed] [removed] var pageTracker = _gat._getTracker("'.Configuration::get('GANALYTICS_ID').'"); pageTracker._initData(); pageTracker._addTrans( "'.intval($order->id).'", // Order ID "PrestaShop", // Affiliation "'.floatval($order->total_paid).'", // Total "0", // Tax "'.floatval($order->total_shipping).'", // Shipping "'.$deliveryAddress->city.'", // City "", // State "'.$deliveryAddress->country.'" // Country );'; /* Product informations */ $products = $order->getProducts(); foreach ($products AS $product) { $output .= ' pageTracker._addItem( "'.intval($order->id).'", // Order ID "'.$product['product_reference'].'", // SKU "'.$product['product_name'].'", // Product Name "", // Category "'.floatval($product['product_price_wt']).'", // Price "'.intval($product['product_quantity']).'" // Quantity );'; } $output .= ' pageTracker._trackTrans(); [removed]'; return $output; } } } I dont have to pull this if I can just duplicate it in the thankyou page. anyone know how to get that to workthanks Link to comment Share on other sites More sharing options...
james23 Posted January 8, 2010 Share Posted January 8, 2010 I'm having the same problem, were you able to find a solution? Thanks,James Link to comment Share on other sites More sharing options...
Ion_Cannon Posted January 8, 2010 Share Posted January 8, 2010 I'm having the same problem, were you able to find a solution? Thanks,James What exactly needs to be added from google to enable google-analytics? Is it just a javascript that needs to be run? Just enclose it in {literal} tags in the .tpl file and see if that works. I played with it briefly and it seemed to work but I was getting some mixed-content errors so I deleted it and never got around to messing with it again. Link to comment Share on other sites More sharing options...
vzero Posted January 8, 2010 Author Share Posted January 8, 2010 The information that needs to get pulled is for the ecommerce part of analyticsit is pulling this information which tells google what the order was and for how much ect. function hookOrderConfirmation($params) { global $protocol_content; $order = $params['objOrder']; if (Validate::isLoadedObject($order)) { $deliveryAddress = new Address(intval($order->id_address_delivery)); /* Order general informations */ $output = ' [removed][removed] [removed] var pageTracker = _gat._getTracker("'.Configuration::get('GANALYTICS_ID').'"); pageTracker._initData(); pageTracker._addTrans( "'.intval($order->id).'", // Order ID "PrestaShop", // Affiliation "'.floatval($order->total_paid).'", // Total "0", // Tax "'.floatval($order->total_shipping).'", // Shipping "'.$deliveryAddress->city.'", // City "", // State "'.$deliveryAddress->country.'" // Country );'; /* Product informations */ $products = $order->getProducts(); foreach ($products AS $product) { $output .= ' pageTracker._addItem( "'.intval($order->id).'", // Order ID "'.$product['product_reference'].'", // SKU "'.$product['product_name'].'", // Product Name "", // Category "'.floatval($product['product_price_wt']).'", // Price "'.intval($product['product_quantity']).'" // Quantity );'; } $output .= ' pageTracker._trackTrans(); [removed]'; return $output; } } } regular analytics works fine but I need this information on the thankyou.php of the authorize.net module.(free one not $500000) Link to comment Share on other sites More sharing options...
james23 Posted January 8, 2010 Share Posted January 8, 2010 I'm having the same problem, were you able to find a solution? Thanks,James What exactly needs to be added from google to enable google-analytics? Is it just a javascript that needs to be run? Just enclose it in {literal} tags in the .tpl file and see if that works. I played with it briefly and it seemed to work but I was getting some mixed-content errors so I deleted it and never got around to messing with it again. Thanks for the response. If I hard code the javascript it will work, but I need to set $HOOK_ORDER_CONFIRMATION in the template so that it has all the sale information for ecommerce tracking to work properly. I've added the following to my thank-you.php file in the authorize.net module (modules/payauthorizenet/thank-you.php): $id_cart = intval(Tools::getValue('id_cart', 0)); $id_module = intval(Tools::getValue('id_module', 0)); $id_order = Order::getOrderByCartId(intval($id_cart)); $smarty->assign(array( 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation(intval($id_order)), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn(intval($id_order), intval($id_module)))); but it does not seem to be assigning anything Link to comment Share on other sites More sharing options...
Paul C Posted January 9, 2010 Share Posted January 9, 2010 You could try: //global $cookie; // Hmm not sure about this one, it could be the killer $params = array(); $order = new Order(intval($id_order)); $currency = new Currency(intval($order->id_currency)); if (Validate::isLoadedObject($order)) { $params['total_to_pay'] = $order->total_paid; $params['currency'] = $currency->sign; $params['objOrder'] = $order; $params['currencyObj'] = $currency; // $params['cookie'] = $cookie; $params['cart'] = $id_cart; $smarty->assign(array( 'HOOK_ORDER_CONFIRMATION' => Module::hookExec('orderConfirmation', $params))); } I'm not saying it will work though, but I'm hopeful enough to suggest it. The above is in place of the $smarty->assign() call you were using above. The only sticking point might be the cookie.....Paul Link to comment Share on other sites More sharing options...
Paul C Posted January 9, 2010 Share Posted January 9, 2010 You might find using smarty in debug mode might help let you see what smary variables have been defined and what they contain:Debugging smarty in Prestashop.In particular if you turn the above on and enable FireBug, you be able to determine the state of all the variables as well as see what code is assign to the HOOK variable Good luck,Paul Link to comment Share on other sites More sharing options...
Recommended Posts