function uc_role_uc_order_product_can_ship in Ubercart 8.4
Implements hook_uc_order_product_can_ship().
File
- uc_role/
uc_role.module, line 349 - Grants roles upon accepted payment of products.
Code
function uc_role_uc_order_product_can_ship($product) {
$connection = \Drupal::database();
$roles = $connection
->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;
}
}