You are here

function uc_cart_condition_product_class in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_cart/uc_cart.ca.inc \uc_cart_condition_product_class()

File

uc_cart/uc_cart_workflow.inc, line 48
This file contains the Workflow-ng hooks and functions necessary to make the cart related entity, conditions, events, and actions work.

Code

function uc_cart_condition_product_class($order, $settings) {
  $result = FALSE;
  $types = array();
  foreach ($order->products as $product) {

    // Ignore "blank line" custom products.
    if ($product->nid) {

      // Cache product types to avoid extra queries.
      if (!isset($types[$product->nid])) {
        if (isset($product->type)) {
          $types[$product->nid] = $product->type;
        }
        else {
          $types[$product->nid] = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $product->nid));
        }
      }
      if ($types[$product->nid] == $settings['class']) {
        $result = TRUE;
        break;
      }
    }
  }
  return $result;
}