Skip to content

Instantly share code, notes, and snippets.

@rachellawson
Created March 14, 2013 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachellawson/5165689 to your computer and use it in GitHub Desktop.
Save rachellawson/5165689 to your computer and use it in GitHub Desktop.
My childish attempts at creating a custom line-type
<?php
/**
* @file dsdm_membership_line_item.module
* Defines the line-item-type for the DSDM Memberships
*
*/
/**
* This function simply returns information about the example to help the
* user understand its purpose.
*/
function dsdm_membership_line_item_info_page() {
return array(
'#markup' => t('The line item example demonstrates adding a custom line item and also how to use related API functions. With this module enabled, an additional line item may be selected by add-to-cart forms.'),
);
}
/**
* Implements hook_commerce_line_item_type_info().
*
*
* @see hook_commerce_line_item_type_info().
* @see http://www.drupalcommerce.org/specification/info-hooks/checkout
*
*/
function dsdm_membership_line_item_commerce_line_item_type_info() {
$line_item_types['dsdm_membership_line_item'] = array(
'name' => t('TEST membership_line_item 1'),
'description' => t('Some Thing here'),
'product' => TRUE,
// Here you can change the text in the submit button in the order admin form.
'add_form_submit_value' => t('Add DSDM Membership'),
// 'base' basically provides magic naming for a set of callbacks
// including the settings_form, checkout_form, etc. Here we'll use the
// forms and callbacks provided for Commerce Product Reference module for
// its product line item, so we'll use
// commerce_product_line_item_configuration()
// and commerce_product_line_item_title(), etc.
// See example_line_item_2 for explicit callbacks.
'base' => 'commerce_product_line_item',
'callbacks' => array(
'configuration' => 'dsdm_membership_line_item_commerce_product_line_item_configuration',
),
);
return $line_item_types;
}
/**
* Configure the line item with additional fields or whatever.
*
* This function is called by the line item module when it is enabled or this
* module is enabled. It invokes this function using the configuration_callback
* as specified above. Other modules defining product line item types should
* use this function to ensure their types have the required fields.
*
* @param $line_item_type
* The info array of the line item type being configured.
*
* @see commerce_product_line_item_configuration()
*/
function dsdm_membership_line_item_commerce_product_line_item_configuration($line_item_type) {
$type = $line_item_type['type'];
// Here we could add fields or other configuration.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment