function commerce_recurring_product_is_recurring in Commerce Recurring Framework 7.2
Determine if a product has recurring properties.
Parameters
$product: Commerce product.
Return value
bool
3 calls to commerce_recurring_product_is_recurring()
- CommerceRecurringTestCase::testCommerceRecurringProductIsRecurring in tests/
commerce_recurring.test - Test product is recurring check.
- commerce_recurring_order_load_recurring_line_items in ./
commerce_recurring.module - Return all the line items that contain a recurring product in an order context.
- commerce_recurring_rules_set_price in ./
commerce_recurring.rules.inc - Action callback to override the listing price by the one in initial price of the recurring framework.
File
- ./
commerce_recurring.module, line 469 - Commerce recurring module file.
Code
function commerce_recurring_product_is_recurring($product) {
// If the product is of type recurring, we don't need to look anything else.
if ($product->type == 'recurring') {
return TRUE;
}
// In case of other product types, they still might be recurring ones, check
// for the presence of any of the recurring fields.
$fields = array(
'commerce_recurring_ini_price',
'commerce_recurring_rec_price',
'commerce_recurring_ini_period',
'commerce_recurring_rec_period',
'commerce_recurring_end_period',
);
foreach ($fields as $field_name) {
if ($items = field_get_items('commerce_product', $product, $field_name)) {
return TRUE;
}
}
// @TODO: Add a hook to be able to set recurring product types otherwise.
return FALSE;
}