You are here

commerce_combine_carts.module in Commerce Combine Carts 8

File

commerce_combine_carts.module
View source
<?php

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function commerce_combine_carts_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.commerce_combine_carts') {
    $output = '';
    $output .= '<h3>' . t('About') . '</h3>';
    $output .= '<p>' . t('Combines multiple carts so that users only ever have one.') . '</p>';
    return $output;
  }
}

/**
 * Implements hook_user_login().
 *
 * @throws \Drupal\Core\Entity\EntityStorageException
 */
function commerce_combine_carts_user_login(\Drupal\user\UserInterface $account) {

  /** @var \Drupal\commerce_combine_carts\CartUnifier $cart_unifier */
  $cart_unifier = \Drupal::service('commerce_combine_carts.cart_unifier');
  $cart_unifier
    ->combineUserCarts($account);
}