Hi,
I'm currently writing a new product type called rentable product for the ecommerce package,
but I can't get to understand how the Forms API really works.
Here's parts of my code for now:
function theme_product_rentable_view(&$node, $teaser = FALSE, $page = FALSE) {
$price_string = '<div class="price"><strong>'. t('Price') .'</strong>: ' . module_invoke('payment', 'format', product_adjust_price($node)) . '</div>';
$node->teaser .= $price_string;
$node->body .= $price_string;
$link = l(t('Check availability '),'rentable/availability/'.$node->nid);
$node->teaser .= $link;
$node->body .= $link;
return $node;
}
When a rentable product is created, this puts a link on the bottom of the product body.
Clicking on the link is controlled by the following function:
function rentable_menu($may_cache) {
$items = array();
if (!$may_cache) {
$items[] = array(
'path' => 'rentable/availability/' . arg(2),
'title' => t('Product availability'),
'callback' => 'rentable_check_availability',
'access' => true,
'type' => MENU_CALLBACK);
}
return $items;
}
The next function then invokes a callback to rentable_check_availability():
function rentable_check_availability(){
$output = '';
if(!is_numeric(arg(2))){
drupal_set_message('Product not selected','error');