- Posts: 53
- Thank you received: 2
Display total value of the orders for a client
12 years 7 months ago #144087
by otx
Display total value of the orders for a client was created by otx
-- url of the page with the problem -- :
www.vitaking.ro
-- HikaShop version -- : 2.2.3
-- Joomla version -- : 3.2
-- PHP version -- : 5.3.10
-- Browser(s) name and version -- : Chromium 31
-- Error-message(debug-mod must be tuned on) -- : Error_message
Hi,
We would like to display in the user orders history page the total value of all the orders, belonging to the current account. The problem is that if we are using the listing.php loop it gets displayed only the total value for the current pagination. Can you please give us some hint about how we can achieve this?
Regards,
Dezso Markon,
vitaking.ro
-- HikaShop version -- : 2.2.3
-- Joomla version -- : 3.2
-- PHP version -- : 5.3.10
-- Browser(s) name and version -- : Chromium 31
-- Error-message(debug-mod must be tuned on) -- : Error_message
Hi,
We would like to display in the user orders history page the total value of all the orders, belonging to the current account. The problem is that if we are using the listing.php loop it gets displayed only the total value for the current pagination. Can you please give us some hint about how we can achieve this?
Regards,
Dezso Markon,
vitaking.ro
Please Log in or Create an account to join the conversation.
12 years 7 months ago #144102
by Tristan
Replied by Tristan on topic Display total value of the orders for a client
You don't have the choice : you have to make a sql query to load all the prices.
Insert this code in the listing.php file :
The total you're looking for will be load in the $total[0] variable, I let you display it as your convenience.
Insert this code in the listing.php file :
Code:
$db = JFactory::getDBO();
$user_id = hikashop_loadUser();
$query = 'SELECT SUM(order_full_price) FROM `#__hikashop_order` WHERE order_user_id = '.$user_id.';';
$db->setQuery($query);
$total= $db->loadObjectList();
The following user(s) said Thank You: otx
Please Log in or Create an account to join the conversation.
12 years 7 months ago #144111
by otx
Replied by otx on topic Display total value of the orders for a client
Thank you!
Printing $total[0] renders the page inoperable.
My array looks like this: Array ( [0] => stdClass Object ( [SUM(order_full_price)] => 13874.35000 ))
So $total[0] it's not an integer or a value. I guess you know the solution for this
Thanks.
Printing $total[0] renders the page inoperable.
My array looks like this: Array ( [0] => stdClass Object ( [SUM(order_full_price)] => 13874.35000 ))
So $total[0] it's not an integer or a value. I guess you know the solution for this
Thanks.
Please Log in or Create an account to join the conversation.
12 years 7 months ago #144234
by nicolas
Replied by nicolas on topic Display total value of the orders for a client
instead of:
$total= $db->loadObjectList();
to:
$total= $db->loadResult();
and you'll get directly the price in the $total variable that you'll be able to print directly.
$total= $db->loadObjectList();
to:
$total= $db->loadResult();
and you'll get directly the price in the $total variable that you'll be able to print directly.
The following user(s) said Thank You: otx
Please Log in or Create an account to join the conversation.
12 years 7 months ago #144348
by otx
Replied by otx on topic Display total value of the orders for a client
Thank you Nicolas, it's perfect!
Please Log in or Create an account to join the conversation.
Time to create page: 0.183 seconds