commerce_discount.info.inc | 1 + commerce_discount.module | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/commerce_discount.info.inc b/commerce_discount.info.inc index 26222eb..ac5d029 100644 --- a/commerce_discount.info.inc +++ b/commerce_discount.info.inc @@ -17,6 +17,7 @@ class CommerceDiscountMetadataController extends EntityDefaultMetadataController $properties['status']['type'] = 'boolean'; $properties['component_title']['translatable'] = TRUE; $properties['component_title']['i18n string'] = TRUE; + return $info; } } diff --git a/commerce_discount.module b/commerce_discount.module index 03772d7..5b4fac5 100644 --- a/commerce_discount.module +++ b/commerce_discount.module @@ -347,7 +347,9 @@ function commerce_discount_field_widget_form_alter(&$element, &$form_state, $con * Rebuild Rules configuration. */ function commerce_discount_commerce_discount_insert($entity) { - i18n_string_object_update('commerce_discount', $entity); + if (module_exists('i18n_string')) { + i18n_string_object_update('commerce_discount', $entity); + } entity_defaults_rebuild(array('rules_config')); } @@ -357,10 +359,15 @@ function commerce_discount_commerce_discount_insert($entity) { * Rebuild Rules configuration. */ function commerce_discount_commerce_discount_update($entity) { - if ($entity->original->name != $entity->name) { - i18n_string_update_context("commerce_discount:commerce_discount:" . $entity->original->name . ":component_title", "commerce_discount:commerce_discount:" . $entity->name . ":component_title"); + if (module_exists('i18n_string')) { + if ($entity->original->name != $entity->name) { + i18n_string_update_context( + "commerce_discount:commerce_discount:" . $entity->original->name . ":component_title", + "commerce_discount:commerce_discount:" . $entity->name . ":component_title" + ); + } + i18n_string_object_update('commerce_discount', $entity); } - i18n_string_object_update('commerce_discount', $entity); entity_defaults_rebuild(array('rules_config')); } @@ -370,7 +377,9 @@ function commerce_discount_commerce_discount_update($entity) { * Delete referenced commerce_discount_offer upon commerce_discount deletion. */ function commerce_discount_commerce_discount_delete($entity) { - i18n_string_object_remove('commerce_discount', $entity); + if (module_exists('i18n_string')) { + i18n_string_object_remove('commerce_discount', $entity); + } $wrapper = entity_metadata_wrapper('commerce_discount', $entity); // Delete the referenced commerce_discount_offer. if ($wrapper->commerce_discount_offer->value()) {