- Posts: 24
- Thank you received: 1
How to retrieve product quantity per J user ID
- alexsmirnov
-
Topic Author
- Offline
Less
More
12 years 9 months ago #137788
by alexsmirnov
Seek and you shall find.
How to retrieve product quantity per J user ID was created by alexsmirnov
-- url of the page with the problem -- : localhost
-- HikaShop version -- : 2.2.3
-- Joomla version -- : 2.5.17
-- PHP version -- : 5.4.6
Hi there,
After my HikaShop customer pays for a product, he will need to log in and fill in for me a small web form in which, as he fills it in, I will need one of his fields to be calculated based on the quantity of the HikaShop product he just purchased.
I am using RSForms Pro to construct the form and one of their tutorials deals with similar task: it inserts into the form field a Cummunity Builder user first name with this code:
//<code>
$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user->get('id');
// Is the user logged in?
if ($userId) {
// Grab the value from the database.
$db->setQuery("SELECT `firstname` FROM `#__comprofiler` WHERE `user_id`='".$userId."'");
return $db->loadResult();
}
//</code>
Could you advise what SELECT would help me to retrieve the quantity of the product from the last order of a logged in Joomla 2.5 user/HikaShop customer?
Cheers,
Alex
-- HikaShop version -- : 2.2.3
-- Joomla version -- : 2.5.17
-- PHP version -- : 5.4.6
Hi there,
After my HikaShop customer pays for a product, he will need to log in and fill in for me a small web form in which, as he fills it in, I will need one of his fields to be calculated based on the quantity of the HikaShop product he just purchased.
I am using RSForms Pro to construct the form and one of their tutorials deals with similar task: it inserts into the form field a Cummunity Builder user first name with this code:
//<code>
$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user->get('id');
// Is the user logged in?
if ($userId) {
// Grab the value from the database.
$db->setQuery("SELECT `firstname` FROM `#__comprofiler` WHERE `user_id`='".$userId."'");
return $db->loadResult();
}
//</code>
Could you advise what SELECT would help me to retrieve the quantity of the product from the last order of a logged in Joomla 2.5 user/HikaShop customer?
Cheers,
Alex
Seek and you shall find.
Please Log in or Create an account to join the conversation.
12 years 9 months ago #137876
by nicolas
Replied by nicolas on topic How to retrieve product quantity per J user ID
Hi,
Code:
$db->setQuery("SELECT op.order_product_quantity FROM #__hikashop_user AS u LEFT JOIN #__hikashop_order AS o ON u.user_id=o.order_user_id LEFT JOIN #__hikashop_order_product AS op ON o.order_id=op.order_id WHERE u.user_cms_id=".(int)$userId." ORDER BY o.order_id DESC;");
The following user(s) said Thank You: alexsmirnov
Please Log in or Create an account to join the conversation.
- alexsmirnov
-
Topic Author
- Offline
Less
More
- Posts: 24
- Thank you received: 1
12 years 9 months ago #137934
by alexsmirnov
Seek and you shall find.
Replied by alexsmirnov on topic How to retrieve product quantity per J user ID
Cheers, Nicolas. This query worked like charm.
Seek and you shall find.
Please Log in or Create an account to join the conversation.
Time to create page: 0.145 seconds