Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Show The Total Number Of Active Vendors On The Backend Rate Topic   - - - - -

 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 158 posts

Posted 24 July 2020 - 07:50 AM #1

Hello, this code {$general_stats.companies.total_companies|number_format} counts the number of sellers on the backend, i want it to count only the active vendors, I tried adding this "AND companies.status = 'A'" but it didn't work, any help is appreciated



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1203 posts

Posted 24 July 2020 - 07:48 PM #2

Hello

 

Where did you try add condition "AND companies.status = 'A'"

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 158 posts

Posted 26 July 2020 - 09:00 AM #3

I tried adding this as an if condition before the code it'self, but i can't get it to work. this is the dashboard on the backend it shows all vendors but i want it to show only the number of vendors that are active



 
  • soft-solid
  • Junior Member
  • Authorized Reseller
  • Join Date: 19-Apr 10
  • 1203 posts

Posted 26 July 2020 - 11:04 AM #4

Hello

 

Please show complete sql query.

 

Best regards

Robert


Team of SoftSolid
cs-cart.pl, marketplace

We specialize in creating the highest quality addons, safe, useful and flexible


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 20771 posts

Posted 27 July 2020 - 06:04 AM #5

Hello, this code {$general_stats.companies.total_companies|number_format} counts the number of sellers on the backend, i want it to count only the active vendors, I tried adding this "AND companies.status = 'A'" but it didn't work, any help is appreciated

 

Where did you add this condition?


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 158 posts

Posted 27 July 2020 - 07:52 PM #6

Where did you add this condition?

 

 

public_html/design/backend/templates/views/index/index.tpl



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11659 posts

Posted 27 July 2020 - 10:54 PM #7

If I'm understanding correctly, I think you're a bit confused.  Template variables are set in PHP code and passed to templates.
So your use of:

{$general_stats.companies.total_companies|number_format}

will only get you what is stored in the registry as $general_stats.companies.  I'd suggest you set your own variable and then use hooks to position the info where you want it.  I.e. in app/addons/my_changes/controllers/backend/companies.post.php do something like:

if( $_SERVER['REQUEST_METHOD'] == 'GET' ) {
  $active_companies = db_get_field("SELECT count(*) FROM ?:companies where status='A'");
  Tygh::$app['view']->assign('active_companies', $active_companies);
}

And then use it in your template as:

<p>{__("active_companies")}: {$active_companies}</p>

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Dexterflamez
  • Senior Member
  • Trial users
  • Join Date: 08-Jan 18
  • 158 posts

Posted Yesterday, 02:44 AM #8

 

If I'm understanding correctly, I think you're a bit confused.  Template variables are set in PHP code and passed to templates.
So your use of:

{$general_stats.companies.total_companies|number_format}

will only get you what is stored in the registry as $general_stats.companies.  I'd suggest you set your own variable and then use hooks to position the info where you want it.  I.e. in app/addons/my_changes/controllers/backend/companies.post.php do something like:

if( $_SERVER['REQUEST_METHOD'] == 'GET' ) {
  $active_companies = db_get_field("SELECT count(*) FROM ?:companies where status='A'");
  Tygh::$app['view']->assign('active_companies', $active_companies);
}

And then use it in your template as:

<p>{__("active_companies")}: {$active_companies}</p>

 

 

Thank you so much fro the idea, worked great. i have another thing I'm trying to figure out, I'm trying to check if company on the frontend already exist then show error message, it checks the email but i want it to also check if a company name on the front end already exists, this is what i have tried, any help is appreciated.

 

//check if the entered company name already exists in the database

 

if (!isset($user_data['company'])) {
           $user_data['company'] = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $user_id);
        }
        
        $is_exist = fn_is_user_exists($user_id, $user_data);
 
//show error message if true
 
        if ($is_exist) {
            fn_set_notification('E', __('error'), __('error_user_exists'), '', 'user_exist');
 
            return false;
        }


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11659 posts

Posted Yesterday, 06:22 PM #9

Not sure where you're getting the code.  If 'company' isn't set, not sure why you'd set it to email.  If you want to set $is_exist based on the $email of the user or $user_data['company'] then I'd change it to something like:

$is_exist = !db_get_field("SELECT user_id FROM ?:users WHERE email=?s", $email) && !db_get_field("SELECT company FROM ?:companies WHERE company=?s and lang_code=?s", $user_data['company'], DESCR_SL);

 

UNTESTED - also is a general statement, may not be specific to the code you're referencing or to your needs.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.