You are here

function _commerce_kickstart_install in Commerce Kickstart 7

Performs additional configuration for Drupal Commerce modules and components.

1 call to _commerce_kickstart_install()
commerce_kickstart_install in ./commerce_kickstart.install
Implements hook_install().

File

./commerce_kickstart.install, line 449
Performs a standard Drupal installation with additional configuration of the Drupal Commerce modules and components.

Code

function _commerce_kickstart_install() {

  // Enable Commerce blocks.
  $default_theme = variable_get('theme_default', KICKSTART_DEFAULT_THEME);
  $admin_theme = KICKSTART_ADMIN_THEME;
  $values = array(
    array(
      'module' => 'commerce_cart',
      'delta' => 'cart',
      'theme' => $default_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'sidebar_first',
      'pages' => "cart\ncheckout/*",
      'cache' => -1,
    ),
  );
  $query = db_insert('block')
    ->fields(array(
    'module',
    'delta',
    'theme',
    'status',
    'weight',
    'region',
    'pages',
    'cache',
  ));
  foreach ($values as $record) {
    $query
      ->values($record);
  }
  $query
    ->execute();

  // Add an image field to the default product type.
  _commerce_kickstart_create_product_image_field('commerce_product', 'product');

  // Insert a product display node type into the database.
  $types = array(
    array(
      'type' => 'product_display',
      'name' => st('Product display'),
      'base' => 'node_content',
      'description' => st('Use <em>product displays</em> to present Add to Cart form for products to your customers.'),
      'custom' => 1,
      'modified' => 1,
      'locked' => 0,
    ),
  );
  foreach ($types as $type) {
    $type = node_type_set_defaults($type);
    node_type_save($type);
    node_add_body_field($type);
  }

  // Update "Product" comment and author information settings.
  variable_set('comment_product_display', COMMENT_NODE_HIDDEN);
  variable_set('node_submitted_product_display', FALSE);

  // Add the product reference field to our product display node type.
  _commerce_kickstart_create_product_reference('node', 'product_display');

  // Give checkout access to anonymous and authenticated users.
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
    'access checkout',
  ));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'access checkout',
  ));

  // Allow users to view their own completed orders.
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
    'view own commerce_order entities',
  ));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'view own commerce_order entities',
  ));

  // Disable Views' Advanced Help module nag message until it's production ready.
  variable_set('views_hide_help_message', TRUE);

  // If Admin Menu is installed, collapse the module fieldsets.
  variable_set('admin_menu_tweak_modules', TRUE);

  // Add a shortcut set for store administration.
  $set = new stdClass();
  $set->title = st('Store administration');
  $set->links = array(
    array(
      'link_path' => 'admin/commerce/products/add',
      'link_title' => st('Add product'),
    ),
    array(
      'link_path' => 'node/add/product-display',
      'link_title' => st('Add product display'),
    ),
    array(
      'link_path' => 'admin/commerce/products',
      'link_title' => st('View products'),
    ),
    array(
      'link_path' => 'admin/commerce/orders',
      'link_title' => st('View orders'),
    ),
    array(
      'link_path' => 'admin/commerce/config',
      'link_title' => st('Configure store'),
    ),
  );
  shortcut_set_save($set);

  // Apply the shortcut set to the first user.
  shortcut_set_assign_user($set, (object) array(
    'uid' => 1,
  ));
}