Skip navigation
Help

hook_uc_order_product_can_ship

7 uc_order.api.php hook_uc_order_product_can_ship($product)

Allow modules to specify whether a product is shippable.

Parameters

$product: The product to check. May be a cart item or an order product.

Return value

TRUE to specify that this product is shippable.

Related topics

2 functions implement hook_uc_order_product_can_ship()

1 invocation of hook_uc_order_product_can_ship()

File

ubercart/uc_order/uc_order.api.php, line 501
Hooks provided by the Order module.

Code

function hook_uc_order_product_can_ship($product) {
  $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;
  }
}