function hook_uc_order_product_can_ship in Ubercart 8.4
Same name and namespace in other branches
- 7.3 uc_order/uc_order.api.php \hook_uc_order_product_can_ship()
Allow modules to specify whether a product is shippable.
Parameters
\Drupal\uc_order\OrderProductInterface|\Drupal\uc_cart\CartItemInterface $product: The product to check. May be a cart item or an order product.
Return value
bool 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_role_uc_order_product_can_ship in uc_role/
uc_role.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 212 - 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', [
':nid' => $product->nid->target_id,
]);
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($product->data['model']) ? $product->model->value : $product->data['model'];
// Keep looking if it doesn't match.
if ($sku != $role->model) {
continue;
}
return $role->shippable;
}
}