- Posts: 431
- Thank you received: 19
Some statistics
8 years 3 weeks ago - 8 years 3 weeks ago #297633
by neo191987
Some statistics was created by neo191987
Hi, can I show total orders a single vendor has in show_block_characteristic.php?
Last edit: 8 years 3 weeks ago by neo191987.
Please Log in or Create an account to join the conversation.
8 years 3 weeks ago #297639
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Some statistics
Hello,
You'll need to write a SQL Query to count the number of order assigned to the vendor via order_vendor_id.
Regards,
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.
The following user(s) said Thank You: neo191987
Please Log in or Create an account to join the conversation.
8 years 3 weeks ago #297662
by neo191987
Replied by neo191987 on topic Some statistics
Thanks. I made the code and worked. Can you check if I'm wrong somewhere.
Code:
<?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.
8 years 3 weeks ago #297665
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Some statistics
Hello,
You can simply it a lot
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".
Regards,
You can simply it a lot
Code:
$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();
The idea is to filter on the order_status for invoice statuses : "confirmed" and "shipped".
Code:
$query .= ' AND order_status IN (\'confirmed\',\'shipped\')';
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
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.189 seconds