You are here

function uc_googleanalytics_display in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_googleanalytics/uc_googleanalytics.module \uc_googleanalytics_display()
  2. 6.2 uc_googleanalytics/uc_googleanalytics.module \uc_googleanalytics_display()
  3. 7.3 uc_googleanalytics/uc_googleanalytics.module \uc_googleanalytics_display()

Determines whether or not to display the e-commerce related JS through GA.

Return value

bool TRUE or FALSE indicating whether or not to display the GA e-commerce JS.

1 call to uc_googleanalytics_display()
uc_googleanalytics_page_attachments_alter in uc_googleanalytics/uc_googleanalytics.module
Implements hook_page_attachments_alter().

File

uc_googleanalytics/uc_googleanalytics.module, line 62
Adds Google Analytics Javascript to the checkout completion page.

Code

function uc_googleanalytics_display() {

  // Display the GA e-commerce JS if the URL is cart/checkout/complete...
  $route_match = \Drupal::routeMatch();
  if ($route_match
    ->getRouteName() == 'uc_cart.checkout_complete') {
    return TRUE;
  }

  // Or if another module says this is the page through hook_ucga_display().
  foreach (\Drupal::moduleHandler()
    ->invokeAll('ucga_display') as $result) {
    if ($result === TRUE) {
      return TRUE;
    }
  }

  // Otherwise return FALSE.
  return FALSE;
}