You are here

function uc_product_handler_field_addtocart::render in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_product/views/uc_product_handler_field_addtocart.inc \uc_product_handler_field_addtocart::render()

Overrides views_handler_field::render().

File

uc_product/views/uc_product_handler_field_addtocart.inc, line 34
Views handler: "Add to cart" form as a field.

Class

uc_product_handler_field_addtocart
Displays the "Add to cart" form like the product page.

Code

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);
    }
  }
}