Skip to main content

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

More
7 years 9 months ago #302149 by oloccina
Hello,
I use a db query to check if a user purchased a product
Code:
$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?
Code:
->where("o.order_status = 'confirmed,confirmedinvoice'");

thank you

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

More
7 years 9 months ago #302150 by nicolas
Hi,

No, you can do it like that:
Code:
->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.208 seconds
Powered by Kunena Forum