/** * Allows modules to confirm that an order may proceed to checkout. * * If any implementation of this hook returns TRUE, the given order can proceed * to checkout. However, if no implementations of this hook exist and return * TRUE, the checkout router will simply redirect away to the front page. * * @param $order * The order being confirmed for checkout. * * @return * Boolean value indicating whether or not the order can proceed to checkout. */ function hook_commerce_checkout_order_can_checkout($order) { // Allow orders with one or more product line items to proceed to checkout. // If there are no line items on the order, redirect away. $wrapper = entity_metadata_wrapper('commerce_order', $order); if (commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) > 0) { return TRUE; } }
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ global $user; $quantity = 0; $total = '$0.00'; $order = commerce_cart_order_load($user->uid); if ($order) { $wrapper = entity_metadata_wrapper('commerce_order', $order); $line_items = $wrapper->commerce_line_items; $quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types()); $order_total = commerce_line_items_total($line_items); } ?> <a href="<?php print url('cart'); ?> "> <span> <i class="fa fa-shopping-cart"></i> </span> <?php print $quantity; ?> item(s) - <?php if ($order) { print commerce_currency_format($order_total['amount'], $order_total['currency_code']);
/** * Overrides theme_menu_link(). */ function cubert_menu_link(array $variables) { $element = $variables['element']; $sub_menu = ''; $team_menus = array('menu-teampayment-navigation', 'user-menu'); $is_user_menu = !empty($element['#original_link']['menu_name']) && $element['#original_link']['menu_name'] == 'user-menu'; // On primary navigation menu, class 'active' is not set on active menu item. // @see https://drupal.org/node/1896674 if (($element['#href'] == $_GET['q'] || $element['#href'] == '<front>' && drupal_is_front_page()) && empty($element['#localized_options']['language'])) { $element['#attributes']['class'][] = 'active'; } // Add FontAwesome icons based on link function $icon = ""; if (!empty($element['#original_link']['menu_name']) && $element['#original_link']['menu_name'] == 'user-menu') { $title = !empty($element['#title']) ? $element['#title'] : ''; $element['#attributes']['class'][] = 'user-action'; if ($element['#href'] == 'user') { global $user; $element['#title'] = $user->name; $icon = "<i class='fa fa-user'></i> "; $element['#attributes']['class'][] = 'user-action-account'; } if ($element['#href'] == 'user/logout') { $icon = "<i class='fa fa-sign-out'></i> "; $element['#attributes']['class'][] = 'user-action-logout'; } if ($element['#href'] == 'cart/my') { $icon = "<i class='fa fa-shopping-cart'></i> "; $element['#attributes']['class'][] = 'user-action-cart'; global $user; $quantity = 0; if ($order = commerce_cart_order_load($user->uid)) { $wrapper = entity_metadata_wrapper('commerce_order', $order); $quantity = commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()); } $title = $title . " (" . $quantity . ")"; $element['#title'] = $title; } } $element['#localized_options'] += array('html' => TRUE); if (!empty($element['#original_link']['menu_name']) && ($element['#original_link']['menu_name'] == 'menu-teampayment-navigation' || $element['#original_link']['menu_name'] == 'user-menu')) { if ($element['#href'] == 'dashboard') { $icon = "<i class='fa fa-home'></i> "; $element['#title'] = ''; $element['#attributes']['class'][] = 'main-nav-home'; } $commerce_links = array('products', 'cart', 'cart/my'); if (in_array($element['#href'], $commerce_links)) { if (module_exists('team_payment')) { $group = team_payment_get_group_info(); $products = team_payment_get_all_commerce_products($group); if (count($products) == 0) { return; } } } } if ($element['#below']) { // Prevent dropdown functions from being added to management menu so it // does not affect the navbar module. if ($element['#original_link']['menu_name'] == 'management' && module_exists('navbar')) { $sub_menu = drupal_render($element['#below']); } elseif (!empty($element['#original_link']['depth']) && in_array($element['#original_link']['menu_name'], $team_menus)) { $depth = $element['#original_link']['depth']; // Add our own wrapper. if ($depth == 2 && !$is_user_menu || $depth == 1 && $is_user_menu) { unset($element['#below']['#theme_wrappers']); $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>'; // Generate as standard dropdown. $element['#title'] .= ' <i class="fa fa-chevron-down"></i>'; $element['#attributes']['class'][] = 'dropdown'; $element['#localized_options']['html'] = TRUE; // Set dropdown trigger element to # to prevent inadvertant page loading // when a submenu link is clicked. $element['#localized_options']['attributes']['data-target'] = '#'; $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle'; $element['#localized_options']['attributes']['data-toggle'] = 'dropdown'; } else { if ($is_user_menu && ($depth = 2)) { unset($element['#below']['#theme_wrappers']); $sub_menu = '<ul class="menu__nested">' . drupal_render($element['#below']) . '</ul>'; } } } } $prefix = ""; $suffix = ""; $output = l($icon . $element['#title'], $element['#href'], $element['#localized_options']); if (!empty($element['#original_link']['depth']) && $element['#original_link']['depth'] == 2) { //$prefix = '<li role="separator" class="divider"></li>'; //$suffix = '<li role="separator" class="divider"></li>'; } return $prefix . '<li ' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>" . $suffix . "\n"; }