function commerce_cart_user_login in Commerce Core 8.2
Same name and namespace in other branches
- 7 modules/cart/commerce_cart.module \commerce_cart_user_login()
Implements hook_user_login().
File
- modules/
cart/ commerce_cart.module, line 104 - Implements the shopping cart system and add to cart features.
Code
function commerce_cart_user_login($account) {
// Assign the anonymous user's carts to the logged-in account.
// This will only affect the carts that are in the user's session.
$anonymous = new AnonymousUserSession();
$carts = \Drupal::service('commerce_cart.cart_provider')
->getCarts($anonymous);
\Drupal::service('commerce_order.order_assignment')
->assignMultiple($carts, $account);
}