You are here

function uc_roles_uc_order_product_can_ship in Ubercart 7.3

Implements hook_uc_order_product_can_ship().

File

uc_roles/uc_roles.module, line 395
Grants roles upon accepted payment of products.

Code

function uc_roles_uc_order_product_can_ship($item) {
  $roles = db_query("SELECT * FROM {uc_roles_products} WHERE nid = :nid", array(
    ':nid' => $item->nid,
  ));
  foreach ($roles as $role) {

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