- Posts: 224
- Thank you received: 8
Database check for products bought by a user?
8 years 5 months ago #291974
by oloccina
Database check for products bought by a user? was created by oloccina
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->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
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->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 or Create an account to join the conversation.
8 years 5 months ago #292014
by nicolas
Replied by nicolas on topic Database check for products bought by a user?
Hi,
Yes.
Something like that:
where XXXX is the id of the product.
Yes.
Something like that:
Code:
$db = JFactory::getDBO();
$db->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->id.' AND op.product_id = XXXX AND o.order_status=\'confirmed\' LIMIT 1');
return (bool)$db->loadResult();
The following user(s) said Thank You: kilou
Please Log in or Create an account to join the conversation.
8 years 5 months ago #292031
by oloccina
Replied by oloccina on topic Database check for products bought by a user?
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.
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
Please Log in or Create an account to join the conversation.
Time to create page: 0.140 seconds