Display orders where ONLY Product X was purchased

  • Posts: 194
  • Thank you received: 5
7 years 6 months ago #252065

-- HikaShop version -- : 2.6.x
-- Joomla version -- : 3.6.2
-- PHP version -- : 7.x
-- Browser(s) name and version -- : var.

Is there any way to create a report that shows all orders where Product X was purchased but NO OTHER products were purchased?

If they purchased Product X AND Product Y I don't want that in the report.

If it's not available somehow within the report system, can you give any tips on how to do that via sql?

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

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
7 years 6 months ago #252079

Hi,

I don't see a way to do that with either the reports system or the mass actions system.
It will require a custom MySQL query.
Something like that for example (to be tested):
SELECT o.*, op1.* FROM #__hikashop_order as o LEFT JOIN #__hikashop_order_product as op1 ON o.order_id = op1.order_id AND op1.product_id = XXX LEFT JOIN #__hikashop_order_product as op2 ON o.order_id = op2.order_id AND op2.product_id != XXX WHERE op2.product_id IS NULL;

Here with load all the orders with a product with the id XXX and with no products with the id different from XXX.

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

Time to create page: 0.057 seconds
Powered by Kunena Forum