diff --git a/resources/pot/retailcrm-es_ES.pot b/resources/pot/retailcrm-es_ES.pot index 243f9d5..5714022 100644 --- a/resources/pot/retailcrm-es_ES.pot +++ b/resources/pot/retailcrm-es_ES.pot @@ -136,15 +136,6 @@ msgstr "Métodos de pago" msgid "Delivery types" msgstr "Métodos de envío" -msgid "Select client roles which will be uploaded from website to Simla.com" -msgstr "Seleccione los roles del cliente que se cargarán desde el sitio web a Simla.com" - -msgid "Client roles available for uploading to Simla.com" -msgstr "Roles del cliente disponibles para cargar en Simla.com" - -msgid "Client roles" -msgstr "Roles del cliente" - msgid "Select order methods which will be uploaded from Simla.com to the website" msgstr "Elige el método de formalización de los pedidos que se van a subir desde Simla.com a la página web" diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot index d7708ed..7ac7369 100644 --- a/resources/pot/retailcrm-ru_RU.pot +++ b/resources/pot/retailcrm-ru_RU.pot @@ -145,15 +145,6 @@ msgstr "Способы оплаты" msgid "Delivery types" msgstr "Способы доставки" -msgid "Select client roles which will be uploaded from website to Simla.com" -msgstr "Выберите роли клиентов, которые будут выгружаться в Simla.com" - -msgid "Client roles available for uploading to Simla.com" -msgstr "Роли клиентов, доступные для выгрузки в Simla.com" - -msgid "Client roles" -msgstr "Роли клиентов" - msgid "Select order methods which will be uploaded from Simla.com to the website" msgstr "Выберите способы оформления заказов, которые будут выгружаться из Simla.com на сайт" diff --git a/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php b/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php index a28bc8d..7fd2e60 100644 --- a/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php +++ b/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php @@ -167,36 +167,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration ); } - /** - * Client roles options - */ - $client_roles_option = array(); - $client_roles_list = wp_roles()->get_names(); - - if (!empty($client_roles_list)) { - foreach ($client_roles_list as $code => $name) { - $client_roles_option[$code] = $name; - } - - $this->form_fields[] = array( - 'title' => __('Client roles', 'retailcrm'), - 'type' => 'heading', - 'description' => '', - 'id' => 'client_roles_options' - ); - - $this->form_fields['client_roles'] = array( - 'label' => ' ', - 'title' => __('Client roles available for uploading to Simla.com', 'retailcrm'), - 'class' => '', - 'type' => 'multiselect', - 'description' => __('Select client roles which will be uploaded from website to Simla.com', 'retailcrm'), - 'options' => $client_roles_option, - 'css' => 'min-height:100px;', - 'select_buttons' => true - ); - } - /** * Order methods options */ diff --git a/src/include/class-wc-retailcrm-customers.php b/src/include/class-wc-retailcrm-customers.php index 6ff9b2c..99033d1 100644 --- a/src/include/class-wc-retailcrm-customers.php +++ b/src/include/class-wc-retailcrm-customers.php @@ -599,32 +599,19 @@ if (!class_exists('WC_Retailcrm_Customers')) : */ public function isCustomer($user) { - $retailcrmSettings = array(); - - if (!empty($this->retailcrm_settings) && array_key_exists('client_roles', $this->retailcrm_settings)) { - $retailcrmSettings = $this->retailcrm_settings['client_roles']; - } - - if (empty($retailcrmSettings)) { - $selectedRoles = array(self::CUSTOMER_ROLE, self::ADMIN_ROLE); - } else { - $selectedRoles = $retailcrmSettings; - } + $clientRoles = wp_roles()->get_names(); + $clientRoles = apply_filters('retailcrm_customer_roles', WC_Retailcrm_Plugin::clearArray($clientRoles)); if ($user instanceof WP_User) { - $userRoles = $user->roles; + $userRole = empty($user->roles[0]) === false ? $user->roles[0] : null; } elseif ($user instanceof WC_Customer) { - $wpUser = get_user_by('id', $user->get_id()); - $userRoles = ($wpUser) ? $wpUser->roles : array($user->get_role()); + $role = $user->get_role(); + $userRole = empty($role) === false ? $role : null; } else { return false; } - $result = array_filter($userRoles, function ($userRole) use ($selectedRoles) { - return in_array($userRole, $selectedRoles); - }); - - return !empty($result); + return empty($clientRoles[$userRole]) === false; } } endif; diff --git a/src/languages/retailcrm-es_ES.mo b/src/languages/retailcrm-es_ES.mo index 0eeef13..0af6985 100644 Binary files a/src/languages/retailcrm-es_ES.mo and b/src/languages/retailcrm-es_ES.mo differ diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo index bd19454..9496683 100644 Binary files a/src/languages/retailcrm-ru_RU.mo and b/src/languages/retailcrm-ru_RU.mo differ