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

#   Database check for products bought by a user?

##

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

Less More

- Posts: 224
- Thank you received: 8
-
-

8 years 6 months ago [\#291974](#291974) by [oloccina](/forum/user/23273-oloccina "View oloccina's Profile")  *[Database check for products bought by a user?](/forum/25-install-update/894573-database-check-for-products-bought-by-a-user#291974 "Hello, I would like to use conditional content extension (regular labs) to show/hide contents on the website based on product bought by the user. Thsi extension has a cutom PHP settings and the description reads like this: Enter a piece of PHP code to evaluate. The code must return the value true or false. For instance: return ( $user-&gt;name == 'Peter van Westen' );  So my question is it is possible to check in the DB if the user has bought a certain product, and if yes could you suggest the necessary PHP sintax to use that extension?  Thank you")* was created by *[oloccina](/forum/user/23273-oloccina "View oloccina's Profile")*

Hello,
I would like to use conditional content extension (regular labs) to show/hide contents on the website based on product bought by the user.
Thsi extension has a cutom PHP settings and the description reads like this:
*Enter a piece of PHP code to evaluate. The code must return the value true or false.
For instance:
return ( $user-&gt;name == 'Peter van Westen' );*

So my question is it is possible to check in the DB if the user has bought a certain product, and if yes could you suggest the necessary PHP sintax to use that extension?

Thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzg5NDU3My1kYXRhYmFzZS1jaGVjay1mb3ItcHJvZHVjdHMtYm91Z2h0LWJ5LWEtdXNlcj90bXBsPW1hcmtkb3du) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86357
- Thank you received: 14289
-
-

8 years 6 months ago [\#292014](#292014) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Database check for products bought by a user?](/forum/25-install-update/894573-database-check-for-products-bought-by-a-user#292014 "Hello, I would like to use conditional content extension (regular labs) to show/hide contents on the website based on product bought by the user. Thsi extension has a cutom PHP settings and the description reads like this: Enter a piece of PHP code to evaluate. The code must return the value true or false. For instance: return ( $user-&gt;name == 'Peter van Westen' );  So my question is it is possible to check in the DB if the user has bought a certain product, and if yes could you suggest the necessary PHP sintax to use that extension?  Thank you")*

Hi,

Yes.

Something like that: Code:

$db = JFactory::getDBO(); $db-&gt;setQuery('SELECT o.order_product_id 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.order_id = o.order_id WHERE u.user_cms_id = '.(int)$user-&gt;id.' AND op.product_id = XXXX AND o.order_status=\'confirmed\' LIMIT 1'); return (bool)$db-&gt;loadResult();

where XXXX is the id of the product.

The following user(s) said Thank You: [kilou](/forum/user/32861-kilou "View kilou's Profile")

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

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

Less More

- Posts: 224
- Thank you received: 8
-
-

8 years 6 months ago [\#292031](#292031) by [oloccina](/forum/user/23273-oloccina "View oloccina's Profile")  Replied by *[oloccina](/forum/user/23273-oloccina "View oloccina's Profile")* on topic *[Database check for products bought by a user?](/forum/25-install-update/894573-database-check-for-products-bought-by-a-user#292031 "Hello, I would like to use conditional content extension (regular labs) to show/hide contents on the website based on product bought by the user. Thsi extension has a cutom PHP settings and the description reads like this: Enter a piece of PHP code to evaluate. The code must return the value true or false. For instance: return ( $user-&gt;name == 'Peter van Westen' );  So my question is it is possible to check in the DB if the user has bought a certain product, and if yes could you suggest the necessary PHP sintax to use that extension?  Thank you")*

Thanks a lot Nicolas,
I will hire a developer to complete this step and post here the solution to use along with regularlabs conditional content, just in case someone else is looking for something similar.

The following user(s) said Thank You: [kilou](/forum/user/32861-kilou "View kilou's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzg5NDU3My1kYXRhYmFzZS1jaGVjay1mb3ItcHJvZHVjdHMtYm91Z2h0LWJ5LWEtdXNlcj90bXBsPW1hcmtkb3du) 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.071 seconds

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