diff --git a/myaccount/register_instance.php b/myaccount/register_instance.php index 79eebb77b..22ad461f8 100644 --- a/myaccount/register_instance.php +++ b/myaccount/register_instance.php @@ -1150,7 +1150,14 @@ if (! empty($conf->global->SELLYOURSAAS_DEFAULT_CUSTOMER_CATEG)) { dol_syslog("register_instance.php We will set customer into the categroy"); - $result = $tmpthirdparty->setCategories(array($conf->global->SELLYOURSAAS_DEFAULT_CUSTOMER_CATEG => $conf->global->SELLYOURSAAS_DEFAULT_CUSTOMER_CATEG), 'customer'); + // To prevent deletion of categories already present + $categories = $tmpthirdparty->getCategoriesCommon('customer'); + $arraycateg = array($conf->global->SELLYOURSAAS_DEFAULT_CUSTOMER_CATEG => $conf->global->SELLYOURSAAS_DEFAULT_CUSTOMER_CATEG); + if (is_array($categories) && !in_array($conf->global->SELLYOURSAAS_DEFAULT_CUSTOMER_CATEG, $categories)){ + $categories = array_merge($categories, $arraycateg); + } + + $result = $tmpthirdparty->setCategories($categories, 'customer'); if ($result < 0) { $db->rollback();