name = 'ganalytics';
$this->tab = 'Stats';
$this->version = '1.2';
$this->displayName = 'Google Analytics';
parent::__construct();
if (!Configuration::get('GANALYTICS_ID'))
$this->warning = $this->l('You have not yet set your Google Analytics ID');
$this->description = $this->l('Integrate the Google Analytics script into your shop');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
}
function install()
{
if (!parent::install() OR !$this->registerHook('footer') OR !$this->registerHook('orderConfirmation'))
return false;
return true;
}
function uninstall()
{
if (!Configuration::deleteByName('GANALYTICS_ID') OR !parent::uninstall())
return false;
return true;
}
public function getContent()
{
$output = '
Google Analytics
';
if (Tools::isSubmit('submitGAnalytics') AND ($gai = Tools::getValue('ganalytics_id')))
{
Configuration::updateValue('GANALYTICS_ID', $gai);
$output .= '
'.$this->l('Settings updated').'
';
}
return $output.$this->displayForm();
}
public function displayForm()
{
$output = '
';
$output .= '
';
return $output;
}
function hookFooter($params)
{
global $step, $protocol_content;
$gaJsHost = ($protocol_content == 'https://' ? 'ssl' : 'www');
$output = '
';
return $output;
}
function hookOrderConfirmation($params)
{
global $protocol_content;
$gaJsHost = ($protocol_content == 'https://' ? 'ssl' : 'www');
$order = $params['objOrder'];
if (Validate::isLoadedObject($order))
{
$deliveryAddress = new Address(intval($order->id_address_delivery));
$conversion_rate = 1;
if ($order->id_currency != Configuration::get('PS_CURRENCY_DEFAULT'))
{
$currency = new Currency(intval($order->id_currency));
$conversion_rate = floatval($currency->conversion_rate);
}
/* Order general informations */
$output = '
';
return $output;
}
}
}