[Skip to main content](#vessel-content)

#   How to retrieve product quantity per J user ID

##

- **[alexsmirnov](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")**
- [![alexsmirnov's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar25100.jpg)](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile") Topic Author
- [ Offline](/forum/user/25100-alexsmirnov)

Less More

- Posts: 24
- Thank you received: 1
-
-
-

12 years 10 months ago [\#137788](#137788) by [alexsmirnov](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")  *[How to retrieve product quantity per J user ID](/forum/35-orders-management/864560-how-to-retrieve-product-quantity-per-j-user-id#137788 "-- 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:  // $user = JFactory::getUser(); $db = JFactory::getDbo(); $userId = $user-&gt;get('id');  // Is the user logged in? if ($userId) { // Grab the value from the database. $db-&gt;setQuery(&quot;SELECT &#96;firstname&#96; FROM &#96;#&#95;&#95;comprofiler&#96; WHERE &#96;user&#95;id&#96;='&quot;.$userId.&quot;'&quot;); return $db-&gt;loadResult(); } //  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")* was created by *[alexsmirnov](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")*

-- 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:

//&lt;code&gt;
$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user-&gt;get('id');

// Is the user logged in?
if ($userId) {
// Grab the value from the database.
$db-&gt;setQuery("SELECT &#96;firstname&#96; FROM &#96;#__comprofiler&#96; WHERE &#96;user_id&#96;='".$userId."'");
return $db-&gt;loadResult();
}
//&lt;/code&gt;

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg2NDU2MC1ob3ctdG8tcmV0cmlldmUtcHJvZHVjdC1xdWFudGl0eS1wZXItai11c2VyLWlkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Online](/forum/user/63-nicolas)

Less More

- Posts: 86315
- Thank you received: 14276
-
-

12 years 10 months ago [\#137876](#137876) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to retrieve product quantity per J user ID](/forum/35-orders-management/864560-how-to-retrieve-product-quantity-per-j-user-id#137876 "-- 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:  // $user = JFactory::getUser(); $db = JFactory::getDbo(); $userId = $user-&gt;get('id');  // Is the user logged in? if ($userId) { // Grab the value from the database. $db-&gt;setQuery(&quot;SELECT &#96;firstname&#96; FROM &#96;#&#95;&#95;comprofiler&#96; WHERE &#96;user&#95;id&#96;='&quot;.$userId.&quot;'&quot;); return $db-&gt;loadResult(); } //  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")*

Hi, Code:

$db-&gt;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](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg2NDU2MC1ob3ctdG8tcmV0cmlldmUtcHJvZHVjdC1xdWFudGl0eS1wZXItai11c2VyLWlkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[alexsmirnov](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")**
- [![alexsmirnov's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar25100.jpg)](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile") Topic Author
- [ Offline](/forum/user/25100-alexsmirnov)

Less More

- Posts: 24
- Thank you received: 1
-
-
-

12 years 10 months ago [\#137934](#137934) by [alexsmirnov](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")  Replied by *[alexsmirnov](/forum/user/25100-alexsmirnov "View alexsmirnov's Profile")* on topic *[How to retrieve product quantity per J user ID](/forum/35-orders-management/864560-how-to-retrieve-product-quantity-per-j-user-id#137934 "-- 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:  // $user = JFactory::getUser(); $db = JFactory::getDbo(); $userId = $user-&gt;get('id');  // Is the user logged in? if ($userId) { // Grab the value from the database. $db-&gt;setQuery(&quot;SELECT &#96;firstname&#96; FROM &#96;#&#95;&#95;comprofiler&#96; WHERE &#96;user&#95;id&#96;='&quot;.$userId.&quot;'&quot;); return $db-&gt;loadResult(); } //  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")*

Cheers, Nicolas. This query worked like charm.

---

Seek and you shall find.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg2NDU2MC1ob3ctdG8tcmV0cmlldmUtcHJvZHVjdC1xdWFudGl0eS1wZXItai11c2VyLWlkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.154 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
