E-Commerce Installation Profile
E-Commerce is a collection of several dozen modules for creating an online store. However, it requires some advanced configuration. As an example we have produced a simple install profile for e-commerce. In this profile we provide first a list of modules that should be enabled, then a profile description. In each of the .install files we have copied important pieces of settings forms to be added to the installation system forms.
<?php
/**
* The modules that are enabled when this profile is installed.
*
* @return
* An array of modules to be enabled.
*/
function ecommerce_profile_modules() {
return array('system', 'apparel', 'audio', 'block', 'cart', 'civicrm', 'cod', 'comment', 'content', 'coupon', 'custom', 'donate', 'ecivicrm', 'file', 'filter', 'help', 'image', 'image_attach', 'menu', 'node', 'page', 'path', 'payment', 'product', 'recommend', 'role_discount', 'shipcalc', 'shipping', 'store', 'stores', 'story', 'subproducts', 'tangible', 'taxonomy', 'text', 'user', 'userreview', 'views', 'votingapi', 'watchdog');
}
/**
*
*/
function ecommerce_profile_details() {
return array(
'name' => 'Ecommerce',
'description' => 'Select this profile to enable the ecommerce distribution.');
}
function ecommerece_install_configure(&$form) {
drupal_set_title('ecommerce configuration');
}
function ecommerece_get_styles() {
return array('profiles/civicspace/civicspace-installer.css');
}
function civicspace_get_scripts() {
return array('profiles/civicspace/toggle.js');
}
?>Here is an example of how we can add configuration forms for E-Commerce to the installation profile.
<?php
function store_install_configure(&$form) {
$options = array(
t('Customers do not have to create accounts in order to purchase items from this site.'),
t('Customers must create accounts before purchasing an item from this site.'));
$form['store'] = array(
'#type' => 'fieldset',
'#title' => t('Store settings'),
);
$form['store']['store_auth_cust'] = array(
'#type' => 'radios',
'#title' => t('Authenticated customers'),
'#default_value' => variable_get('store_auth_cust', 1),
'#options' => $options,
'#description' => t('There are several advantages in having customers create accounts. When they shop, the items in their cart will be remembered from visit to visit, and they can store their shipping and billing addresses in an address book at this site.')
);
return $form;
}
function store_install_configure_submit($form_id, $edit) {
variable_set('store_auth_cust', $edit['store_auth_cust']);
}
?>