Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ps_googleanalytics.php #168

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 83 additions & 35 deletions ps_googleanalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ public function getContent()

public function hookDisplayHeader($params, $back_office = false)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayHeader($this, $this->context);
$hook->setBackOffice($back_office);
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayHeader($this, $this->context);
$hook->setBackOffice($back_office);

return $hook->run();
return $hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -92,10 +96,14 @@ public function hookDisplayHeader($params, $back_office = false)
*/
public function hookDisplayOrderConfirmation($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayOrderConfirmation($this, $this->context);
$hook->setParams($params);
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayOrderConfirmation($this, $this->context);
$hook->setParams($params);

return $hook->run();
return $hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -104,9 +112,13 @@ public function hookDisplayOrderConfirmation($params)
*/
public function hookDisplayBeforeBodyClosingTag()
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayBeforeBodyClosingTag($this, $this->context);
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayBeforeBodyClosingTag($this, $this->context);

return $hook->run();
return $hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -115,9 +127,13 @@ public function hookDisplayBeforeBodyClosingTag()
*/
public function hookDisplayFooterProduct()
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayFooterProduct($this, $this->context);
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayFooterProduct($this, $this->context);

return $hook->run();
return $hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -126,13 +142,17 @@ public function hookDisplayFooterProduct()
*/
public function hookDisplayAdminOrder()
{
$gaTagHandler = new PrestaShop\Module\Ps_Googleanalytics\Handler\GanalyticsJsHandler($this, $this->context);
try {
$gaTagHandler = new PrestaShop\Module\Ps_Googleanalytics\Handler\GanalyticsJsHandler($this, $this->context);

$output = $gaTagHandler->generate($this->context->cookie->ga_admin_refund);
unset($this->context->cookie->ga_admin_refund);
$this->context->cookie->write();
$output = $gaTagHandler->generate($this->context->cookie->ga_admin_refund);
unset($this->context->cookie->ga_admin_refund);
$this->context->cookie->write();

return $output;
return $output;
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -141,9 +161,13 @@ public function hookDisplayAdminOrder()
*/
public function hookDisplayBackOfficeHeader()
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayBackOfficeHeader($this, $this->context);
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookDisplayBackOfficeHeader($this, $this->context);

return $hook->run();
return $hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -152,29 +176,41 @@ public function hookDisplayBackOfficeHeader()
*/
public function hookActionProductCancel($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionProductCancel($this, $this->context);
$hook->setParams($params);
$hook->run();
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionProductCancel($this, $this->context);
$hook->setParams($params);
$hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
* Hook used to detect backoffice orders and store their IDs into cookie.
*/
public function hookActionValidateOrder($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionValidateOrder($this, $this->context);
$hook->setParams($params);
$hook->run();
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionValidateOrder($this, $this->context);
$hook->setParams($params);
$hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
* Hook called after order status change, used to "refund" order after cancelling it
*/
public function hookActionOrderStatusPostUpdate($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionOrderStatusPostUpdate($this, $this->context);
$hook->setParams($params);
$hook->run();
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionOrderStatusPostUpdate($this, $this->context);
$hook->setParams($params);
$hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -183,9 +219,13 @@ public function hookActionOrderStatusPostUpdate($params)
*/
public function hookActionCartUpdateQuantityBefore($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionCartUpdateQuantityBefore($this, $this->context);
$hook->setParams($params);
$hook->run();
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionCartUpdateQuantityBefore($this, $this->context);
$hook->setParams($params);
$hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

/**
Expand All @@ -194,16 +234,24 @@ public function hookActionCartUpdateQuantityBefore($params)
*/
public function hookActionObjectProductInCartDeleteBefore($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionObjectProductInCartDeleteBefore($this, $this->context);
$hook->setParams($params);
$hook->run();
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionObjectProductInCartDeleteBefore($this, $this->context);
$hook->setParams($params);
$hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

public function hookActionCarrierProcess($params)
{
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionCarrierProcess($this, $this->context);
$hook->setParams($params);
$hook->run();
try {
$hook = new PrestaShop\Module\Ps_Googleanalytics\Hooks\HookActionCarrierProcess($this, $this->context);
$hook->setParams($params);
$hook->run();
} catch (Exception $e) {
error_log($e->getMessage());
}
}

protected function _debugLog($function, $log)
Expand Down