By buendia on
I was told that it would be easier to modify the E-Commerce module in 4.7 where Form API is used. However, it seems to me that not everything can be modified by Forms (yet). Here is an example:
Assume we want the price of the product to not be shown to the user. The price appear by the function theme_node_product in product.module as the following:
function theme_node_product($node, $teaser = 0, $page = 0) {
$product_type_theme = false;
$f = 'theme_product_'. $node->ptype . '_view';
if (function_exists($f)) {
$product_type_theme = true;
$node = theme('product_'. $node->ptype. '_view', $node, $teaser, $page);
}
if (!$product_type_theme) {
$price_string = '<div class="price"><strong>'. t('Price') .'</strong>: ' . module_invoke('payment', 'format', product_adjust_price($node)) . '</div>';
if ($node->is_recurring) {
$price_string .= '<div class="recurring-details">'. product_recurring_nice_string($node) . '</div>';
}
$node->teaser .= $price_string;
$node->body .= $price_string;
}
return $node;
}
The question is how can the Forms API be used to modify this function so that it hides the price?
Comments
Theme functions can be overridden
I am not familiar with the logic of the modules you're using, but this is a theme function, thus you can write a new theme funciton that overrides it like this:
- Robert Douglass
-----
My Drupal book: Building Online Communities with Drupal, phpBB and WordPress
look closely at theme_node_product()
and you'll see that it uses a product-type specific theme function if one is available:
So for a product type 'potato' (defined by a potato.module), you can write a theme function called
theme_product_potato_view(), and all your potato records will be presented accordingly.w00t
This is the type of magic that one can expect from Matt W. and co. =)
- Robert Douglass
-----
My Drupal book: Building Online Communities with Drupal, phpBB and WordPress