home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (uc_product_handler_field_addtocart.inc)

This example Drupal source code file (uc_product_handler_field_addtocart.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

_add_to_cart, extends, function, if, isset, module, node, php, product, render, return, theme, type, values

The uc_product_handler_field_addtocart.inc Drupal example source code

// $Id: uc_product_handler_field_addtocart.inc,v 2009/05/07 20:52:29 islandusurper Exp $

 * @file
 * Views handler: "Add to cart" form as a field.

 * Display the "Add to cart" form like the product page.
class uc_product_handler_field_addtocart extends views_handler_field {
  function query() {

  function element_type() {
    if (isset($this->definition['element type'])) {
      return $this->definition['element type'];
    return 'div';

  function render($values) {
    if (uc_product_is_product($values->{$this->aliases['type']})) {
      $type = node_get_types('type', $values->{$this->aliases['type']});
      $module = $type->module;
      $product = node_load($values->{$this->aliases['nid']});
      if (function_exists('theme_'. $module .'_add_to_cart')) {
        return theme($module .'_add_to_cart', $product);
      elseif (function_exists('theme_uc_product_add_to_cart')) {
        return theme('uc_product_add_to_cart', $product);

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_product_handler_field_addtocart.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.