Some statistics

  • Posts: 281
  • Thank you received: 6
  • Hikaauction Standard Hikamarket Multivendor Hikaserial Subscription Hikashop Business
4 months 1 week ago #297633

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

Last Edit: 4 months 1 week ago by neo191987.

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

  • Posts: 23202
  • Thank you received: 3592
  • MODERATOR
4 months 1 week 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: 281
  • Thank you received: 6
  • Hikaauction Standard Hikamarket Multivendor Hikaserial Subscription Hikashop Business
4 months 1 week 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: 23202
  • Thank you received: 3592
  • MODERATOR
4 months 1 week 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.079 seconds
Powered by Kunena Forum