function commerce_registration_item_can_register in Commerce Registration 7.2
Same name and namespace in other branches
- 7 commerce_registration.rules.inc \commerce_registration_item_can_register()
Condition callback.
Checks if the line item product has registration capacity left. Capacity is only taken if an order is paid for in full.
Parameters
CommerceLineItem $line_item: Commerce Line Item to check the product for registration capacity.
Return value
bool Boolean TRUE if the product has registration capacity.
Related topics
1 string reference to 'commerce_registration_item_can_register'
File
- ./
commerce_registration.rules.inc, line 146 - Commerce Registration rules file.
Code
function commerce_registration_item_can_register($line_item) {
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
if (!in_array($line_item_wrapper->type
->value(), commerce_product_line_item_types())) {
return FALSE;
}
$id = $line_item_wrapper->commerce_product->product_id
->value();
$settings = registration_entity_settings('commerce_product', $id);
if (empty($settings)) {
return FALSE;
}
$quantity = $line_item_wrapper->quantity
->value();
return $settings['status'] && registration_has_room('commerce_product', $id, $quantity);
}