You are here

function uc_roles_cart_item in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_roles/uc_roles.module \uc_roles_cart_item()

Implements hook_cart_item().

File

uc_roles/uc_roles.module, line 510

Code

function uc_roles_cart_item($op, &$item) {
  switch ($op) {
    case 'can_ship':
      $roles = db_query("SELECT * FROM {uc_roles_products} WHERE nid = %d", $item->nid);
      while ($role = db_fetch_object($roles)) {

        // If the model is empty, keep looking. (Everyone needs a role model...)
        if (empty($role->model)) {
          continue;
        }

        // If there's an adjusted SKU, use it... otherwise use the node SKU.
        $sku = empty($item->data['model']) ? $item->model : $item->data['model'];

        // Keep looking if it doesn't match.
        if ($sku != $role->model) {
          continue;
        }
        return $role->shippable;
      }
      break;
  }
}