Customer Query for targetting

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
Hi All

I was wondering if a site administrator can run a query identifying all their clients who have NOT bought a product from vendor ABC and then target those clients with a one-time Coupon offering a discount on their first purchase.  I could not see this option in the documentation.

Thanks
1 year ago
No you would need to create a custom report and target function to do this

Depending on the number of products, vendors and customers you would need to a way to identify how the combinations would be put together.
i.e. does every customer get a coupon targeting every product or do you have a discount code for all products send to every customer
1 year ago
Execute these queries on sql server:
1. Customers who did not buy products from Vendor 1:

SELECT c.Username,c.Email from [Customer] c
where c.Id not in (
Select distinct o.CustomerId from [Order] o
where o.Id in (Select distinct OrderId from [OrderItem] oi
inner join [Product] p
on oi.ProductId = p.Id
where p.VendorId = (select top 1 Id from Vendor where Name = 'Vendor 1')))
and c.Username is not null



2. Customers who uses a coupon code on his first purchase (note: only possible if admin does not change coupon code requirement on a discount):

SELECT c.Username,c.Email,o.OrderTotal,o.OrderDiscount, d.Name from [Customer] c
left outer join [Order] o
on c.Id = o.CustomerId
left outer join [DiscountUsageHistory] duh
on o.Id = duh.OrderId
left outer join [Discount] d
on duh.DiscountId = d.Id
where o.OrderDiscount > 0 and d.RequiresCouponCode = 'true'
and o.Id in (select Id
from (
select Id,row_number() over(partition by CustomerId order by Id asc) as roworder
from [Order]
) temp
where roworder = 1)

1 year ago
Thank you both for your responses. So it looks like a site administrator cannot but at the SQL query level its possible. That's great.
1 year ago
In addition:
If you want to execute SQL query on back admin and want to see result/report then you may use this plugin!
https://www.nop-station.com/sql-manager-mssql
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.