Trying to find anything on automatic vendor approval, have no luck. Is there such a function that I can turn on?
If there isn't, what would be the reason for not having it? Just to check everyone?
Is it an easy fix to add?
Thank you
Trying to find anything on automatic vendor approval, have no luck. Is there such a function that I can turn on?
If there isn't, what would be the reason for not having it? Just to check everyone?
Is it an easy fix to add?
Thank you
Trying to find anything on automatic vendor approval, have no luck. Is there such a function that I can turn on?
If there isn't, what would be the reason for not having it? Just to check everyone?
Is it an easy fix to add?
Thank you
Pay attention to the Vendor Data Premoderation add-on. You can find the information on it in our Docs: http://docs.cs-cart.com/4.3.x/user_guide/addons/vendor_data_premoderation/index.html
Do you mean that the Vendor account should not receive Pending status after registration?
Pay attention to the Vendor Data Premoderation add-on. You can find the information on it in our Docs: http://docs.cs-cart.com/4.3.x/user_guide/addons/vendor_data_premoderation/index.html
This doesn't solve the problem. I want a way for vendors apply for an account and being approved without us looking at it. Is there such thing?
Try the following:
app/controllers/frontend/companies.php
replace:
if (!$result) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request'));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
}
if (!$result) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request'));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
} else {
fn_companies_change_status($result, ‘A’, ‘’, ‘N’);
}
(!) Not tested
Try the following:
app/controllers/frontend/companies.php
replace:
if (!$result) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request'));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
}
withif (!$result) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request'));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
} else {
fn_companies_change_status($result, ‘A’, ‘’, ‘N’);
}(!) Not tested
Get this page:
http://screencast.com/t/QqBCsMoB8lf
The vendor registration goes through, but no automatic approval.
Please check the source code of this page. Error message should be displayed at bottom
The correct solution is:
if (!$result) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request'));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
} else {
$status_from = ‘N’;
fn_companies_change_status($result, ‘A’, ‘’, $status_from);
}
also it is required to open the app/functions/fn.users.php file and replace:
'user_type' => 'C', // FIXME?
with
'user_type' => (!empty($user_data['user_type']) && $user_data['user_type'] != 'A') ? $user_data['user_type'] : 'C',
Tested Sure it will help
Go To: [CScart root]/app/controllers/frontend/companies.php
& replace all code with this :
use Tygh\Registry;
use Tygh\Mailer;if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
if ($mode == 'apply_for_vendor') { if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') { return array(CONTROLLER_STATUS_NO_PAGE); } if (fn_image_verification('apply_for_vendor_account', $_REQUEST) == false) { fn_save_post_data('user_data', 'company_data'); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } $data = $_REQUEST['company_data']; $data['timestamp'] = TIME; $data['status'] = 'N'; $data['request_user_id'] = !empty($auth['user_id']) ? $auth['user_id'] : 0; $account_data = array(); $account_data['fields'] = isset($_REQUEST['user_data']['fields']) ? $_REQUEST['user_data']['fields'] : ''; $account_data['admin_firstname'] = isset($_REQUEST['company_data']['admin_firstname']) ? $_REQUEST['company_data']['admin_firstname'] : ''; $account_data['admin_lastname'] = isset($_REQUEST['company_data']['admin_lastname']) ? $_REQUEST['company_data']['admin_lastname'] : ''; $data['request_account_data'] = serialize($account_data); if (empty($data['request_user_id'])) { $login_condition = empty($data['request_account_name']) ? '' : db_quote(" OR user_login = ?s", $data['request_account_name']); $user_account_exists = db_get_field("SELECT user_id FROM ?:users WHERE email = ?s ?p", $data['email'], $login_condition); if ($user_account_exists) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('error_user_exists')); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } } $company_id = fn_update_company($data); $data = array_merge($data, fn_get_company_data($company_id)); if (!$company_id) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request')); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } $status_from = 'N'; fn_change_company_status($company_id, 'A','', $status_from); // Notify user department on the new vendor application Mailer::sendMail(array( 'to' => 'default_company_users_department', 'from' => 'default_company_users_department', 'data' => array( 'company_id' => $company_id, 'company' => $data ), 'tpl' => 'companies/apply_for_vendor_notification.tpl', ), 'A', Registry::get('settings.Appearance.backend_default_language')); $return_url = !empty(Tygh::$app['session']['apply_for_vendor']['return_url']) ? Tygh::$app['session']['apply_for_vendor']['return_url'] : fn_url(''); unset(Tygh::$app['session']['apply_for_vendor']['return_url']); return array(CONTROLLER_STATUS_REDIRECT, $return_url); }
}
if (fn_allowed_for(‘ULTIMATE’)) {
if ($mode == ‘entry_page’) {
$countries = array();$companies_countries = db_get_array('SELECT storefront, countries_list FROM ?:companies'); foreach ($companies_countries as $data) { if (empty($data['countries_list'])) { continue; } $_countries = explode(',', $data['countries_list']); foreach ($_countries as $code) { $countries[$code] = strpos($data['storefront'], 'http://') === false ? 'http://' . $data['storefront'] : $data['storefront']; } } $country_descriptions = fn_get_countries_name(array_keys($countries)); Tygh::$app['session']['entry_page'] = true; Tygh::$app['view']->assign('countries', $countries); Tygh::$app['view']->assign('country_descriptions', $country_descriptions); Tygh::$app['view']->display('views/companies/components/entry_page.tpl'); exit; }
}
if ($mode == ‘view’) {
$company_data = !empty($_REQUEST['company_id']) ? fn_get_company_data($_REQUEST['company_id']) : array(); if (empty($company_data) || empty($company_data['status']) || !empty($company_data['status']) && $company_data['status'] != 'A') { return array(CONTROLLER_STATUS_NO_PAGE); } fn_add_breadcrumb(__('all_vendors'), 'companies.catalog'); fn_add_breadcrumb($company_data['company']); $company_data['total_products'] = count(db_get_fields(fn_get_products(array( 'get_query' => true, 'company_id' => $_REQUEST['company_id'] )))); $company_data['logos'] = fn_get_logos($company_data['company_id']); Registry::set('navigation.tabs', array( 'description' => array( 'title' => __('description'), 'js' => true ) )); $params = array( 'company_id' => $_REQUEST['company_id'], ); Tygh::$app['view']->assign('company_data', $company_data);
} elseif ($mode == ‘catalog’) {
fn_add_breadcrumb(__('all_vendors')); $params = $_REQUEST; $params['status'] = 'A'; $params['get_description'] = 'Y'; $vendors_per_page = Registry::get('settings.Vendors.vendors_per_page'); list($companies, $search) = fn_get_companies($params, $auth, $vendors_per_page); foreach ($companies as &$company) { $company['logos'] = fn_get_logos($company['company_id']); } Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search);
} elseif ($mode == ‘apply_for_vendor’) {
if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') { return array(CONTROLLER_STATUS_NO_PAGE); } $restored_company_data = fn_restore_post_data('company_data'); if ($restored_company_data) { Tygh::$app['view']->assign('company_data', $restored_company_data); } $restored_user_data = fn_restore_post_data('user_data'); if ($restored_user_data) { Tygh::$app['view']->assign('user_data', $restored_user_data); } $profile_fields = fn_get_profile_fields('A', array(), CART_LANGUAGE, array('get_custom' => true, 'get_profile_required' => true)); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); fn_add_breadcrumb(__('apply_for_vendor_account')); Tygh::$app['session']['apply_for_vendor']['return_url'] = !empty($_REQUEST['return_previous_url']) ? $_REQUEST['return_previous_url'] : fn_url('');
} elseif ($mode == ‘products’) {
$company_data = !empty($_REQUEST[‘company_id’]) ? fn_get_company_data($_REQUEST[‘company_id’]) : array();if (empty($company_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } $company_id = $company_data['company_id']; fn_add_breadcrumb(__('all_vendors'), 'companies.catalog'); $params = $_REQUEST; $params['company_id'] = $company_id; $params['extend'] = array('description'); if (!empty($_REQUEST['category_id'])) { fn_add_breadcrumb($company_data['company'], 'companies.products?company_id=' . $company_id); $category_id = $_REQUEST['category_id']; // Get full data for current category $category_data = fn_get_category_data($category_id); if (!empty($category_data)) { $params['cid'] = $category_id; if (Registry::get('settings.General.show_products_from_subcategories') == 'Y') { $params['subcats'] = 'Y'; } // [Breadcrumbs] $parent_ids = explode('/', $category_data['id_path']); array_pop($parent_ids); if (!empty($parent_ids)) { $cats = fn_get_category_name($parent_ids); foreach ($parent_ids as $c_id) { fn_add_breadcrumb($cats[$c_id], "companies.products?category_id=$c_id&company_id=$company_id"); } } fn_add_breadcrumb($category_data['category']); } // Get subcategories list for current category Tygh::$app['view']->assign('subcategories', fn_get_subcategories( $category_id, array('company_ids' => $company_data['company_id']) )); Tygh::$app['view']->assign('category_data', $category_data); Tygh::$app['view']->assign('reset_url', fn_url('companies.products?category_id=' . $category_id . '&company_id=' . $company_id)); } else { if (!empty($_REQUEST['q'])) { fn_add_breadcrumb($company_data['company'], 'companies.products?company_id=' . $company_id); fn_add_breadcrumb(__('search')); } else { fn_add_breadcrumb($company_data['company']); } Tygh::$app['view']->assign('reset_url', fn_url('companies.products?company_id=' . $company_id)); } list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page')); if (defined('AJAX_REQUEST') && (!empty($params['features_hash']) && !$products)) { fn_filters_not_found_notification(); exit; } fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => true, 'get_options'=> true)); if (!empty($products)) { Tygh::$app['session']['continue_url'] = Registry::get('config.current_url'); } $selected_layout = fn_get_products_layout($params); Tygh::$app['view']->assign('products', $products); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('selected_layout', $selected_layout); Tygh::$app['view']->assign('company_id', $company_data['company_id']); Registry::set('runtime.vendor_id', $company_id);
}
this is really great! Has anyone figured out how to automatically assign a group to the vendor user profile?
this is really great! Has anyone figured out how to automatically assign a group to the vendor user profile?
You can use the fn_change_usergroup_status function. E.g.
if (!$company_id) {
fn_save_post_data(‘user_data’, ‘company_data’);
fn_set_notification(‘E’, __(‘error’), __(‘text_error_adding_request’));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
} else {
fn_companies_change_status($company_id, ‘A’, ‘’, ‘N’);
$users = db_get_fields(“SELECT user_id FROM ?:users WHERE user_type = ?s AND company_id = ?i”, ‘V’, $company_id);
foreach ($users as $uid) {
fn_change_usergroup_status(‘A’, $uid, USERGROUP_ID);
}
}
You can use the fn_change_usergroup_status function. E.g.
if (!$company_id) {
fn_save_post_data(‘user_data’, ‘company_data’);
fn_set_notification(‘E’, __(‘error’), __(‘text_error_adding_request’));return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor');
} else {
fn_companies_change_status($company_id, ‘A’, ‘’, ‘N’);
$users = db_get_fields(“SELECT user_id FROM ?:users WHERE user_type = ?s AND company_id = ?i”, ‘V’, $company_id);
foreach ($users as $uid) {
fn_change_usergroup_status(‘A’, $uid, USERGROUP_ID);
}
}
Thanks eCOMLabs
Do i replace USERGROUP_ID with the name of the group?
Thanks eCOMLabs
Do i replace USERGROUP_ID with the name of the group?
Replace it with user group ID
Tested Sure it will help
Go To: [CScart root]/app/controllers/frontend/companies.php
& replace all code with this :
use Tygh\Registry;
use Tygh\Mailer;if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
if ($mode == 'apply_for_vendor') { if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') { return array(CONTROLLER_STATUS_NO_PAGE); } if (fn_image_verification('apply_for_vendor_account', $_REQUEST) == false) { fn_save_post_data('user_data', 'company_data'); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } $data = $_REQUEST['company_data']; $data['timestamp'] = TIME; $data['status'] = 'N'; $data['request_user_id'] = !empty($auth['user_id']) ? $auth['user_id'] : 0; $account_data = array(); $account_data['fields'] = isset($_REQUEST['user_data']['fields']) ? $_REQUEST['user_data']['fields'] : ''; $account_data['admin_firstname'] = isset($_REQUEST['company_data']['admin_firstname']) ? $_REQUEST['company_data']['admin_firstname'] : ''; $account_data['admin_lastname'] = isset($_REQUEST['company_data']['admin_lastname']) ? $_REQUEST['company_data']['admin_lastname'] : ''; $data['request_account_data'] = serialize($account_data); if (empty($data['request_user_id'])) { $login_condition = empty($data['request_account_name']) ? '' : db_quote(" OR user_login = ?s", $data['request_account_name']); $user_account_exists = db_get_field("SELECT user_id FROM ?:users WHERE email = ?s ?p", $data['email'], $login_condition); if ($user_account_exists) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('error_user_exists')); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } } $company_id = fn_update_company($data); $data = array_merge($data, fn_get_company_data($company_id)); if (!$company_id) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request')); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } $status_from = 'N'; fn_change_company_status($company_id, 'A','', $status_from); // Notify user department on the new vendor application Mailer::sendMail(array( 'to' => 'default_company_users_department', 'from' => 'default_company_users_department', 'data' => array( 'company_id' => $company_id, 'company' => $data ), 'tpl' => 'companies/apply_for_vendor_notification.tpl', ), 'A', Registry::get('settings.Appearance.backend_default_language')); $return_url = !empty(Tygh::$app['session']['apply_for_vendor']['return_url']) ? Tygh::$app['session']['apply_for_vendor']['return_url'] : fn_url(''); unset(Tygh::$app['session']['apply_for_vendor']['return_url']); return array(CONTROLLER_STATUS_REDIRECT, $return_url); }
}
if (fn_allowed_for(‘ULTIMATE’)) {
if ($mode == ‘entry_page’) {
$countries = array();$companies_countries = db_get_array('SELECT storefront, countries_list FROM ?:companies'); foreach ($companies_countries as $data) { if (empty($data['countries_list'])) { continue; } $_countries = explode(',', $data['countries_list']); foreach ($_countries as $code) { $countries[$code] = strpos($data['storefront'], 'http://') === false ? 'http://' . $data['storefront'] : $data['storefront']; } } $country_descriptions = fn_get_countries_name(array_keys($countries)); Tygh::$app['session']['entry_page'] = true; Tygh::$app['view']->assign('countries', $countries); Tygh::$app['view']->assign('country_descriptions', $country_descriptions); Tygh::$app['view']->display('views/companies/components/entry_page.tpl'); exit; }
}
if ($mode == ‘view’) {
$company_data = !empty($_REQUEST['company_id']) ? fn_get_company_data($_REQUEST['company_id']) : array(); if (empty($company_data) || empty($company_data['status']) || !empty($company_data['status']) && $company_data['status'] != 'A') { return array(CONTROLLER_STATUS_NO_PAGE); } fn_add_breadcrumb(__('all_vendors'), 'companies.catalog'); fn_add_breadcrumb($company_data['company']); $company_data['total_products'] = count(db_get_fields(fn_get_products(array( 'get_query' => true, 'company_id' => $_REQUEST['company_id'] )))); $company_data['logos'] = fn_get_logos($company_data['company_id']); Registry::set('navigation.tabs', array( 'description' => array( 'title' => __('description'), 'js' => true ) )); $params = array( 'company_id' => $_REQUEST['company_id'], ); Tygh::$app['view']->assign('company_data', $company_data);
} elseif ($mode == ‘catalog’) {
fn_add_breadcrumb(__('all_vendors')); $params = $_REQUEST; $params['status'] = 'A'; $params['get_description'] = 'Y'; $vendors_per_page = Registry::get('settings.Vendors.vendors_per_page'); list($companies, $search) = fn_get_companies($params, $auth, $vendors_per_page); foreach ($companies as &$company) { $company['logos'] = fn_get_logos($company['company_id']); } Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search);
} elseif ($mode == ‘apply_for_vendor’) {
if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') { return array(CONTROLLER_STATUS_NO_PAGE); } $restored_company_data = fn_restore_post_data('company_data'); if ($restored_company_data) { Tygh::$app['view']->assign('company_data', $restored_company_data); } $restored_user_data = fn_restore_post_data('user_data'); if ($restored_user_data) { Tygh::$app['view']->assign('user_data', $restored_user_data); } $profile_fields = fn_get_profile_fields('A', array(), CART_LANGUAGE, array('get_custom' => true, 'get_profile_required' => true)); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); fn_add_breadcrumb(__('apply_for_vendor_account')); Tygh::$app['session']['apply_for_vendor']['return_url'] = !empty($_REQUEST['return_previous_url']) ? $_REQUEST['return_previous_url'] : fn_url('');
} elseif ($mode == ‘products’) {
$company_data = !empty($_REQUEST[‘company_id’]) ? fn_get_company_data($_REQUEST[‘company_id’]) : array();if (empty($company_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } $company_id = $company_data['company_id']; fn_add_breadcrumb(__('all_vendors'), 'companies.catalog'); $params = $_REQUEST; $params['company_id'] = $company_id; $params['extend'] = array('description'); if (!empty($_REQUEST['category_id'])) { fn_add_breadcrumb($company_data['company'], 'companies.products?company_id=' . $company_id); $category_id = $_REQUEST['category_id']; // Get full data for current category $category_data = fn_get_category_data($category_id); if (!empty($category_data)) { $params['cid'] = $category_id; if (Registry::get('settings.General.show_products_from_subcategories') == 'Y') { $params['subcats'] = 'Y'; } // [Breadcrumbs] $parent_ids = explode('/', $category_data['id_path']); array_pop($parent_ids); if (!empty($parent_ids)) { $cats = fn_get_category_name($parent_ids); foreach ($parent_ids as $c_id) { fn_add_breadcrumb($cats[$c_id], "companies.products?category_id=$c_id&company_id=$company_id"); } } fn_add_breadcrumb($category_data['category']); } // Get subcategories list for current category Tygh::$app['view']->assign('subcategories', fn_get_subcategories( $category_id, array('company_ids' => $company_data['company_id']) )); Tygh::$app['view']->assign('category_data', $category_data); Tygh::$app['view']->assign('reset_url', fn_url('companies.products?category_id=' . $category_id . '&company_id=' . $company_id)); } else { if (!empty($_REQUEST['q'])) { fn_add_breadcrumb($company_data['company'], 'companies.products?company_id=' . $company_id); fn_add_breadcrumb(__('search')); } else { fn_add_breadcrumb($company_data['company']); } Tygh::$app['view']->assign('reset_url', fn_url('companies.products?company_id=' . $company_id)); } list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page')); if (defined('AJAX_REQUEST') && (!empty($params['features_hash']) && !$products)) { fn_filters_not_found_notification(); exit; } fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => true, 'get_options'=> true)); if (!empty($products)) { Tygh::$app['session']['continue_url'] = Registry::get('config.current_url'); } $selected_layout = fn_get_products_layout($params); Tygh::$app['view']->assign('products', $products); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('selected_layout', $selected_layout); Tygh::$app['view']->assign('company_id', $company_data['company_id']); Registry::set('runtime.vendor_id', $company_id);
}
the message intended for the admin is displayed to the vendor. How can this be disabled?
the message intended for the admin is displayed to the vendor. How can this be disabled?
Please clarify your question?
Please clarify your question?
I'm referring to this default message from cs-cart when new vendor is approved:
Notice New administrator account has been successfully created. You can edit the account details now.
I'm referring to this default message from cs-cart when new vendor is approved:
Notice New administrator account has been successfully created. You can edit the account details now.
app/functions/fn.companies.php
replace 2 lines:
fn_set_notification('N', __('notice'), $msg, 'K');
with
//fn_set_notification('N', __('notice'), $msg, 'K');