Some statistics

  • Posts: 427
  • Thank you received: 19
6 years 2 months ago #297633

Hi, can I show total orders a single vendor has in show_block_characteristic.php?

Last edit: 6 years 2 months ago by neo191987.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
6 years 2 months ago #297639

Hello,

You'll need to write a SQL Query to count the number of order assigned to the vendor via order_vendor_id.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: neo191987

Please Log in or Create an account to join the conversation.

  • Posts: 427
  • Thank you received: 19
6 years 2 months ago #297662

Thanks. I made the code and worked. Can you check if I'm wrong somewhere.

<?php
$vendorClass = hikamarket::get('class.vendor');
$vendor_user = $vendorClass->get($variant->product_vendor_id,'vendor');
$vendor_id = $vendor_user->vendor_id;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = 'SELECT a.*, c.* FROM `#__hikashop_order` AS a INNER JOIN `#__order_user_id` AS c ON a.order_user_id = c.user_id '.'WHERE a.order_vendor_id = ' . $vendor_id . ' AND a.order_type = \'subsale\' ORDER BY a.order_id DESC';
$query = 'SELECT COUNT(*) FROM `#__hikashop_order` AS a WHERE a.order_vendor_id = ' . $vendor_id . ' AND a.order_type = \'subsale\'';
$db->setQuery($query);
$orders = $db->loadObjectList();
$orders_count = $db->loadResult();
?>

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
6 years 2 months ago #297665

Hello,

You can simply it a lot

$vendor_id = (int)$variant->product_vendor_id;
$db = JFactory::getDbo();
$query = 'SELECT COUNT(*) FROM `#__hikashop_order` WHERE order_vendor_id = ' . $vendor_id . ' AND order_type = '.$db->Quote('subsale');
$db->setQuery($query);
$orders_count = $db->loadResult();
Afterwards, you might want to just count confirmed orders ; like it is done in HikaShop and HikaMarket.
The idea is to filter on the order_status for invoice statuses : "confirmed" and "shipped".
$query .= ' AND order_status IN (\'confirmed\',\'shipped\')';

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: neo191987

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.054 seconds
Powered by Kunena Forum