Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions modules/payment/commerce_payment.module
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,35 @@ function commerce_payment_theme() {
);
}

/**
* Implements hook_modules_disabled().
*
* Disable rules for disabled payment methods.
*/
function commerce_payment_modules_disabled($modules) {
foreach($modules as $module_name) {
// Check if module being disabled implements payment methods.
if (module_hook($module_name, 'commerce_payment_method_info')) {
// Loop over all payment methods this module declares.
foreach (array_keys(module_invoke($module_name, 'commerce_payment_method_info')) as $payment_method_id) {
$rules_config = rules_config_load('commerce_payment_' . $payment_method_id);
if ($rules_config->active) {
if (!$rules_config->hasStatus(ENTITY_OVERRIDDEN)) {
// If the rule wasn't overridden it's safe to delete it so it get
// recreated when the payment module is re-enabled.
$rules_config->delete();
}
else {
// Otherwise, just disable and save it.
$rules_config->active = FALSE;
$rules_config->save();
}
}
}
}
}
}

/**
* Adds the necessary CSS for the line item summary template.
*/
Expand Down