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

#   DB query to check if user purchased a product, little suggestion needed

##

- **[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
-
-

7 years 10 months ago [\#302149](#302149) by [oloccina](/forum/user/23273-oloccina "View oloccina's Profile")  *[DB query to check if user purchased a product, little suggestion needed](/forum/35-orders-management/896577-db-query-to-check-if-user-purchased-a-product-little-suggestion-needed#302149 "Hello, I use a db query to check if a user purchased a product  question: how do I add another order status to the last line? I want the query to return a true value also for the status with namekey confirmedinvoice  I just do it like this?  thank you")* was created by *[oloccina](/forum/user/23273-oloccina "View oloccina's Profile")*

Hello,
I use a db query to check if a user purchased a product Code:

$query-&gt;select('count(op.order_product_id)') -&gt;from('#__hikashop_user AS u') -&gt;leftJoin('#__hikashop_order AS o ON u.user_id = o.order_user_id') -&gt;leftJoin('#__hikashop_order_product AS op ON op.order_id = o.order_id') -&gt;where('u.user_cms_id = ' . (int)$user-&gt;id) -&gt;where('op.product_id IN (' . implode(',', array_map('intval', (array)$productIds)) . ')') -&gt;where("o.order_status = 'confirmed'");

**question:**
how do I add another order status to the last line?
I want the query to return a true value also for the status with namekey *confirmedinvoice*

I just do it like this? Code:

-&gt;where("o.order_status = 'confirmed,confirmedinvoice'");

thank you

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

Less More

- Posts: 86583
- Thank you received: 14324
-
-

7 years 10 months ago [\#302150](#302150) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[DB query to check if user purchased a product, little suggestion needed](/forum/35-orders-management/896577-db-query-to-check-if-user-purchased-a-product-little-suggestion-needed#302150 "Hello, I use a db query to check if a user purchased a product  question: how do I add another order status to the last line? I want the query to return a true value also for the status with namekey confirmedinvoice  I just do it like this?  thank you")*

Hi,

No, you can do it like that: Code:

-&gt;where("o.order_status IN ( 'confirmed', 'confirmedinvoice')");

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

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

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