You are here

function hook_uc_order_product_can_ship in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_order/uc_order.api.php \hook_uc_order_product_can_ship()

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.

2 functions implement hook_uc_order_product_can_ship()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_file_uc_order_product_can_ship in uc_file/uc_file.module
Implements hook_uc_order_product_can_ship().
uc_roles_uc_order_product_can_ship in uc_roles/uc_roles.module
Implements hook_uc_order_product_can_ship().
1 invocation of hook_uc_order_product_can_ship()
uc_order_product_is_shippable in uc_order/uc_order.module
Determines whether a product is shippable or not.

File

uc_order/uc_order.api.php, line 500
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;
  }
}