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

  • Posts: 224
  • Thank you received: 8
5 years 2 months ago #302149

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

$query->select('count(op.order_product_id)')
            ->from('#__hikashop_user AS u')
            ->leftJoin('#__hikashop_order AS o ON u.user_id = o.order_user_id')
            ->leftJoin('#__hikashop_order_product AS op ON op.order_id = o.order_id')
            ->where('u.user_cms_id = ' . (int)$user->id)
            ->where('op.product_id IN (' . implode(',', array_map('intval', (array)$productIds)) . ')')
            ->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?
->where("o.order_status = 'confirmed,confirmedinvoice'");

thank you

Please Log in or Create an account to join the conversation.

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
5 years 2 months ago #302150

Hi,

No, you can do it like that:

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

The following user(s) said Thank You: oloccina

Please Log in or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum