Uc Cart workflow (Order has product of particular class)

Posts: 12
Joined: 11/30/2007
Bug Finder

i have been trying to get this workflow condition to work with no luck. After doing some debugging the problem appears to be in

uc_cart_workflow.inc

function uc_cart_condition_product_class($order, $settings) {
  $result = FALSE;
  foreach ($order->products as $product) {
    if ($product->type == $settings['class']) {
      $result = TRUE;
      break;
    }
  }

  return $result;
}

It is checking the product type but the product has no type set. The product is a created class through product classes.

Posts: 12
Joined: 11/30/2007
Bug Finder

Temp Fix

function uc_cart_condition_product_class($order, $settings) {
  $result = FALSE;
  foreach ($order->products as $product) {
     $get_type = db_fetch_object(db_query("SELECT type FROM {node} WHERE nid = %d", $product->nid));
     if ($get_type->type == $settings['class']) {
    //if ($product->type == $settings['class']) {
      $result = TRUE;
      break;
    }
  }

  return $result;
}

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Good find. I've added the fix with some modifications to reduce the number of queries that need to be made,.